How to make Elegant Rank System
#1

I want to make a rank system like this one



Can any one help me with filterscript or how to make it myself ?
Reply
#2

Anyhelp
Reply
#3

Textdraws and variables
Reply
#4

I'm going to assume that you have basic knowledge of the textdraw system.

Here is how I would approach creating a system like this:

* 1. You're going to need a textdraw editor. I suggest using Zamaroht's Textdraw editor, as it supports textdraw images (stars).
* 2. Create two textdraws. The first one being the stars.

* 3. Gather a certain sense of how you want the rank textdraw to look like, and create the second textdraw. This may be a little tricky, so I suggest that you, for starters, copy and paste the following:
"SCR: 0000 / 9999 \n K: 0000 / D: 0000".

Right now, I'm going to assume you do not know what \n does. In basic explanation, all it does is to skip to a new line.

* 4. Here comes the scripting part! I hope you're still with me thus far. You are going to want to create variables for the player. I'm not going to create a registration script for you, so you will have to do with the score, kills and deaths being reset upon disconnecting.

You're going to want to account for deaths, kills and score. Start by creating two variables, you will be using to account kills and deaths with.

pawn Код:
new
    Kills[MAX_PLAYERS],
    Deaths[MAX_PLAYERS];
There is no need to create a third variable, as you can simply go by using the native GetPlayerScore check.

You will now have to change these variables, in a callback. Seeing as these variables will change when a player is killed, the logical choice in this case, would be to pick the OnPlayerDeath callback. So go ahead and scroll down to the OnPlayerDeath callback.

pawn Код:
public OnPlayerDeath(playerid, reason, killerid)
{
    Kills[killerid] ++;
    Deaths[playerid] ++;
}
Now you have got your variables changing each time a player is killed, or kills.

Finally, the only thing you have to do now, is to convert the textdraw you created in the first place (not the stars, but the Kills and Deaths listing one), to an actual "string textdraw". That's not an official name, but you get the point. Hopefully.

To do this, you will have to use the TextDrawSetString(params) function.
https://sampwiki.blast.hk/wiki/TextDrawSetString

I suggest that you read that link before continuing.

pawn Код:
new
    string[20];

format(string, sizeof(string), "SCR: %i \n K: %i / D: %i", GetPlayerScore(playerid), Kills[playerid], Deaths[playerid]);
TextDrawSetString(whatever_text_draw_name_you_selected_in_the_beginning, string);
That should do the trick for you! all there is left for you to do now, is to hook these lines into the OnPlayerDeath callback, and there you go.

Let me know if you need any further help / explaining.
Reply
#5

I am using LuxAdmin FS for the login \ register system

it save all the needed info so there is a command i get the player kills and deathes through LuxAdmin or i do a file reader and read the player file ?
Reply
#6

I have absolutely no idea. Never before have I used LuxAdmin.
I'm guessing you will simply have to replace the variables which I created, with the ones in LuxAdmin.

Probably something like..
pawn Код:
new
    string[20];

format(string, sizeof(string), "SCR: %i \n K: %i / D: %i", GetPlayerScore(playerid), pInfo[playerid][Kills], pInfo[playerid][Deaths]);
TextDrawSetString(whatever_text_draw_name_you_selected_in_the_beginning, string);
You'll have to find the enumerator/variables yourself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)