PDA

View Full Version : Rank System


JaKe Elite
22/03/2015, 12:46 AM
I have been scripting a War Server (TDM) for the past few days for a community & myself.
Now i have been receiving problems on the Rank System, i thought it was working perfectly until i have come to think of it playing around with scores, I did some adjustment and it still didn't work. It works, but the Rank Up name shows wrong information for example, If i set score to 18000 (Which is Colonel) and i am currently in Corporal Rank, The message will tell me that i have been promoted to Sergeant instead of Colonel.

Can someone help me with this?


stock GetRank(playerid)
{
new rank[100];
switch(pInfo[playerid][Rank])
{
case 0: rank = "Trainee";
case 1: rank = "Private";
case 2: rank = "Corporal";
case 3: rank = "Sergeant";
case 4: rank = "Staff Sgt.";
case 5: rank = "Master Sgt.";
case 6: rank = "Sgt. Major";
case 7: rank = "Officer";
case 8: rank = "II.Lieutenant";
case 9: rank = "I.Lieutenant";
case 10: rank = "Captain";
case 11: rank = "Major";
case 12: rank = "Lt.Colonel";
case 13: rank = "Colonel";
}
return rank;
}

stock RankUp(playerid)
{
new string[128];

if(GetPlayerScore(playerid) >= 50 && pInfo[playerid][Rank] < 1)
{
pInfo[playerid][Rank] = 1;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a 10 score+, 5000$ and an armoury.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 10);
GivePlayerMoney(playerid, 5000);
SetPlayerArmour(playerid, 100);
}
else if(GetPlayerScore(playerid) >= 150 && pInfo[playerid][Rank] < 2)
{
pInfo[playerid][Rank] = 2;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a 5 score+, 3500$ and a M4 package.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
GivePlayerMoney(playerid, 3500);
GivePlayerWeapon(playerid, 31, 1000);
}
else if(GetPlayerScore(playerid) >= 300 && pInfo[playerid][Rank] < 3)
{
pInfo[playerid][Rank] = 3;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 30+.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 30);
}
else if(GetPlayerScore(playerid) >= 600 && pInfo[playerid][Rank] < 4)
{
pInfo[playerid][Rank] = 4;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a cash of $30,000 and a score boost of 20.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 20);
GivePlayerMoney(playerid, 30000);
}
else if(GetPlayerScore(playerid) >= 900 && pInfo[playerid][Rank] < 5)
{
pInfo[playerid][Rank] = 5;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 30+.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 30);
}
else if(GetPlayerScore(playerid) >= 1500 && pInfo[playerid][Rank] < 6)
{
pInfo[playerid][Rank] = 6;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 20+, $10000 - A weapon package (Set A).", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 20);
GivePlayerMoney(playerid, 10000);

GivePlayerWeapon(playerid, 31, 1000);
GivePlayerWeapon(playerid, 29, 1000);
}
else if(GetPlayerScore(playerid) >= 2500 && pInfo[playerid][Rank] < 7)
{
pInfo[playerid][Rank] = 7;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a cash of $5000.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

GivePlayerMoney(playerid, 5000);
}
else if(GetPlayerScore(playerid) >= 4500 && pInfo[playerid][Rank] < 8)
{
pInfo[playerid][Rank] = 8;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a weapon package (Set B).", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

GivePlayerWeapon(playerid, 30, 1000);
GivePlayerWeapon(playerid, 32, 1000);
}
else if(GetPlayerScore(playerid) >= 6000 && pInfo[playerid][Rank] < 9)
{
pInfo[playerid][Rank] = 9;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received nothing.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);
}
else if(GetPlayerScore(playerid) >= 7500 && pInfo[playerid][Rank] < 10)
{
pInfo[playerid][Rank] = 10;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 350.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 350);
}
else if(GetPlayerScore(playerid) >= 10000 && pInfo[playerid][Rank] < 11)
{
pInfo[playerid][Rank] = 11;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a cash of $50,000 + boosting score of 250.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 250);
GivePlayerMoney(playerid, 50000);
}
else if(GetPlayerScore(playerid) >= 13500 && pInfo[playerid][Rank] < 12)
{
pInfo[playerid][Rank] = 12;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 1000.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 1000);
}
else if(GetPlayerScore(playerid) >= 17000 && pInfo[playerid][Rank] < 13)
{
pInfo[playerid][Rank] = 13;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a cash of $2,500,000", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

GivePlayerMoney(playerid, 2500000);
}
Update3DTextLabelText(Label[playerid], GetPlayerColor(playerid), GetRank(playerid));
}


