[FilterScript] Sonny's Ranking system [Based on Scores, Cash] + Extra: Ping
#1

Description:

This is my first filterscript, made especially for sa-mp forum users. Hopefully it will be useful ^^


Rank Names:
Code:
    if(GetPlayerScore(playerid) >= 0 && GetPlayerScore(playerid) < 100) format(player, sizeof(player), "Newbie");
    else if(GetPlayerScore(playerid) >= 100 && GetPlayerScore(playerid) < 500) format(player, sizeof(player), "Junior Player");
    else if(GetPlayerScore(playerid) >= 500 && GetPlayerScore(playerid) < 5000) format(player, sizeof(player), "Regular Player");
    else if(GetPlayerScore(playerid) >= 5000 && GetPlayerScore(playerid) < 10000) format(player, sizeof(player), "Senior Player");
    else if(GetPlayerScore(playerid) >= 10000 && GetPlayerScore(playerid) < 50000) format(player, sizeof(player), "Loyal Player");
    else if(GetPlayerScore(playerid) >= 50000 && GetPlayerScore(playerid) < 100000) format(player, sizeof(player), "Hero");
    else if(GetPlayerScore(playerid) >= 100000) format(player, sizeof(player), "Godlike");
Social Status:

< 1000000: Poor
> 1000000: Millionaire


Screenshot:




Download:

https://pastebin.com/5KN9dPXf


Credits:

* SA-MP
* SonnyGamer
Reply
#2

Wow every FS nowadays has the same two issues

- Global TextDraws used for per-player purposes
- No TD init when FS is loaded

Also you don't destroy textdraws on unload, and don't handle a gamemode restart.
Reply
#3

Quote:
Originally Posted by NaS
View Post
Wow every FS nowadays has the same two issues

- Global TextDraws used for per-player purposes
- No TD init when FS is loaded

Also you don't destroy textdraws on unload, and don't handle a gamemode restart.
1. Why I can't use global textdraws for per-player purposes?

2. I only forgot to add:

Code:
public OnPlayerDisconnect(playerid, reason)
{
    TextDrawHideForPlayer(playerid, PlayerranksTextdraw[playerid]);
	return 1;
}
3. I did not add destroy textdraw because I don't see reason why would owner of server reload this filterscript, even they can just put it in the main gamemode.


Otherwise I don't think that this fs has any issues, its tested 100%
Reply
#4

Quote:
Originally Posted by SonnyGamer
View Post
1. Why I can't use global textdraws for per-player purposes?

2. I only forgot to add:

Code:
public OnPlayerDisconnect(playerid, reason)
{
    TextDrawHideForPlayer(playerid, PlayerranksTextdraw[playerid]);
	return 1;
}
3. I did not add destroy textdraw because I don't see reason why would owner of server reload this filterscript, even they can just put it in the main gamemode.


Otherwise I don't think that this fs has any issues, its tested 100%
1. Because this uses 50% of the TD capacity for showing one thing to a player. It's a complete waste.

Player-TDs would use 1 of 256 (per-player) which is less than 0.5%.

2. You don't need to hide it on Disconnect. You need to destroy it. But if you change these to player-TDs, you don't need to destroy them since they are automatically destroyed when a player disconnects. But you still need to handle OnFilterScriptExit and a gamemode restart if you want it to survive a GMX.

3. Reloading this filterscript because you for example changed rank names or whatever would use another 1000 TDs, so 99% of TDs for no reason.
Reply
#5

I'd have used an array and looped through it. Learn to use the (fucking) arrays lol
Reply
#6

Oh I see,

I can easily update this fs like that. Thanks for advices


@Logic_

What you mean?
Reply
#7

This is barely a filterscript and more of a snippet; And use an array, all what you guys think is that arrays are for storing player data into the memory but you can use it for thousands of other purposes as well, same goes that thousands of you just use Streamer for objects whereas you forget the functionality it gives to make codes smaller, same goes with other plugins and tools already available..

PHP Code:
#define MAX_RANKS (3)
#define MAX_RANK_NAME (32)
enum e_RankingStructure {
        
e_RankingName[MAX_RANK_NAME],
        
e_RankingScore,
        
e_RankingColor
};
new const 
g_RankingStructure[MAX_RANKS][e_RankingStructure] {
        {
"Newbie"00xFFFFFFFF},
        {
"Wannabe"500xFF0000FF},
        {
"Scripter"1000x00FFFFFF}
};
Rank_GetPlayer(playerid) {
        
        new
                
score GetPlayerScore(playerid);
        for (new 
MAX_RANKS!= 0--) {
                if (
score >= g_RankingStructure[i][e_RankingScore])
                        return 
i;
        }
        return 
0;

PS: there might be minor mistakes in the code, written this on the browser just as an example.
Reply
#8

Good Work.. Keep it up..
Reply
#9

Don't use if else if just create an array or you'll get lost in numbers.

TDs aren't needed as this is a rank system, better focus on the core itself than the looks. You could of add a function to create unlockable abilities per rank or some sort of bonus that can be customized.

Use filterscripts only if you create something that is standalone, a rank system should be an include as it is associated with the game mode itself.
Reply
#10

@RajatAsthana thanks!

@Variable™, in the case if textdraws not needed you can use ScoreName(playerid), MoneyName(playerid) in your /stats command just like this:

Quote:

new playerranks[728];
format(playerranks, sizeof(playerranks), "{00FFFF}S{FFFFFF}cores: %d ({00FF00}%s{FFFFFF}) \n{00FFFF}C{FFFFFF}ash: %d ({00FF00}%s{FFFFFF})",GetPlayerScore(playerid), ScoreName(playerid), GetPlayerMoney(playerid), MoneyName(playerid));

Example:

Code:
CMD:myrank(playerid,params[])
{
new playerranks[728];
    format(playerranks, sizeof(playerranks), "{00FFFF}S{FFFFFF}cores: %d ({00FF00}%s{FFFFFF}) \n{00FFFF}C{FFFFFF}ash: %d ({00FF00}%s{FFFFFF})",GetPlayerScore(playerid), ScoreName(playerid), GetPlayerMoney(playerid), MoneyName(playerid));
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"My Rank",strz,"Close","");
return 1;
}
You can use boths functions anywhere,
I just used it for textdraws this time

Well anyways thanks for advices and comments
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)