SA-MP Forums Archive
[FilterScript] [FS]OnPlayerUpdate Score to Money [0.3 and 0.2X compatible] - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] [FS]OnPlayerUpdate Score to Money [0.3 and 0.2X compatible] (/showthread.php?tid=95816)



[FS]OnPlayerUpdate Score to Money [0.3 and 0.2X compatible] - AiVAMAN - 05.09.2009

Simple OnPlayerUpdate Score to Money by Alive.
Description:
When showing scoreboard (TAB) where is score shows your money. Hope you understood me.

Bugs:
Haven't found any. If you do reply here.

Download:
Failai.lt

Mirrors are NOT allowed
Cheers,
-Alive


Re: [FS]OnPlayerUpdate Score to Money [0.3 and 0.2X compatible] - Andom - 05.09.2009

What the FUCK are you doing? are you trying to ruine or server or something?

Quote:

public OnPlayerUpdate(playerid)
{
new CashScore;
new CashScoreOld;

for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
CashScore = GetPlayerMoney(i);
SetPlayerScore(i, CashScore);
if(CashScore > CashScoreOld)
{
CashScoreOld = CashScore;
}
}
}
return 1;
}

OnPlayerUpdate get's called every like 20-30 times a second for each player.
So that like if you've 500 players (for 0.3): 500x20 = 100.000 x 500 (for the loop) = 50.000.000 times.

This function is calles 50.000.000 times each 1 second if your server is full....


Re: [FS]OnPlayerUpdate Score to Money [0.3 and 0.2X compatible] - CracK - 05.09.2009

By the way loop is not needed here.


Re: [FS]OnPlayerUpdate Score to Money [0.3 and 0.2X compatible] - AiVAMAN - 05.09.2009

Say me 5 things why I cant make it OnPlayerUpdate?
and thanks CracK, will make it better in next ver. :P


Re: [FS]OnPlayerUpdate Score to Money [0.3 and 0.2X compatible] - Jakku - 05.09.2009

I just wanna laugh for you script.


Re: [FS]OnPlayerUpdate Score to Money [0.3 and 0.2X compatible] - [eLg]Timmy - 05.09.2009

Quote:
Originally Posted by Jakku
I just wanna laugh for you script.
Why laugh, I don't laugh about your script (stolen FS and claimed as your own) either?


Re: [FS]OnPlayerUpdate Score to Money [0.3 and 0.2X compatible] - darkrider366 - 05.09.2009

Are you trying to Kill somones server?
you cant put this on OnPlayerUpdate...... just make it a public and make a timer which does it every 1 minute or so. Also
Because its looping 50,000,000 times each second you're going to use soo much CPU and bandwidth,
Make a timer, every 1 minute because every second is STUPID.


Re: [FS]OnPlayerUpdate Score to Money [0.3 and 0.2X compatible] - gijsmin - 05.09.2009

Common guys do normal to this guy
maby he is not good at Pawn scripting just help him
I don't know what script this is but try this:



Re: [FS]OnPlayerUpdate Score to Money [0.3 and 0.2X compatible] - Frankylez - 05.09.2009

pawn Код:
public OnPlayerUpdate(playerid)
{
  ResetPlayerMoney(playerid);
  GivePlayerMoney(playerid, GetPlayerScore(playerid));
}
I figure that this script would start causing trouble if you had like ~100 players.

Actually, why not make it check for a change?
pawn Код:
new pOldScore[MAX_PLAYERS],
  pNewScore[MAX_PLAYERS];

public OnPlayerUpdate(playerid)
{
  pNewScore[playerid] = GetPlayerScore(playerid);
  if(pNewScore[playerid] != pOldScore[playerid])
  {
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, pNewScore[playerid]);
  }
}
Or make it execute only if a certain amount of ticks is counted:
pawn Код:
new playerScoreTick[MAX_PLAYERS];
public OnPlayerUpdate(playerid)
{
  if(playerScoreTick[playerid] == 100)
  {
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, GetPlayerScore(playerid));
    playerScoreTick[playerid] = 0;
  }
  else
  {
    playerScoreTick[playerid] = playerScoreTick[playerid] + 1;
  }
}
Or the BEST way to make your score transfer into your amount of money or otherwise is to actually change the score/money when you change the money/score. You know what I mean, this would require no usage of OnPlayerUpdate, just make your:
pawn Код:
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
into
pawn Код:
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
GivePlayerMoney(playerid, GetPlayerScore(playerid));



Re: [FS]OnPlayerUpdate Score to Money [0.3 and 0.2X compatible] - Luka P. - 24.10.2009

You could make timer for every player
pawn Код:
forward ScoreUpdate(playerid);
pawn Код:
public OnPlayerConnect(playerid)
{
    SetTimerEx("ScoreUpdate",60000,0,"i",playerid);
    return 1;
}
pawn Код:
public ScoreUpdate(playerid)
{
    SetPlayerScore(playerid,GetPlayerMoney(playerid));
    SetTimerEx("ScoreUpdate",60000,0,"i",playerid);
    return 1;
}