SA-MP Forums Archive
Timer doesn't get destroyed - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Timer doesn't get destroyed (/showthread.php?tid=248688)



Timer doesn't get destroyed - Jochemd - 15.04.2011

Hello,

I am having this issue for ages. I can't get it fixed. The problem is; a timer does not get killed, though it says in the script!
pawn Код:
case 1:
                            {
                                new randpos = random(5);
                                switch(randpos)
                                {
                                    case 0: SetPlayerPos(target,693.7203,-4412.6436,6.9868);
                                    case 1: SetPlayerPos(target,683.7387,-4412.4180,6.9868);
                                    case 2: SetPlayerPos(target,672.3016,-4414.1641,6.9868);
                                    case 3: SetPlayerPos(target,681.9968,-4392.6797,6.9868);
                                    case 4: SetPlayerPos(target,693.0054,-4392.3984,6.9868);
                                }
                                SetPlayerInterior(target,1);
                                PlayerInfo[playerid][JailCountDownTimer] = SetTimerEx("OnPlayerReleaseJail",1000,1,"i",target);
                                SetInfoBoxMessage(target,"~y~You have been ~r~jailed ~y~ by a ~b~Police Officer ~y~for 10 minutes",6000);
                                SetPVarInt(target,"JailCountDown",600);
                                SendClientMessage(playerid,COLOR_GREEN,"    You've arrested a criminal. $1000 has been added to your Pay-Day.");
                                SetInfoBoxMessage(playerid,"~r~$1000 ~y~added to your ~w~Paycheck",4000);
                                SetPlayerWantedLevel(target,0);
                                SetPVarInt(playerid,"PayDayExtra",GetPVarInt(playerid,"PayDayExtra") + 1000);
                                SetPVarInt(target,"IsCuffed",0);
                            }
(a snippet from arrest)
pawn Код:
public OnPlayerReleaseJail(playerid)
{
    if(GetPVarInt(playerid,"JailCountDown") > 0)
    {
        new string[5];
        format(string,sizeof(string),"%d",GetPVarInt(playerid,"JailCountDown"));
        GameTextForPlayer(playerid,string,1100,6);
        SetPVarInt(playerid,"JailCountDown",GetPVarInt(playerid,"JailCountDown") -1);
        return 1;
    }
    KillTimer(PlayerInfo[playerid][JailCountDownTimer]);
    SetPlayerInterior(playerid,10);
    SetPlayerPos(playerid,241.3580,117.5502,1003.2188);
    SetPlayerFacingAngle(playerid,208.2633);
    SetCameraBehindPlayer(playerid);
    SetInfoBoxMessage(playerid,"~y~You have been ~r~released ~y~from ~b~jail. ~y~Criminal records have been ~b~cleared.",4000);
    GameTextForPlayer(playerid,"~y~Behave ~b~yourself ~y~now!",4000,1);
    return 1;
}
It just keeps giving the info box 'You have been released from jail" and sets my pos back every time to the pos above. Why is it? My script is just correct?

Jochem


Re: Timer doesn't get destroyed - mrcoolballs - 15.04.2011

Post the line where you use SetTimer


Re: Timer doesn't get destroyed - Stigg - 15.04.2011

Quote:
Originally Posted by mrcoolballs
Посмотреть сообщение
Post the line where you use SetTimer
It's already there.


Re: Timer doesn't get destroyed - Jochemd - 15.04.2011

I tried to set the PVar to -1, let's see if that works

Edit: didn't work.

Edit 2: Just noticed in /arrest; The timer (PlayerInfo) gets set for the cop, not the target :/


Re: Timer doesn't get destroyed - Kayaque - 15.04.2011

First off all.. You're writing stuff into the one executing the command. (playerid)

PlayerInfo[target][JailCountDownTimer] ( "target" is the id you entered into your /arrest command)

And instead of KillTimer(PlayerInfo[target][JailCountDownTimer]);
Use KillTimer(JailCountDownTimer);

Hope that helped a little.


Re: Timer doesn't get destroyed - Jochemd - 15.04.2011

What you are saying at last is totally wrong.

I already fixed it, yeah, I had playerid in stead of target.