Change Score
#1

How do I Change score to how many minutes that a player has played for?
Reply
#2

You'll need a timer and a variable for player to count his online time and then you can just use the SetPlayerScore function.
Reply
#3

Do you know how to write it up?
Reply
#4

pawn Код:
/* this script isn't saving player's time, you can use dini/dudb or DJson or any other system to save player's time. */

forward myTimer();

new
    playerOnlineTime[MAX_PLAYERS];

public myTimer()
{
  foreach(Player, u)
  {
    playerOnlineTime[u]++;
    SetPlayerScore(u, floatround(playerOnlineTime[u] / 60));
  }
  return true;
}

/* under OnGameModeInit/OnFilterScriptInit*/
SetTimer("myTimer", 1000, true);

public OnPlayerDisconnect(playerid, reason)
{
  playerOnlineTime[playerid] = 0; // reset the time.
  return true;
}
You'll need ******'s foreach function or you could just use the normal loop.
Reply
#5

Correli btw can you tell me what the foreach does because i dont understand what ****** topic says...
Reply
#6

Quote:
Originally Posted by DarK TeaM PT
Correli btw can you tell me what the foreach does because i dont understand what ****** topic says...
If you look on the player's loop for an example: it loops only for the connected players which is more efficient.
Reply
#7

oh okay thanks
Reply
#8

You're welcome.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)