Giving Score each hour - 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)
+--- Thread: Giving Score each hour (
/showthread.php?tid=400198)
Giving Score each hour -
diego_p11 - 17.12.2012
I need help on this =P i want that when a player achieves 1 hour online, he gets 1 score point
Re: Giving Score each hour -
LarzI - 17.12.2012
Globally:
pawn Код:
new gOnlineTimer[ MAX_PLAYERS ];
//making a global variable to use later when killing the looping timer
OnPlayerConnect:
pawn Код:
gOnlineTimer[ playerid ] = SetTimerEx( "HourScoreIncome", 60*60*1000, true, "i", playerid );
//here we initialize the timer, and assigns the global variable as its ID. The timer will loop every 60*60*1000th millisecond, which is every hour.
OnPlayerDisconnect:
pawn Код:
KillTimer( gOnlineTimer[ playerid ] );
//killing the timer so that it won't run when the player disconnects
Anywhere:
pawn Код:
forward HourScoreIncome(playerid);
public HourScoreIncom(playerid)
return SetPlayerScore( playerid, GetPlayerScore( playerid ) + 1 );
//simply adding 1 to the player's current score (the timer function)
This should work.
Re: Giving Score each hour -
diego_p11 - 17.12.2012
but, how it will look already in pawn?
Re: Giving Score each hour -
Konstantinos - 17.12.2012
Quote:
Originally Posted by diego_p11
but, how it will look already in pawn?
|
He gave you instructions about how you can make it and where you should add the piece of code.
Don't wait for a finished code to just paste into your script.. try to add what LarzI said to where he said!