SA-MP Forums Archive
Change Score - 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: Change Score (/showthread.php?tid=129345)



Change Score - Biggs - 21.02.2010

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


Re: Change Score - Correlli - 21.02.2010

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


Re: Change Score - Biggs - 21.02.2010

Do you know how to write it up?


Re: Change Score - Correlli - 21.02.2010

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.


Re: Change Score - SlashPT - 21.02.2010

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


Re: Change Score - Correlli - 21.02.2010

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.


Re: Change Score - SlashPT - 21.02.2010

oh okay thanks


Re: Change Score - Correlli - 21.02.2010

You're welcome.