Help would be appreciated.

iPrivate
22/03/2015, 01:25 AM
stock RankUp(playerid)
{
new string[128];

if(GetPlayerScore(playerid) >= 50 && GetPlayerScore(playerid) < 150)
{
pInfo[playerid][Rank] = 1;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a 10 score+, 5000$ and an armoury.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 10);
GivePlayerMoney(playerid, 5000);
SetPlayerArmour(playerid, 100);
}
else if(GetPlayerScore(playerid) >= 150 && GetPlayerScore(playerid) < 300)
{
pInfo[playerid][Rank] = 2;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a 5 score+, 3500$ and a M4 package.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
GivePlayerMoney(playerid, 3500);
GivePlayerWeapon(playerid, 31, 1000);
}
else if(GetPlayerScore(playerid) >= 300 && GetPlayerScore(playerid) < 600)
{
pInfo[playerid][Rank] = 3;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 30+.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 30);
}
else if(GetPlayerScore(playerid) >= 600 && GetPlayerScore(playerid) < 900)
{
pInfo[playerid][Rank] = 4;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a cash of $30,000 and a score boost of 20.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 20);
GivePlayerMoney(playerid, 30000);
}
else if(GetPlayerScore(playerid) >= 900 && GetPlayerScore(playerid) < 1500)
{
pInfo[playerid][Rank] = 5;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 30+.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 30);
}
else if(GetPlayerScore(playerid) >= 1500 && GetPlayerScore(playerid) < 2500)
{
pInfo[playerid][Rank] = 6;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 20+, $10000 - A weapon package (Set A).", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 20);
GivePlayerMoney(playerid, 10000);

GivePlayerWeapon(playerid, 31, 1000);
GivePlayerWeapon(playerid, 29, 1000);
}
else if(GetPlayerScore(playerid) >= 2500 && GetPlayerScore(playerid) < 4500)
{
pInfo[playerid][Rank] = 7;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a cash of $5000.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

GivePlayerMoney(playerid, 5000);
}
else if(GetPlayerScore(playerid) >= 4500 && GetPlayerScore(playerid) < 6000)
{
pInfo[playerid][Rank] = 8;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a weapon package (Set B).", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

GivePlayerWeapon(playerid, 30, 1000);
GivePlayerWeapon(playerid, 32, 1000);
}
else if(GetPlayerScore(playerid) >= 6000 && GetPlayerScore(playerid) < 7500)
{
pInfo[playerid][Rank] = 9;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received nothing.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);
}
else if(GetPlayerScore(playerid) >= 7500 && GetPlayerScore(playerid) < 10000)
{
pInfo[playerid][Rank] = 10;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 350.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 350);
}
else if(GetPlayerScore(playerid) >= 10000 && GetPlayerScore(playerid) < 13500)
{
pInfo[playerid][Rank] = 11;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a cash of $50,000 + boosting score of 250.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 250);
GivePlayerMoney(playerid, 50000);
}
else if(GetPlayerScore(playerid) >= 13500 && GetPlayerScore(playerid) < 17000)
{
pInfo[playerid][Rank] = 12;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 1000.", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

SetPlayerScore(playerid, GetPlayerScore(playerid) + 1000);
}
else if(GetPlayerScore(playerid) >= 17000)
{
pInfo[playerid][Rank] = 13;

format(string, sizeof(string), "You have rank up to %s (%d) - Congratulations, You received a cash of $2,500,000", GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessage(playerid, COLOR_LIME, string);
format(string, sizeof(string), "* %s has ranked up to %s (%d).", nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
SendClientMessageToAll(COLOR_YELLOW, string);

GivePlayerMoney(playerid, 2500000);
}
Update3DTextLabelText(Label[playerid], GetPlayerColor(playerid), GetRank(playerid));
}

I don't know if this will help but give it a try.

Good luck. - Respond after testing

Jefff
22/03/2015, 01:27 AM
You need set rank too

JaKe Elite
22/03/2015, 01:58 AM
I did that Jefff if you will check the code.

@ iPrivate - Sure, hold on, testing it.

EDIT:

It is working, However if i set score back to 50 (from 18000) i will get a Private rank back.

Well doesn't matter, i believe i can fix this issue by myself, Thank you for helping me out.

fuckingcruse
22/03/2015, 06:11 AM
Nice cool code dude