Scores for stunting
#1

Hi, i have searched through the forum for this and i cant find it
I know there is some code that converts stunts preformed into the player score, how is this done
Thanks
Cameron
Reply
#2

pawn Код:
//ontop of your script
new CashScoreOld;

//ongamemodeinit
SetTimer("ScoreUpdate", 9999, 1);

//anywhere
forward ScoreUpdate();
public ScoreUpdate()
{
    new CashScore;
    new name[MAX_PLAYER_NAME];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, name, sizeof(name));
            CashScore = GetPlayerMoney(i);
            SetPlayerScore(i, CashScore);
            if (CashScore > CashScoreOld)
            {
                CashScoreOld = CashScore;
            }
        }
    }
}
Reply
#3

WTF? why do you get the player name? Why do you use MAX_PLAYERS in your loop?

why do you bother making the oldcashscore variable?

Theres no real reason to do this or even use the CashScoreOld variable. I suggest doing this.

pawn Код:
//ongamemodeinit
SetTimer("ScoreUpdate", 10000, 1); //10000 is a nice round number. update every 10 seconds.

forward ScoreUpdate();
public ScoreUpdate()
{
  for(new i=0; i<=GetMaxPlayers(); i++)
  {
    if(IsPlayerConnected(i))
    {
      new CashScore = GetPlayerMoney(i);
      SetPlayerScore(i, CashScore);
    }
  }
}
That is MUCH better.
Reply
#4

Quote:
Originally Posted by Kinetic
WTF? why do you get the player name? Why do you use MAX_PLAYERS in your loop?

why do you bother making the oldcashscore variable?

Theres no real reason to do this or even use the CashScoreOld variable. I suggest doing this.

pawn Код:
//ongamemodeinit
SetTimer("ScoreUpdate", 10000, 1); //10000 is a nice round number. update every 10 seconds.

forward ScoreUpdate();
public ScoreUpdate()
{
  for(new i=0; i<=GetMaxPlayers(); i++)
  {
    if(IsPlayerConnected(i))
    {
      new CashScore = GetPlayerMoney(i);
      SetPlayerScore(i, CashScore);
    }
  }
}
That is MUCH better.
How does that detects if you were stunting?
Reply
#5

You get money from stunting, and it converts that money to a score.
Reply
#6

Quote:
Originally Posted by Kinetic
WTF? why do you get the player name? Why do you use MAX_PLAYERS in your loop?
I have it from the original lvdm gm, I was too lazy to delete the uneccesary stuff :

//format(string, sizeof(string), "$$$ %s is now in the lead $$$", name);
//SendClientMessageToAll(COLOR_YELLOW, string);

And it's better to spread timers to divide the cpu usage, so in my eyes it's better to use 9999 instead of 10000...
Reply
#7

Quote:
Originally Posted by watkijkje
Quote:
Originally Posted by Kinetic
WTF? why do you get the player name? Why do you use MAX_PLAYERS in your loop?
And it's better to spread timers to divide the cpu usage, so in my eyes it's better to use 9999 instead of 10000...
How does 9999 spread cpu usage any better than 10000? In fact if you use 9999 it calls the function 1 millisecond faster, meaning it happens more often than 10000. Therefore using more CPU than 10000.
Reply
#8

Quote:
Originally Posted by Kinetic
pawn Код:
for(new i=0; i<=GetMaxPlayers(); i++)
That is MUCH better.
Calling a function each itteration which returns a constant result is not better than using a define. MAX_PLAYERS is there for a reason so use it or atleast store the result of GetMaxPlayers() before hand then use the result in the loop as doing it your way is adding a ton of function calls which is slower not "MUCH better".
Reply
#9

Quote:
Originally Posted by Kinetic
How does 9999 spread cpu usage any better than 10000? In fact if you use 9999 it calls the function 1 millisecond faster, meaning it happens more often than 10000. Therefore using more CPU than 10000.
I can't explain it with my bad english, if you want to know it contact ******.
He made a topic about it.
Reply
#10

Quote:
Originally Posted by Kinetic
Quote:
Originally Posted by watkijkje
Quote:
Originally Posted by Kinetic
WTF? why do you get the player name? Why do you use MAX_PLAYERS in your loop?
And it's better to spread timers to divide the cpu usage, so in my eyes it's better to use 9999 instead of 10000...
How does 9999 spread cpu usage any better than 10000? In fact if you use 9999 it calls the function 1 millisecond faster, meaning it happens more often than 10000. Therefore using more CPU than 10000.
That would be necessary if he had more timers in his game mode. It is better to make a difference between your timers like 1000 first timer, than 1001 second one and here like he said 9999 this other timer. Than the server has this one mili second to loop thru players...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)