custom python script in a map? -1 reply

Please wait...

Guest

I didn't make it!

0 XP

 
#1 10 years ago

Hi there, is there any way to insert a custom python script directly in a map directory, as opposed to inserting it in a mod's python directory?

I don't want to modify any modfile for custom mapping, although having custom scripts in a map would be quite useful.

what does execfile (used to call each map's mapdata.py from perMapData.py) exactly do? in other words, can mapdata.py only be used to read dicts?

PS: keep in mind I don't really know python, or programming in general :P so please use simple words to explain :D




ctz

FH Devolver

50 XP

17th May 2004

0 Uploads

655 Posts

0 Threads

#2 10 years ago

execfile runs mapdata.py as a standalone script, so yes you can do all sorts of things in your mapdata.py like include custom python plugins which can change many things.




Guest

I didn't make it!

0 XP

 
#3 10 years ago

I must be doing something wrong then... I tried placing this simple code in the map's mapdata.py import host

def init(): host.rcon_invoke('sv.numPlayersNeededToStart 1')

But it doesn't appear to be working, at least when hosting the map as multiplayer conquest on local (no dedicated server)...

I placed the same mapdata file in the map dir, server.zip and client.zip. What am I doing wrong?




Guest

I didn't make it!

0 XP

 
#4 10 years ago

bump.... (I know, that's not very polite netiquettewise)

does anyone know how to solve this? I've made no progress since then :(




Guest

I didn't make it!

0 XP

 
#5 10 years ago

Ok I found out what the problem was, just ignore the post above :banghead:




Guest

I didn't make it!

0 XP

 
#6 10 years ago

Personally I would just like to know what file the command is in normally. Ive spent all morning looking to get a map to run with just me in my created server. I have ths on my laptop so I'm not worried about online gaming, but it would help me test some basic changes I'm doing to the python code since the tickets wont bleed unless I do it.

Thanks in advance to the person who can tell me. (or even the way you did it Rattovolante)




Guest

I didn't make it!

0 XP

 
#7 10 years ago

I'm not sure I understand what you mean. You just want to have your map start with only 1 player when you test it in local?

This is usually done by enteringsv.numPlayersNeededToStart 1 in the console (to activate the console, while in-game press the key left of "1" - IIRC, it should be "~" on standard English keyboards)

If you want to have it automatically executed every time you run a specific map just insert this code into the map's mapdata.py: import host host.rcon_invoke('sv.numPlayersNeededToStart 1')

This simply instructs python to send a 'sv.numPlayersNeededToStart 1' string to the remote console (rcon) when the map is started.

I think you only need to insert it into the mapdata.py inside the server.zip file, but I'm not 100% sure (if you test this, let me know)




Guest

I didn't make it!

0 XP

 
#8 10 years ago

Thanks I used the console command to test my change. ------- BTW it worked. Nothing important, but I found once that I had 8 kills and no deaths. At the end of the round the person with the highest K/D ratio had a 2. This means that anyone who doesn't have a death in game is excluded from the final k/d tally because you cannot divide by zero.

All I needed to do was add an Else statement where I just had it take the kills and divide by 1. Although not a true K/D ratio it allows players who do manage not to die to be recognized.