SA-MP Forums Archive
SetPlayerScore With OnPlayerUpdate? - 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: SetPlayerScore With OnPlayerUpdate? (/showthread.php?tid=151743)



SetPlayerScore With OnPlayerUpdate? - Toni - 31.05.2010

I was just wondering For like every 1 minute they play, the earn 5 points, How would I do that? I just thought of using OnPlayerUpdate, but I have no clue how to make that work

any help please?


Re: SetPlayerScore With OnPlayerUpdate? - dice7 - 31.05.2010

Use a timer and loop through all players


Re: SetPlayerScore With OnPlayerUpdate? - Conroy - 31.05.2010

pawn Код:
forward ScoreUpdate();
pawn Код:
//OnGameModeInit
SetTimer("ScoreUpdate", 60000, true);
pawn Код:
public ScoreUpdate()
{
for(new i; i<MAX_PLAYERS; i++) {
if(IsPlayerConnected(i)) {
SetPlayerScore(i, GetPlayerScore(i)+5);
}
}
return 1;
}



Re: SetPlayerScore With OnPlayerUpdate? - Toni - 31.05.2010

Quote:
Originally Posted by dice7
Use a timer and loop through all players
Thanks Lets just hope I can figure out that.

EDIT:

Thanks Conroy.

EDIT AGAIN:

Thanks Joe Torran!


Re: SetPlayerScore With OnPlayerUpdate? - NewTorran - 31.05.2010

pawn Код:
forward ScoreUpdate(playerid);
new timer;

public OnPlayerConnect(playerid)
{
  timer = SetTimerEx("ScoreUpdate", 60*1000, 1, "i", playerid);
  return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
  KillTimer(timer);
  return 1;
}

public ScoreUpdate(playerid)
{
  SetPlayerScore(playerid, GetPlayerScore(playerid)+5);
  return 1;
}



Re: SetPlayerScore With OnPlayerUpdate? - Conroy - 31.05.2010

My way is much more easier.


Re: SetPlayerScore With OnPlayerUpdate? - NewTorran - 31.05.2010

Quote:
Originally Posted by Conroy
My way is much more easier.
He said for every minute they play, Not every minute the server is running


Re: SetPlayerScore With OnPlayerUpdate? - Conroy - 31.05.2010

Yes, it only gives score if the player is connected.


Re: SetPlayerScore With OnPlayerUpdate? - Toni - 31.05.2010

Quote:
Originally Posted by Joe Torran C
Quote:
Originally Posted by Conroy
My way is much more easier.
He said for every minute they play, Not every minute the server is running
Thats correct Joe