Help with script
#1

How i can make every hour to give to all players 100 score
Reply
#2

Use a timer that calls every hour, then use a for loop or foreach to increase their score by 100.

https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/SetPlayerScore
https://sampwiki.blast.hk/wiki/For
Reply
#3

pawn Код:
new ScoreTimer[MAX_PLAYERS];

ScoreTimer[playerid] = SetTimerEx("AddScore", 3600000, true, "i", playerid);//add the timer to OnPlayerConnect

forward AddScore(playerid);
public AddScore(playerid)
{
SetPlayerScore(playerid,GetPlayerScore(playerid)+100);
//adds +100 ever 1hr
}

/*when the player leave the server kill the timer !
Go on "OnPlayerDisconnect" adn add this */

KillTimer(ScoreTimer[playerid]);
edit
Post bellow is right it the timer need to grt killed after the player leaves no dies !
God knows what I was thinking
Reply
#4

@park4bmx

The correct code should look like this:

pawn Код:
new ScoreTimer[MAX_PLAYERS];
ScoreTimer[playerid] = SetTimerEx("AddScore", 3600000, true, "i", playerid);
forward AddScore(playerid);
public AddScore(playerid)
{
     SetPlayerScore(playerid,GetPlayerScore(playerid)+100)
}

//now add this under OnPlayerDISCONNECT, NOT OnPlayerDeath
KillTimer(ScoreTimer[playerid])
Why should you kill the timer when the player died? He'd still play, so you'll have to kill it when he leaves the server / disconnects!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)