SA-MP Forums Archive
Lil question - 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: Lil question (/showthread.php?tid=277387)



Lil question - Tanush123 - 17.08.2011

how can i make every 2 hours player gets a score?


Re: Lil question - KingTurtle - 17.08.2011

You can try to create player variables. You know what, I will try it for you


Add this at OnPlayerConnect(playerid)
pawn Код:
new hour, minute, second, starts[MAX_PLAYERS][3];
printf("2-hours score has started for %d. The time currently is %02d:%02d:%02d", hour, minute, second);
starts[playerid][0] = hour;
starts[playerid][1] = minute;
starts[playerid][2] = second;
Add this at OnPlayerUpdate
NOTE: If your server gets laggy, create a global timer with OnPlayerUpdateEx and set the time you want to update the player

pawn Код:
new hour, minute, second;
getTime(hour, minute, second));
if(hour == starts[playerid][0]+2 && minute == starts[playerid][1] && second = starts[playerid][2])
{
/* EXPLANATION FOR ABOVE
Since you want it only 2 hours. You don't need to edit the minutes or seconds because you want it once 2 hours
It just checks if the player since he connected is 2 hours long on the server
*/

    SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
    printf("Player %d has received an extra score for being online on the server for 2 hours. Time is %02d:%02d:%02d", getTime(hour, minute, second));
}
Add this at OnPlayerDisconnect
pawn Код:
starts[playerid][0] = 0;
starts[playerid][1] = 0;
starts[playerid][2] = 0;



Re: Lil question - Tanush123 - 17.08.2011

well actually im confused, i got this
pawn Код:
forward OnlineTimeUpdate(playerid);
public OnlineTimeUpdate(playerid)
{
    PlayerData[playerid][MinutesPlayed] ++;
    if(PlayerData[playerid][MinutesPlayed] == 60)
    {
        PlayerData[playerid][HoursPlayed] ++;
        PlayerData[playerid][MinutesPlayed] = 0;
    }
    return 1;
}
i just want that their score goes up to 1 every 2 hour like
2 hours = score 1
4hours = score 2


Re: Lil question - Tanush123 - 17.08.2011

please help me...


Re: Lil question - =WoR=Varth - 18.08.2011

Use https://sampwiki.blast.hk/wiki/SetTimerEx
pawn Код:
new Timer[MAX_PLAYERS]

public OnPlayerConnect(playerid)
{
    Timer[playerid] = SetTimerEx("OnlineTimeUpdate",216000000,1,"%d",playerid);
    return 1;
}

public OnPlayerDisconnect(playeridmreason)
{
    KillTimer(Timer[playerid]);
    return 1;
}

forward OnlineTimeUpdate(playerid);
public OnlineTimeUpdate(playerid)
{
    SetPlayerScore(playerid,GetPlayerScore(playerid)++);
    return 1;
}



Re: Lil question - Tanush123 - 18.08.2011

dude i just need help making the player get 1 score every 2 hours, i already got the timer


Re: Lil question - =WoR=Varth - 18.08.2011

Dude, you never said you already use timer.
Just use this "SetPlayerScore(playerid,GetPlayerScore(playerid)+ +);"


Re: Lil question - Tanush123 - 18.08.2011

but how can i make them get a score every 2 hours in game like when the hours are in 2 4 6 8 10


Re: Lil question - Pinguinn - 18.08.2011

Did you even tried it? Cause I am pretty sure what varthshenon posted should work
[And yes I do think it repeats the whole time until the player disconnects]