Scores for stunting -
CAMERON_BANFIELD - 23.03.2009
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
Re: Scores for stunting -
watkijkje - 23.03.2009
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;
}
}
}
}
Re: Scores for stunting -
Kinetic - 23.03.2009
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.
Re: Scores for stunting -
Dujma - 23.03.2009
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?
Re: Scores for stunting -
Kinetic - 23.03.2009
You get money from stunting, and it converts that money to a score.
Re: Scores for stunting -
watkijkje - 23.03.2009
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
![afro](images/smilies/mrgreen.gif)
:
//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...
Re: Scores for stunting -
Kinetic - 23.03.2009
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.
Re: Scores for stunting -
Donny_k - 23.03.2009
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".
Re: Scores for stunting -
watkijkje - 23.03.2009
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.
Re: Scores for stunting -
Dujma - 23.03.2009
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...