SA-MP Forums Archive
Help with timer ! - 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: Help with timer ! (/showthread.php?tid=249135)



Help with timer ! - Gotti_ - 17.04.2011

I have a simple timer for adding score:

Код:
ScoreTimer1[playerid] = SetTimerEx("AddScore1", 60000, true, "i", playerid);
but its ok for 10-15 minutes and after that, it adding 2-3 score in every 15-20 seconds, anyone know how to fix it ?


Re: Help with timer ! - iJumbo - 17.04.2011

Prob its a variable problem or some in your script ... show the AddScore1 public


Re: Help with timer ! - Stigg - 17.04.2011

Where are you setting the timer ?
And whats it calling ?


Re: Help with timer ! - Gotti_ - 17.04.2011

Addscore1 + SetPlayerScoreEx

Quote:

forward AddScore1(playerid);
public AddScore1(playerid)
{
SetPlayerScoreEx(playerid, GetPlayerScore(playerid)+1);
return 1;
}

forward SetPlayerScoreEx(playerid,score);
public SetPlayerScoreEx(playerid,score)
{
new string[128];
Account[playerid][Score] = score;
SetPlayerScore(playerid,score);
if(score < 10) format(string,sizeof(string),"S0000000%d",score);
else if(score < 100 && score > 9) format(string,sizeof(string),"S000000%d",score);
else if(score < 1000 && score > 99) format(string,sizeof(string),"S00000%d",score);
else if(score < 10000 && score > 999) format(string,sizeof(string),"S0000%d",score);
else if(score < 100000 && score > 9999) format(string,sizeof(string),"S0000%d",score);
else if(score < 1000000 && score > 99999) format(string,sizeof(string),"S000%d",score);
else if(score < 10000000 && score > 999999) format(string,sizeof(string),"S00%d",score);
else if(score < 100000000 && score > 9999999) format(string,sizeof(string),"S0%d",score);
else if(score < 1000000000 && score > 99999999) format(string,sizeof(string),"S%d",score);
TextDrawSetString(TextScore[playerid],string);
}




Re: Help with timer ! - Stigg - 17.04.2011

Quote:
Originally Posted by Gotti_
Посмотреть сообщение
Addscore1 + SetPlayerScoreEx
Where are you setting the timer ?


Re: Help with timer ! - Gotti_ - 17.04.2011

public OnPlayerConnect( playerid )
{

ScoreTimer1[playerid] = SetTimerEx("AddScore1", 60000, true, "i", playerid);


Re: Help with timer ! - Stigg - 17.04.2011

Quote:
Originally Posted by Gotti_
Посмотреть сообщение
public OnPlayerConnect( playerid )
{

ScoreTimer1[playerid] = SetTimerEx("AddScore1", 60000, true, "i", playerid);
Try:

pawn Код:
SetPlayerScoreEx(playerid, GetPlayerScore(playerid)++);
And where are you killing your timer ?


Re: Help with timer ! - Gotti_ - 17.04.2011

im not killing it


Re: Help with timer ! - Stigg - 17.04.2011

Quote:
Originally Posted by Gotti_
Посмотреть сообщение
im not killing it
You need to kill it when the player disconnects. Otherwise it will keep running. When the player re-connects it will start another.
Hence your score will go up by 2 or more.

https://sampwiki.blast.hk/wiki/KillTimer


Re: Help with timer ! - iJumbo - 17.04.2011

You have to kill when player disconnect ..


EDIT: Fail post xD sorry