Jump to content

removeCommandHandler crashes the server


ArmedGuy

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...