SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 15/05/2015, 07:47 PM   #1
pollo97
Big Clucker
 
pollo97's Avatar
 
Join Date: Sep 2011
Location: Italy
Posts: 83
Reputation: 4
Default Timer doesn't stop

Hi everyone, im making jail command using a timer with repeating true, but when i try to cut off the timer it doesn't.
Here the script.
Code:
stock CheckJail(playerid)
	{
		new time[20];
		if(PlayerData[playerid][pJailTime]==0)
		{
			SendClientMessage(playerid,BIANCO,"Jail finito");
			SetPlayerPos(playerid,2127.7607,2360.1333,10.8203);
			PlayerTextDrawHide(playerid,JailRemainTime[playerid]);
			SetPlayerVirtualWorld(playerid,0);
			KillTimer(JailTimer[playerid]);
		}
		else
		{
			PlayerTextDrawHide(playerid,JailRemainTime[playerid]);
			format(time,sizeof(time),"%d minuti rimanenti",PlayerData[playerid][pJailTime]);
			PlayerTextDrawSetString(playerid,JailRemainTime[playerid],time);  
			PlayerTextDrawShow(playerid,JailRemainTime[playerid]);
		}

	}
This function should kill timer if jail time is 0, else refresh textdraw.


Code:
stock JailTimeLeft(playerid,time,bool:First)
	{
		new hour,minute;
		new tsjail;
		gettime(hour,minute);
		tsjail=(hour*60)+minute;
		printf("%d %d\n",tsjail,tsjailPlusOne[playerid]);
		if(tsjail==tsjailPlusOne[playerid]||First==true)
		{
			if(First)
			{
				TimeForSjail[playerid]=(hour*60)+time+minute;
			}
			tsjailPlusOne[playerid]=(hour*60)+minute+1;
			PlayerData[playerid][pJailTime]=TimeForSjail[playerid]-tsjail;
			CheckJail(playerid);
			printf("%d %d %d\n",PlayerData[playerid][pJailTime],tsjail,tsjailPlusOne[playerid]);
		}
         }
This function get the remaining time.

Code:
JailTimeLeft(id,PlayerData[id][pJailTime],true);
JailTimer[id] = SetTimerEx("WaitTime",1000,true,"ii",id,PlayerData[id][pJailTime]);
When /jail is perform

Code:
forward WaitTime(playerid,time);
	public WaitTime(playerid,time)
	{
		JailTimeLeft(playerid,time,false);
	}
The call of JailTimeLeft every second for refresh time.

How to fix this timer problem?
pollo97 is offline   Reply With Quote
Old 15/05/2015, 08:14 PM   #2
Azula
Huge Clucker
 
Azula's Avatar
 
Join Date: Apr 2015
Location: *-*
Posts: 213
Reputation: 57
Default Re: Timer doesn't stop

JailTimer[id] = SetTimerEx("WaitTime",1000,true,"if",id,PlayerData[id][pJailTime]);
__________________
new FS


Azula is offline   Reply With Quote
Old 15/05/2015, 08:19 PM   #3
Joe Staff
High-roller
 
Join Date: Aug 2007
Posts: 2,593
Reputation: 379
Default Re: Timer doesn't stop

Try if jail time <= 0
Joe Staff is offline   Reply With Quote
Old 15/05/2015, 08:21 PM   #4
pollo97
Big Clucker
 
pollo97's Avatar
 
Join Date: Sep 2011
Location: Italy
Posts: 83
Reputation: 4
Default Re: Timer doesn't stop

Quote:
Originally Posted by Azula View Post
JailTimer[id] = SetTimerEx("WaitTime",1000,true,"if",id,PlayerData[id][pJailTime]);
Umm... Why i should set PlayerData[id][pJailTime] as a float? It is an integer
pollo97 is offline   Reply With Quote
Old 15/05/2015, 08:28 PM   #5
pollo97
Big Clucker
 
pollo97's Avatar
 
Join Date: Sep 2011
Location: Italy
Posts: 83
Reputation: 4
Default Re: Timer doesn't stop

Quote:
Originally Posted by Joe Staff View Post
Try if jail time <= 0
It doesn't work, the timer keep run also if the player disconnect from server.
But i kill timer when player disconnect too.
pollo97 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto UnJail timer doesn't stop after player leaves/gets kicked whilst in jail? Goldino Scripting Help 2 22/02/2013 04:01 PM
Auto Unjail timer doesn't stop after getting kicked. Goldino Scripting Help 3 20/02/2013 07:22 PM
Sound doesn't stop!! samtey Help Archive 1 02/08/2011 12:35 PM
Timer don't want to stop ;D Daslee Help Archive 4 28/08/2010 10:02 PM
Stop The Timer Ironboy500 Help Archive 6 18/11/2009 01:42 PM


All times are GMT. The time now is 04:33 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.