[Help] How can i make playing hours = level
#1

How can i make that it saves the playing hours and puts every hour +1 level


If i played 1h my score on tab should show 1 ?
Reply
#2

Do you know how to work with timers?
Click here!
Reply
#3

pawn Код:
//under OnGameModeInit
SetTimer("gScore",3600000,1);

//Anywhere (out of any callback)
forward gScore();
public gScore()
{
     foreach(Player,i)
     {
          SetPlayerScore(i,GetPlayerScore(i)+1);
     }
     return 1;
}
Uses foreach - https://sampforum.blast.hk/showthread.php?tid=92679

Then, you could use Y_INI to save the players data.
https://sampforum.blast.hk/showthread.php?tid=175565
Reply
#4

Quote:
Originally Posted by [MWR]Blood
Посмотреть сообщение
pawn Код:
//under OnGameModeInit
SetTimer("gScore",3600000,1);

//Anywhere (out of any callback)
forward gScore();
public gScore()
{
     foreach(Player,i)
     {
          SetPlayerScore(i,GetPlayerScore(i)+1);
     }
     return 1;
}
Uses foreach - https://sampforum.blast.hk/showthread.php?tid=92679

Then, you could use Y_INI to save the players data.
https://sampforum.blast.hk/showthread.php?tid=175565
As well, he should save every minute so that the player does not need to play 1 hour at once too reach level 1.
Reply
#5

Quote:
Originally Posted by [MWR]Blood
Посмотреть сообщение
pawn Код:
//under OnGameModeInit
SetTimer("gScore",3600000,1);

//Anywhere (out of any callback)
forward gScore();
public gScore()
{
     foreach(Player,i)
     {
          SetPlayerScore(i,GetPlayerScore(i)+1);
     }
     return 1;
}
Uses foreach - https://sampforum.blast.hk/showthread.php?tid=92679

Then, you could use Y_INI to save the players data.
https://sampforum.blast.hk/showthread.php?tid=175565
Thanks !! yes im using forearch and Y_Ini but like Cameltoe said i need this too

" As well, he should save every minute so that the player does not need to play 1 hour at once too reach level 1. "
Reply
#6

Quote:
Originally Posted by Jimbo01
Посмотреть сообщение
Thanks !! yes im using forearch and Y_Ini but like Cameltoe said i need this too

" As well, he should save every minute so that the player does not need to play 1 hour at once too reach level 1. "
pawn Код:
new ScoreTimer[MAX_PLAYERS];
new PlayerScore[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    ScoreTimer[playerid] = SetTimerEx("ScoreAdd", 1000 * 60, true, "i", playerid);
    return 1;
}

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

forward ScoreAdd(playerid);
public ScoreAdd(playerid)
{
    PlayerScore[playerid]++;
    SetPlayerScore(playerid, floatround(PlayerScore[playerid], floatround_floor));
}
Reply
#7

this dont sets every 1h = 1 score ^^ its 60sec i think ?
Reply
#8

Quote:
Originally Posted by Jimbo01
Посмотреть сообщение
this dont sets every 1h = 1 score ^^ its 60sec i think ?
Yes, 60 * 1000 = 60,000 MS. 60,000 MS = 60 seconds = 1 Min.

so :

pawn Код:
SetPlayerScore(playerid, ( floatround(PlayerScore[playerid], floatround_floor) / 60 ));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)