Jump to content
Official BF Editor Forums

Krauzi

Members
  • Posts

    262
  • Joined

  • Last visited

Everything posted by Krauzi

  1. this was just an example code i wanted to use the fileManager for copying Level data from vanilla bf2 to my mod
  2. i know that this is a very old topic but i did fix the problem this way: adding 7 kits to the init.con and modify the spawnmenu (give kit 5-7 x-coordinates of 600). bots can select this kits but humans cannot.
  3. Hello guys, the example of the fileManager ( http://bf2.fun-o-matic.org/index.php/ConGrammar [at the bottom]) doesnt seem to work anymore. Can anyone confirm this?
  4. if i remember right, host.rcon_invoke can also return values. so maybe a host.rcon_invoke("sv.spawnTime") will return the respawn time value. Dont have bf2 installed atm but ill try to help you within the next days if i have time.
  5. sure, it is open source under Apache Licence 2.
  6. oh lol i found out that the old (1.4.2) version works perfectly with bf2 version 1.5. Btw: I've coded a gamespy login emulator so you can enjoy the unlocks (which only works with online accounts) even if you dont have internet: http://gsloginserver.googlecode.com
  7. Hi guys, because BF2Statistics is down and i dont have any forum access any more now (where 1.5 fixes were published) i ask you guys here: Anyone has a working BF2statistics (especially the ASP thing) for BF2 with patch 1.5 or fixes for the current stat (1.4.2)? Cheers Krauzi.
  8. I think if you want to write a real game with good graphics and networkcode you cant avoid coding the core in C++. Some time ago i tried to rewrite a basic part of the python core (from C to C++) but i finally gave up because it were to many objects i had to change. But one thing i recognized was that python is not written very efficient and often not very smart (for example the whole dictoffset thing). I spent the last few weeks of my holidays (the last school holidays i'll ever have) to code a library which allowes you to easily integreate python into c++. Ill publish it here if you want (but im not yet finished). Anyway: Python isn't meant to be a language you should write a entire game in.
  9. ok then they changed a lot between 2.3 and < 2.3. Then maybe this works strlen = len(text)-len("turbo") text = text[ strlen : len(text) ] Anyway there shouldnt be any difference between demo and final bf2 (python side only). About your last question: I think you mean something like this: Clan_Members = ["name1", "name2", "name3", "name4"] def onPlayerSpawn( player, soldier ): if player.getName() in Clan_Members: #dunno weather this works because the CLAN tag could be in the name if not hasattr(player, "greet_sent"): sendrankstuff( player, rank, otherargs ) #i dont know the function for this atm player.greet_sent = True something like that should work. EDIT: I tested my script out and it seems to work on my BF2 client 1.5 (non demo): import bf2 import host def init(): host.registerHandler('ChatMessage', onChatMessage, 1) def onChatMessage(playerid, text, channel, flags): if len(text) < len("turbo"): return text = text[ len(text)-len("turbo") : ] if text == "turbo": host.rcon_invoke("ObjectTemplate.activeSafe Engine JEEP_FAAV_Engine") host.rcon_invoke("ObjectTemplate.setTorque 600 ") host.rcon_invoke("ObjectTemplate.newCar2.maxRpm 8000 ") host.rcon_invoke('game.sayall "|ccc|Turbo Activated!|ccc|"')
  10. ups maybe there was a syntax change with the array operator within python 2.3 -> < 2.3. Maybe try this one: text = text[ ( len(text)-len("turbo") ) : ]
  11. dont get into habit of doing this that way! You better code universal (this will avoid many error sources) like I've done in my script (which is also a lot of faster then the whole replace stuff [because you only copy a array once in comparison to 4 time copy with the replace stuff]).
  12. i think that the "if text[0:1] == "turbo"" thing doesnt work! You should better replace the whole text.replace stuff with: text = text[ len(text)-len("turbo") : ] if text == "turbo": #host.rcon_invoke stuff EDIT: Full code then: import bf2 import host def init(): host.rcon_invoke('game.sayall "Scrippy Loaded"') host.registerHandler('ChatMessage', onChatMessage, 1) def onChatMessage(playerid, text, channel, flags): if playerID == -1: playerID = 255 text = text[ len(text)-len("turbo") : ] if text == "turbo": host.rcon_invoke("ObjectTemplate.activeSafe Engine JEEP_FAAV_Engine") host.rcon_invoke("ObjectTemplate.setTorque 600 ") host.rcon_invoke("ObjectTemplate.newCar2.maxRpm 8000 ") host.rcon_invoke('game.sayall "|ccc| Turbo Activated!|ccc|"') host.rcon_invoke('game.sayall "end of invoke!"')
  13. This triggers can only (as far as i know) be set with python. This works well for static objects like map flags are and this is also used for the flag overtaking logic (see scoringCommon.py)
  14. please a bit more exactly. I dont want to look through the whole code.... @UberWazuSoldier: I'm interested in this too. Do you have any idea how this can work WITHOUT python and then server side (arent all the *.con executed client side?!)?
  15. Hi guys, yeah back now after a (or two?!) years absence of bf2 modding but with quite a lot experience in coding ( C++ [especially python's C-API] and python ). So now about my "start"-project: Pilot script again The last project i was working on was a pilot script which allowed only ppl with a certain kit to enter a certain vehicle (worked with engine disable). But my idea is to disable not only the engine but the entrypoints (so entering isn't even longer possible). This will work quite well on game loading (i iterate through all available vehicles and disable all the entrypoints). But the problem is that if the vehicle is destroyed and another one spawns i cannot disable the entrypoints any more (i cant detected weather i vehicle spawns). So my question: Anyone knows a good way to detect new spawned vehicles? A check with a timer won't make any sense here because (if you do a global vehicle check e.g. every 0.1 secs) it'll cause horrible lags.
  16. Lol you credited me Thanks... Anyone has a copy of my old pilot script from http://bf2-mods.de ? Edit: Lol this post was thought as a reply to http://www.bfeditor.org/forums/index.php?showtopic=14375.
  17. hm for the same round could be right. Anyway this doesnt matter because: 1.) PyObject_CallObjects are not threaded C++ side (this call the python handlers you have registered) 2.) the (PyObject *)s (the instance of the player created on player join) assigned to the player are never deleted. This explains this gigantic memory lacks of the Battlefield 2 Dedicated Server. I would never publish a lacking program. DICE should really take Crysis as example. So the problem which i thought may occur will never do that.
  18. well thats maybe the reason why the execution of the handlers are NOT threaded c++ side.
  19. i dont think so, if you rejoin the game after e.g. a day and this is a popular gameserver there were much more than 255 players in this time on the server. Someone must have had the same id as you had the day before.
  20. about the threading/socket: Both are not possible because 1.) threading is not allowed c++/c-side and 2.) socket needs threading (if nonblocking) which is not allowed. This is the reason: The c++ class Player create a python instance of the python class Player (python/PlayerManager.py). This instance is registered on the c++ instance. IF threading WOULD be allowed, you could do something like this: Register a attribute on Player spawn: player.a = 1 player.b = 2 player leaves now which deletes the python player instance you are using at the moment player.c = 3 # crash here you CAN maybe get threading working by importing _thread and do the whole crap with GIL requests and releases. But you can't import *.pyd files (_thread IS a dynamic library). What you can do is hooking into the fake_stream (python/__init__.py). You could create a system like when you print something: print "[sOCKET]80.123.255.23 hello world" you can detect weather the print is to be send to the IP or not (e.g. if there is a [sOCKET] at the beginning of the string). Look this script for more info: http://rapidshare.com/files/277404959/bf2_gui_debugging.zip this script hooks into the fake stream (this will save all your "print" statements into the python log file). Hope i was clear (i'm a bit drunken so sry ) Cheers krauzi
  21. hm ok, then another question: Lets suppose you have an action on e.g. playerrevive or playerjoin. And you set several attributes now while the player leaves the game! e.g. player.a = 1 player.b = 2 now player leaves player.c = 3 what will happen now? does this crash the game or isnt this even possible because the python handler execution isnt (multi)threaded?
  22. Hi guys, due to some coding works i need a information about the relationship between playerID and playerIndex (i dont have bf2 installed atm). Are they the same in every case (except i change player.index)? with player.index i mean the (unsigned) char value saved in the python int player.index (see declaration of class Player). playerID is sometimes argument of some pythonEvents. Hope i can get a quick answer Cheers Krauzi
  23. since i am a bit familiar with python's c-api: Did any of you maybe try sys.modules? or adding sys path? Maybe also .pyd modules could work - with them you can generally do all of the os-depending things!
×
×
  • Create New...