28.01.2011, 22:14
So today I am going to show you how to make counting system, backwards or forwards, w/e you want.
So, first we include a_samp
Then you should forward the timer
Then we need to make a timerid to kill the timer later, and a count:
Then we need to make the commands that activate the timers/counts:
Ok, after we made these three cmds, we need to make a public for the timer, which we forwarded before ^^:
GameTextForPlayer is used this way:
You can find styles here:
https://sampwiki.blast.hk/wiki/GameTextStyle
Ok now we got a working count of how many seconds we spent on the server! Congragulations!
So, first we include a_samp
pawn Code:
#include <a_samp>
pawn Code:
forward test(playerid);
pawn Code:
new timer;
new count = 0; // You may change this if you count backwards or w/e
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
//Command to start the count:
if(strcmp("/startcount", cmdtext, true, 11) == 0)
{
timer = SetTimerEx("test", 1000, 1, "d", playerid);
return 1;
}
//A command to stop the count:
if(strcmp("/stopcount", cmdtext, true, 10) == 0)
{
KillTimer(timer);
return 1;
}
//And a command to reset the count:
if(strcmp("/resetcount", cmdtext, true, 11) == 0)
{
count = 0;
return 1;
}
return 0;
}
pawn Code:
public test(playerid)
{
count++; //Use ++ for counting forwards, and -- for counting the seconds backwards
new string[24];
format(string, sizeof(string), "Seconds playing: %d", count); // Formatted the count
return GameTextForPlayer(playerid, string, 1000, 5);
}
pawn Code:
GameTextForPlayer(playerid, const string[], time, style)
https://sampwiki.blast.hk/wiki/GameTextStyle
Ok now we got a working count of how many seconds we spent on the server! Congragulations!