24.02.2013, 20:36
This is my first tutorial, so please don't be so rude if you don't like it, and try and help me if something is wrong.
Alright, let's get started...
1.- At the top of your gamemode define a global variable, in wich we'll know the rank a player is..
2.- Here we'll create the textdraw variables.
Q: Why using MAX_PLAYERS?
A: it is because it will create a global array with one slot for every player, then the function will assign whatever is in the variable in this case the textdraw.
3.- In this step we'll be creating the textdraws.
Costep 3-1: Find the public OnGameModeInIt()
Costep 3-2
Q: What is this line for?
A: Well this line is becase as we have defined the array MAX_PLAYERS ([playerid]) and you can't use playerid in on OnGameModeInIt playerid is replaced with the array
.
4.- Creating the ranks.
Costep 4-1: Find the public OnPlayerSpawn(playerid)
Costep 4-2: Creating the ranks.
Q: Why hiding the rest of the textdraws?
A: It is because, if we create the rank only showing one textdraw the rest of the textdraws would be bugged as they'll show up later.
Example:
Player gets all the ranks by mistake, admin sets his score to 0. All the textdraws will be there as we are not hiding the textdraws.
Note: You could create the /ranks command with the score you're gonna use.
Here's a picture of how the ranks look like.
When the player is rank 0.
When the player is rank 5.
Tips: You can use zamaroht textdraw editor to create the textdraws https://sampforum.blast.hk/showthread.php?tid=290640Alright, let's get started...
1.- At the top of your gamemode define a global variable, in wich we'll know the rank a player is..
pawn Код:
new Rank[MAX_PLAYERS];
pawn Код:
new Text:Textdraw0[MAX_PLAYERS];
new Text:Textdraw1[MAX_PLAYERS];
new Text:Textdraw2[MAX_PLAYERS];
new Text:Textdraw3[MAX_PLAYERS];
new Text:Textdraw4[MAX_PLAYERS];
new Text:Textdraw5[MAX_PLAYERS];
new Text:R1[MAX_PLAYERS];
new Text:R2[MAX_PLAYERS];
new Text:R3[MAX_PLAYERS];
new Text:R4[MAX_PLAYERS];
new Text:R5[MAX_PLAYERS];
A: it is because it will create a global array with one slot for every player, then the function will assign whatever is in the variable in this case the textdraw.
3.- In this step we'll be creating the textdraws.
Costep 3-1: Find the public OnGameModeInIt()
pawn Код:
public OnGameModeInit() //In this public we'll be creating the textdraws.
{
return 1;
}
pawn Код:
public OnGameModeInIt()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
Textdraw0[i] = TextDrawCreate(503.000000, 102.000000, "]");
TextDrawBackgroundColor(Textdraw0[i], 255);
TextDrawFont(Textdraw0[i], 0);
TextDrawLetterSize(Textdraw0[i], 0.529999, 1.299999);
TextDrawColor(Textdraw0[i], 16777215);
TextDrawSetOutline(Textdraw0[i], 1);
TextDrawSetProportional(Textdraw0[i], 1);
TextDrawUseBox(Textdraw0[i], 1);
TextDrawBoxColor(Textdraw0[i], -1347440726);
TextDrawTextSize(Textdraw0[i], 605.000000, 0.000000);
Textdraw1[i] = TextDrawCreate(521.000000, 102.000000, "]");
TextDrawBackgroundColor(Textdraw1[i], 255);
TextDrawFont(Textdraw1[i], 0);
TextDrawLetterSize(Textdraw1[i], 0.509999, 1.300000);
TextDrawColor(Textdraw1[i], 16777215);
TextDrawSetOutline(Textdraw1[i], 1);
TextDrawSetProportional(Textdraw1[i], 1);
Textdraw2[i] = TextDrawCreate(538.000000, 102.000000, "]");
TextDrawBackgroundColor(Textdraw2[i], 255);
TextDrawFont(Textdraw2[i], 0);
TextDrawLetterSize(Textdraw2[i], 0.509999, 1.300000);
TextDrawColor(Textdraw2[i], 16777215);
TextDrawSetOutline(Textdraw2[i], 1);
TextDrawSetProportional(Textdraw2[i], 1);
Textdraw3[i] = TextDrawCreate(556.000000, 102.000000, "]");
TextDrawBackgroundColor(Textdraw3[i], 255);
TextDrawFont(Textdraw3[i], 0);
TextDrawLetterSize(Textdraw3[i], 0.509999, 1.300000);
TextDrawColor(Textdraw3[i], 16777215);
TextDrawSetOutline(Textdraw3[i], 1);
TextDrawSetProportional(Textdraw3[i], 1);
Textdraw4[i] = TextDrawCreate(575.000000, 102.000000, "]");
TextDrawBackgroundColor(Textdraw4[i], 255);
TextDrawFont(Textdraw4[i], 0);
TextDrawLetterSize(Textdraw4[i], 0.509999, 1.300000);
TextDrawColor(Textdraw4[i], 16777215);
TextDrawSetOutline(Textdraw4[i], 1);
TextDrawSetProportional(Textdraw4[i], 1);
Textdraw5[i] = TextDrawCreate(594.000000, 102.000000, "0");
TextDrawBackgroundColor(Textdraw5[i], 255);
TextDrawFont(Textdraw5[i], 3);
TextDrawLetterSize(Textdraw5[i], 0.509999, 1.300000);
TextDrawColor(Textdraw5[i], 16777215);
TextDrawSetOutline(Textdraw5[i], 1);
TextDrawSetProportional(Textdraw5[i], 1);
R1[i] = TextDrawCreate(594.000000, 102.000000, "1");
TextDrawBackgroundColor(R1[i], 255);
TextDrawFont(R1[i], 3);
TextDrawLetterSize(R1[i], 0.509999, 1.300000);
TextDrawColor(R1[i], 16777215);
TextDrawSetOutline(R1[i], 1);
TextDrawSetProportional(R1[i], 1);
R2[i] = TextDrawCreate(594.000000, 102.000000, "2");
TextDrawBackgroundColor(R2[i], 255);
TextDrawFont(R2[i], 3);
TextDrawLetterSize(R2[i], 0.509999, 1.300000);
TextDrawColor(R2[i], 16777215);
TextDrawSetOutline(R2[i], 1);
TextDrawSetProportional(R2[i], 1);
R3[i] = TextDrawCreate(594.000000, 102.000000, "3");
TextDrawBackgroundColor(R3[i], 255);
TextDrawFont(R3[i], 3);
TextDrawLetterSize(R3[i], 0.509999, 1.300000);
TextDrawColor(R3[i], 16777215);
TextDrawSetOutline(R3[i], 1);
TextDrawSetProportional(R3[i], 1);
R4[i] = TextDrawCreate(594.000000, 102.000000, "4");
TextDrawBackgroundColor(R4[i], 255);
TextDrawFont(R4[i], 3);
TextDrawLetterSize(R4[i], 0.509999, 1.300000);
TextDrawColor(R4[i], 16777215);
TextDrawSetOutline(R4[i], 1);
TextDrawSetProportional(R4[i], 1);
R5[i] = TextDrawCreate(594.000000, 102.000000, "5");
TextDrawBackgroundColor(R5[i], 255);
TextDrawFont(R5[i], 3);
TextDrawLetterSize(R5[i], 0.509999, 1.300000);
TextDrawColor(R5[i], 16777215);
TextDrawSetOutline(R5[i], 1);
TextDrawSetProportional(R5[i], 1);
}
return 1;
}
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
A: Well this line is becase as we have defined the array MAX_PLAYERS ([playerid]) and you can't use playerid in on OnGameModeInIt playerid is replaced with the array
pawn Код:
[i]
4.- Creating the ranks.
Costep 4-1: Find the public OnPlayerSpawn(playerid)
pawn Код:
public OnPlayerSpawn(playerid) //In this public we'll be creating the ranks + showing the textdraws.
{
return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
if(GetPlayerScore(playerid) <=0) // If the player's score is 0, then it will show him TextDraw 5.
{
TextDrawShowForPlayer(playerid, Textdraw5[playerid]); //Showing TD 5 defined in ongamemodeinit
TextDrawHideForPlayer(playerid, Textdraw0[playerid]);
TextDrawHideForPlayer(playerid, Textdraw1[playerid]);
TextDrawHideForPlayer(playerid, Textdraw2[playerid]);
TextDrawHideForPlayer(playerid, Textdraw3[playerid]);
TextDrawHideForPlayer(playerid, Textdraw4[playerid]);
TextDrawHideForPlayer(playerid, R1[playerid]);
TextDrawHideForPlayer(playerid, R2[playerid]);
TextDrawHideForPlayer(playerid, R3[playerid]);
TextDrawHideForPlayer(playerid, R4[playerid]);
TextDrawHideForPlayer(playerid, R5[playerid]);
SetPlayerHealth(playerid, 80);
SendClientMessage(playerid, Azul, " ");
SendClientMessage(playerid, Azul, "{FFFFFF}[ {33CCFF}* {FFFFFF}] You are rank {FFFFFF}({33CCFF}0{FFFFFF}) so you get {33CCFF}80 {FFFFFF}hp and {33CCFF}0 {FFFFFF}armour");
SendClientMessage(playerid, COLOR_GREY, "[ * ] Read /ranks for more information!");
SendClientMessage(playerid, Azul, " ");
Rank[playerid] = 0; //Here's the variable storing the player's rank this case = 0.
}
else if(GetPlayerScore(playerid) <=100) //note the else if.
{
TextDrawHideForPlayer(playerid, Textdraw5[playerid]);
TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
TextDrawHideForPlayer(playerid, Textdraw1[playerid]);
TextDrawHideForPlayer(playerid, Textdraw2[playerid]);
TextDrawHideForPlayer(playerid, Textdraw3[playerid]);
TextDrawHideForPlayer(playerid, Textdraw4[playerid]);
TextDrawShowForPlayer(playerid, R1[playerid]);
TextDrawHideForPlayer(playerid, R2[playerid]);
TextDrawHideForPlayer(playerid, R3[playerid]);
TextDrawHideForPlayer(playerid, R4[playerid]);
TextDrawHideForPlayer(playerid, R5[playerid]);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 10);
SendClientMessage(playerid, Azul, " ");
SendClientMessage(playerid, Azul, "{FFFFFF}[ {33CCFF}* {FFFFFF}] You are rank {FFFFFF}({33CCFF}1{FFFFFF}) so you get {33CCFF}100 {FFFFFF}hp and {33CCFF}10 {FFFFFF}armour");
SendClientMessage(playerid, COLOR_GREY, "[ * ] Read /ranks for more information!");
SendClientMessage(playerid, Azul, " ");
Rank[playerid] = 1;
}
else if(GetPlayerScore(playerid) <=150)
{
TextDrawHideForPlayer(playerid, Textdraw5[playerid]);
TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
TextDrawShowForPlayer(playerid, Textdraw1[playerid]);
TextDrawHideForPlayer(playerid, Textdraw2[playerid]);
TextDrawHideForPlayer(playerid, Textdraw3[playerid]);
TextDrawHideForPlayer(playerid, Textdraw4[playerid]);
TextDrawHideForPlayer(playerid, R1[playerid]);
TextDrawShowForPlayer(playerid, R2[playerid]);
TextDrawHideForPlayer(playerid, R3[playerid]);
TextDrawHideForPlayer(playerid, R4[playerid]);
TextDrawHideForPlayer(playerid, R5[playerid]);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 30);
SendClientMessage(playerid, Azul, " ");
SendClientMessage(playerid, Azul, "{FFFFFF}[ {33CCFF}* {FFFFFF}] You are rank {FFFFFF}({33CCFF}2{FFFFFF}) so you get {33CCFF}100 {FFFFFF}hp and {33CCFF}30 {FFFFFF}armour");
SendClientMessage(playerid, COLOR_GREY, "[ * ] Read /ranks for more information!");
SendClientMessage(playerid, Azul, " ");
Rank[playerid] = 2;
}
else if(GetPlayerScore(playerid) <=300)
{
TextDrawHideForPlayer(playerid, Textdraw5[playerid]);
TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
TextDrawShowForPlayer(playerid, Textdraw1[playerid]);
TextDrawShowForPlayer(playerid, Textdraw2[playerid]);
TextDrawHideForPlayer(playerid, Textdraw3[playerid]);
TextDrawHideForPlayer(playerid, Textdraw4[playerid]);
TextDrawHideForPlayer(playerid, R1[playerid]);
TextDrawHideForPlayer(playerid, R2[playerid]);
TextDrawShowForPlayer(playerid, R3[playerid]);
TextDrawHideForPlayer(playerid, R4[playerid]);
TextDrawHideForPlayer(playerid, R5[playerid]);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 50);
SendClientMessage(playerid, Azul, " ");
SendClientMessage(playerid, Azul, "{FFFFFF}[ {33CCFF}* {FFFFFF}] You are rank {FFFFFF}({33CCFF}3{FFFFFF}) so you get {33CCFF}100 {FFFFFF}hp and {33CCFF}50 {FFFFFF}armour");
SendClientMessage(playerid, COLOR_GREY, "[ * ] Read /ranks for more information!");
SendClientMessage(playerid, Azul, " ");
Rank[playerid] = 3;
}
else if(GetPlayerScore(playerid) <=750)
{
TextDrawHideForPlayer(playerid, Textdraw5[playerid]);
TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
TextDrawShowForPlayer(playerid, Textdraw1[playerid]);
TextDrawShowForPlayer(playerid, Textdraw2[playerid]);
TextDrawShowForPlayer(playerid, Textdraw3[playerid]);
TextDrawHideForPlayer(playerid, Textdraw4[playerid]);
TextDrawHideForPlayer(playerid, R1[playerid]);
TextDrawHideForPlayer(playerid, R2[playerid]);
TextDrawHideForPlayer(playerid, R3[playerid]);
TextDrawShowForPlayer(playerid, R4[playerid]);
TextDrawHideForPlayer(playerid, R5[playerid]);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 75);
SendClientMessage(playerid, Azul, " ");
SendClientMessage(playerid, Azul, "{FFFFFF}[ {33CCFF}* {FFFFFF}] You are rank {FFFFFF}({33CCFF}4{FFFFFF}) so you get {33CCFF}100 {FFFFFF}hp and {33CCFF}75 {FFFFFF}armour");
SendClientMessage(playerid, COLOR_GREY, "[ * ] Read /ranks for more information!");
SendClientMessage(playerid, Azul, " ");
Rank[playerid] = 4;
}
else if(GetPlayerScore(playerid) <=1000)
{
TextDrawHideForPlayer(playerid, Textdraw5[playerid]);
TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
TextDrawShowForPlayer(playerid, Textdraw1[playerid]);
TextDrawShowForPlayer(playerid, Textdraw2[playerid]);
TextDrawShowForPlayer(playerid, Textdraw3[playerid]);
TextDrawShowForPlayer(playerid, Textdraw4[playerid]);
TextDrawHideForPlayer(playerid, R1[playerid]);
TextDrawHideForPlayer(playerid, R2[playerid]);
TextDrawHideForPlayer(playerid, R3[playerid]);
TextDrawHideForPlayer(playerid, R4[playerid]);
TextDrawShowForPlayer(playerid, R5[playerid]);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, Azul, " ");
SendClientMessage(playerid, Azul, "{FFFFFF}[ {33CCFF}* {FFFFFF}] You are rank {FFFFFF}({33CCFF}1{FFFFFF}) so you get {33CCFF}100 {FFFFFF}hp and {33CCFF}100 {FFFFFF}armour");
SendClientMessage(playerid, COLOR_GREY, "[ * ] Read /ranks for more information!");
SendClientMessage(playerid, Azul, " ");
Rank[playerid] = 5;
}
return 1;
}
A: It is because, if we create the rank only showing one textdraw the rest of the textdraws would be bugged as they'll show up later.
Example:
Player gets all the ranks by mistake, admin sets his score to 0. All the textdraws will be there as we are not hiding the textdraws.
Note: You could create the /ranks command with the score you're gonna use.
Here's a picture of how the ranks look like.
When the player is rank 0.
When the player is rank 5.
Or iPLEOMAX Textdraw editor: https://sampforum.blast.hk/showthread.php?tid=376758