Originally Posted by leonardo1434
This may work, a little thing, your code is pretty messed up, try fixing this mess, it may help you alot for prevent future mistakes.
pawn Код:
CMD:cuff(playerid, params[]) { new ID,pname[24],opname[24],string[200]; if(!IsPlayerACop(playerid)) return SendClientMessage(playerid, COLOR_RED,"You are not a law enforcement."); if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You cannot use this command in a vehicle."); if(sscanf(params, "u", ID)) return SendClientMessage(playerid, COLOR_RED, "Usage: /cuff (ID)"); if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, "Invalid ID."); GetPlayerName(ID, opname, 24); GetPlayerName(playerid, pname, 24); if(GetDistanceBetweenPlayers(playerid, ID) > 3) return SendClientMessage(playerid, COLOR_RED, "That player is too far away to be cuffed."); if(IsPlayerInAnyVehicle(ID)) return SendClientMessage(playerid, COLOR_RED, "That player is in a vehicle. You cannot cuff him."); if(IsPlayerACop(ID)) return SendClientMessage(playerid, COLOR_RED, "You cannot cuff other Law Enforcements."); TogglePlayerControllable(ID, 0); GameTextForPlayer(ID, "~b~HANDCUFFED!", 5000, 1); format(string, sizeof(string), "[POLICE] Officer %s(%d) has put hand cuffs on you. You cannot move.", pname, playerid); SendClientMessage(ID, COLOR_LIGHTBLUE, string); format(string, 200, "[DISPATCH] Officer %s(%d) has cuffed player %s(%d)", pname, playerid, opname, ID); SendClientMessage(playerid, COLOR_LIGHTBLUE, "[POLICE] You have cuffed a suspect. You have 30 seconds before they get uncuffed."); SetTimerEx(#cuffed,2000*10,false,"i",ID); // it gonna repate once, since is set to false, and only for the ID, which is the victim. return 1; } forward cuffed(playerid); public cuffed(playerid) { SendClientMessage(playerid,-1,#you're free); return TogglePlayerControllable(playerid, 1); // unfreezing him. }
@ These guys that posted above are kinda wrong, first one is not required a loop or even call the settimer every second, is just required once, and doesn't require to destroy it, cause it's once.
second, why we would put a settimer on ongamemodeinit? to call it every 20 seconds, kinda useless.
|