Lil question
#1

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

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;
Reply
#3

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
Reply
#4

please help me...
Reply
#5

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;
}
Reply
#6

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

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

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
Reply
#9

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]
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)