ArmedGuy Posted August 10, 2009 Share Posted August 10, 2009 I got a script that when a cop hits a marker a command gets avalible, and when he uses that command that command becomes unavalible... But when i use removeCommandHandler the server crashes and the game too, am im using it on the wrong place? Heres the code: function crimeCommit( playerSource,cmd,crime) local team = getPlayerTeam(playerSource) local teamname = getTeamName(team) if teamname =="SAPD" then if crime=="true" then givePlayerMoney(player, 5000) outputChatBox("Good, That Criminal Is No More, For your Cooperation The SAPD give you 5000 dollars!", player,0,255,0) --added the removeCommandHandler here end if crime=="false" then takePlayerMoney(player, tonumber(10000)) outputChatBox("Prank Calling The Police is NOT ALLOWED, you have now lost 10000 dollars!", player, 255,0,0) --added the removeCommandHandler here end end end this isent the whole code! but what may be the problem? Link to comment
50p Posted August 10, 2009 Share Posted August 10, 2009 Probably server doesn't like you removing command handler in the command. BTW, why do you want to remove the command for everyone when 1 cop types it in? Make a global table of players and check if they can use the command or not. g_Players = { }; -- somewhere at the top of your script ... -- let him use the command g_Players[ player ] = true; ... -- disable the command for him: g_Players[ player ] = false; ... -- inside the function called by command if g_Players[ player ] then -- can he use the command? Link to comment
eAi Posted August 10, 2009 Share Posted August 10, 2009 Of course, scripts shouldn't be able to crash the server, but as 50p says, it's likely an issue with removing command handlers from within a command handler. Link to comment
Lordy Posted August 11, 2009 Share Posted August 11, 2009 If I recall correctly, I noticed that one in dp2.3 too and it indeed was about removing it from inside the handler, but later tested it in nightly and it was fixed. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now