Sonny's Ranking system [Based on Scores, Cash] + Extra: Ping -
SonnyGamer - 28.03.2019
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
Re: Sonny's Ranking system [Based on Scores, Cash] + Extra: Ping -
NaS - 28.03.2019
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.
Re: Sonny's Ranking system [Based on Scores, Cash] + Extra: Ping -
SonnyGamer - 28.03.2019
Quote:
Originally Posted by NaS
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%
Re: Sonny's Ranking system [Based on Scores, Cash] + Extra: Ping -
NaS - 28.03.2019
Quote:
Originally Posted by SonnyGamer
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.
Re: Sonny's Ranking system [Based on Scores, Cash] + Extra: Ping -
Logic_ - 28.03.2019
I'd have used an array and looped through it. Learn to use the (fucking) arrays lol
Re: Sonny's Ranking system [Based on Scores, Cash] + Extra: Ping -
SonnyGamer - 28.03.2019
Oh I see,
I can easily update this fs like that. Thanks for advices
@Logic_
What you mean?
Re: Sonny's Ranking system [Based on Scores, Cash] + Extra: Ping -
Logic_ - 28.03.2019
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", 0, 0xFFFFFFFF},
{"Wannabe", 50, 0xFF0000FF},
{"Scripter", 100, 0x00FFFFFF}
};
Rank_GetPlayer(playerid) {
new
score = GetPlayerScore(playerid);
for (new i = MAX_RANKS; i != 0; i --) {
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.
Re: Sonny's Ranking system [Based on Scores, Cash] + Extra: Ping -
RajatAsthana - 28.03.2019
Good Work.. Keep it up..
Re: Sonny's Ranking system [Based on Scores, Cash] + Extra: Ping -
Variable™ - 28.03.2019
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.
Re: Sonny's Ranking system [Based on Scores, Cash] + Extra: Ping -
SonnyGamer - 28.03.2019
@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