Timer Problem
#1

i put a timer on the command 'breakcuff' they can use it after 3 minutes
but the timer is not working.. can anyone help me ?
pawn Код:
dcmd_breakcuff(playerid, params[])
{
   #pragma unused params
   new string[128];
       if(GetTickCount()-GetPVarInt(playerid,"TimerBreakcuff")>180000)
        {
        SetPVarInt(playerid,"TimerBreakcuff",GetTickCount());
        SendClientMessage(playerid, COLOR_GREY, "You have succesfully escape! Run from Police!!.");
        }
        else
        {
            SendClientMessage(playerid, COLOR_ERROR, "Please wait 3 minutes to use this command again");
        }
        if(IsSpawned[playerid] != 1)
        {
            SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
            return 1;
        }
        if(IsFrozen[playerid] == 1)
        {
            SendClientMessage(playerid,COLOR_ERROR,"You have been frozen by a Server Administrator. You cannot use this command.");
            return 1;
        }
        if(IsKidnapped[playerid] == 1)
        {
            SendClientMessage(playerid,COLOR_ERROR,"You are kidnapped. You cannot use this command.");
            return 1;
        }
        if(IsCuffed[playerid] == 0)
        {
            SendClientMessage(playerid,COLOR_ERROR,"You are not handcuffed. You cannot use this command");
            return 1;
        }
        if(IsKidnapped[playerid] == 1)
        {
           SendClientMessage(playerid,COLOR_ERROR,"You are kidnapped. You cannot use this command.");
           return 1;
        }
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
        {
           SendClientMessage(playerid,COLOR_ERROR,"You cannot use /breakcuff while in a vehicle. Exit the vehicle first.");
           return 1;
        }
            format(string,sizeof(string), "[CRIMINAL ACTION] %s(%d) has used /breakcuff to escape from cops",PlayerName(playerid), playerid);
            SendClientMessageToAll(COLOR_ERROR, string);
            format(string,sizeof(string),"[POLICE RADIO] Escape Cuff: %s(%d) has escape from cuff Catch And Arrrest Them!",PlayerName(playerid), playerid);
            SendClientMessageToAllCops(string);

            TogglePlayerControllable(playerid,1);
            IncreaseWantedLevel(playerid,8);
            IncreasePlayerScore(playerid,1);
            IsCuffed[playerid] =0;
            SetPlayerSpecialAction(playerid ,SPECIAL_ACTION_NONE);
            ClearAnimations(playerid);

    return 1;
}
Reply
#2

anyone??
Reply
#3

Well, there's no timer at all, just a tick count. I guess your problem is that you get the "Please wait 3 minutes to use this command again" message and players can use the command though, isn't it?


Also I can see something that could harm your mode a bit, although it has nothing to do with your current problem. Why do you declare that string at this place? I can see it ONLY used when all the checks (IsSpawned, IsFrozen, etc.) are false, so why don't you declare it right before you start using it (i.e. before the first Format())?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)