06.01.2011, 22:51
How To Make Score System With Timers
Introduction
I'll be showing u today how to make score system with timers....first we will be defining them then set the timers then set the publics to gain score and killtimers after u gain it
so it doesnt just reapet all over and i'll be making if player already have score < 2 ,, 2= number of timers scores u did so if u loged out and loged in just doesnt repeat
The Start
so first lets define our timers
pawn Code:
new ScoreTimer1[MAX_PLAYERS];
new ScoreTimer2[MAX_PLAYERS];
Scripting
so now we will set the timers
pawn Code:
ScoreTimer1[playerid] = SetTimerEx("AddScore1", 60000, true, "i", playerid);
ScoreTimer2[playerid] = SetTimerEx("AddScore2", 120000, true, "i", playerid);
1000 = 1second 1minute = 60000 1hr = 3,600,000 so if u want it by hours just multiply 3,600,000 x [number of hrs] to get u the number of hrs u want in milliseconds same with minutes 60000 x [number of mins]
So after ur done with setting ur timers now lets go to the part of gaining score and killtimer after the timer pass
and gaining the score ...
pawn Code:
forward AddScore1(playerid);
public AddScore1(playerid)
{
SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
new string[200];
format(string, sizeof(string, "~g~U're now level 1 Congratz");
GameTextForPlayer(playerid, string, 1000, 0);
KillTimer(ScoreTimer1[playerid]);
if(GetPlayerScore(playerid) < 2)
{
KillTimer(ScoreTimer1[playerid]);
}
return 1;
}
pawn Code:
forward AddScore2(playerid);
public AddScore2(playerid)
{
SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
new string[200];
format(string, sizeof(string, "~g~U're now level 2 Congratz");
GameTextForPlayer(playerid, string, 1000, 0);
KillTimer(ScoreTimer2[playerid]);
if(GetPlayerScore(playerid) < 2) // Change the < 2 of the numbers to the number of scoretimers u got
{
KillTimer(ScoreTimer2[playerid]);
}
return 1;
}
Summary
In This Tutorial we used timers and game texts
1st (First): we defined them
2nd (Second): we set the timers
3rd (Third): we set the publics for gaining scores and killtimers
Conclusion
Now if u stayed 1minute online on server u gonna be lvl 1 means +1 then 2minutes lvl2 +1 more so score2
So i was showing u ex: for 2 scoretimers u can just keep adding to the number of lvls u want
I Hope it was good tutorial if you got any errors i'll be glad to help post ur errors in a comment please
Ok Thanks For Reading my tutorial i hope it was usefull for ur server Don't worry if u got any errors just post it down here and i'll help
PS: If something u didnt understand in my explanation just post it and i'll explain it Bai!
Arshavin, Thanks bb..