Rank System
#1

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?

PHP код:
stock GetRank(playerid)
{
    new 
rank[100];
    switch(
pInfo[playerid][Rank])
    {
        case 
0rank "Trainee";
        case 
1rank "Private";
        case 
2rank "Corporal";
        case 
3rank "Sergeant";
        case 
4rank "Staff Sgt.";
        case 
5rank "Master Sgt.";
        case 
6rank "Sgt. Major";
        case 
7rank "Officer";
        case 
8rank "II.Lieutenant";
        case 
9rank "I.Lieutenant";
        case 
10rank "Captain";
        case 
11rank "Major";
        case 
12rank "Lt.Colonel";
        case 
13rank "Colonel";
    }
    return 
rank;
}
stock RankUp(playerid)
{
    new 
string[128];
    if(
GetPlayerScore(playerid) >= 50 && pInfo[playerid][Rank] < 1)
    {
        
pInfo[playerid][Rank] = 1;
        
        
format(stringsizeof(string), "You have rank up to %s (%d) - Congratulations, You received a 10 score+, 5000$ and an armoury."GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessage(playeridCOLOR_LIMEstring);
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessageToAll(COLOR_YELLOWstring);
        
        
SetPlayerScore(playeridGetPlayerScore(playerid) + 10);
        
GivePlayerMoney(playerid5000);
        
SetPlayerArmour(playerid100);
    }
    else if(
GetPlayerScore(playerid) >= 150 && pInfo[playerid][Rank] < 2)
    {
        
pInfo[playerid][Rank] = 2;
        
format(stringsizeof(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(playeridCOLOR_LIMEstring);
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessageToAll(COLOR_YELLOWstring);
        
SetPlayerScore(playeridGetPlayerScore(playerid) + 5);
        
GivePlayerMoney(playerid3500);
        
GivePlayerWeapon(playerid311000);
    }
    else if(
GetPlayerScore(playerid) >= 300 && pInfo[playerid][Rank] < 3)
    {
        
pInfo[playerid][Rank] = 3;
        
format(stringsizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 30+."GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessage(playeridCOLOR_LIMEstring);
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessageToAll(COLOR_YELLOWstring);
        
SetPlayerScore(playeridGetPlayerScore(playerid) + 30);
    }
    else if(
GetPlayerScore(playerid) >= 600 && pInfo[playerid][Rank] < 4)
    {
        
pInfo[playerid][Rank] = 4;
        
format(stringsizeof(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(playeridCOLOR_LIMEstring);
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessageToAll(COLOR_YELLOWstring);
        
SetPlayerScore(playeridGetPlayerScore(playerid) + 20);
        
GivePlayerMoney(playerid30000);
    }
    else if(
GetPlayerScore(playerid) >= 900 && pInfo[playerid][Rank] < 5)
    {
        
pInfo[playerid][Rank] = 5;
        
format(stringsizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 30+."GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessage(playeridCOLOR_LIMEstring);
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessageToAll(COLOR_YELLOWstring);
        
SetPlayerScore(playeridGetPlayerScore(playerid) + 30);
    }
    else if(
GetPlayerScore(playerid) >= 1500 && pInfo[playerid][Rank] < 6)
    {
        
pInfo[playerid][Rank] = 6;
        
format(stringsizeof(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(playeridCOLOR_LIMEstring);
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessageToAll(COLOR_YELLOWstring);
        
SetPlayerScore(playeridGetPlayerScore(playerid) + 20);
        
GivePlayerMoney(playerid10000);
        
GivePlayerWeapon(playerid311000);
        
GivePlayerWeapon(playerid291000);
    }
    else if(
GetPlayerScore(playerid) >= 2500 && pInfo[playerid][Rank] < 7)
    {
        
pInfo[playerid][Rank] = 7;
        
format(stringsizeof(string), "You have rank up to %s (%d) - Congratulations, You received a cash of $5000."GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessage(playeridCOLOR_LIMEstring);
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessageToAll(COLOR_YELLOWstring);
        
GivePlayerMoney(playerid5000);
    }
    else if(
GetPlayerScore(playerid) >= 4500 && pInfo[playerid][Rank] < 8)
    {
        
pInfo[playerid][Rank] = 8;
        
format(stringsizeof(string), "You have rank up to %s (%d) - Congratulations, You received a weapon package (Set B)."GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessage(playeridCOLOR_LIMEstring);
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessageToAll(COLOR_YELLOWstring);
        
GivePlayerWeapon(playerid301000);
        
GivePlayerWeapon(playerid321000);
    }
    else if(
GetPlayerScore(playerid) >= 6000 && pInfo[playerid][Rank] < 9)
    {
        
pInfo[playerid][Rank] = 9;
        
format(stringsizeof(string), "You have rank up to %s (%d) - Congratulations, You received nothing."GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessage(playeridCOLOR_LIMEstring);
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessageToAll(COLOR_YELLOWstring);
    }
    else if(
GetPlayerScore(playerid) >= 7500 && pInfo[playerid][Rank] < 10)
    {
        
pInfo[playerid][Rank] = 10;
        
format(stringsizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 350."GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessage(playeridCOLOR_LIMEstring);
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessageToAll(COLOR_YELLOWstring);
        
SetPlayerScore(playeridGetPlayerScore(playerid) + 350);
    }
    else if(
GetPlayerScore(playerid) >= 10000 && pInfo[playerid][Rank] < 11)
    {
        
pInfo[playerid][Rank] = 11;
        
format(stringsizeof(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(playeridCOLOR_LIMEstring);
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessageToAll(COLOR_YELLOWstring);
        
SetPlayerScore(playeridGetPlayerScore(playerid) + 250);
        
GivePlayerMoney(playerid50000);
    }
    else if(
GetPlayerScore(playerid) >= 13500 && pInfo[playerid][Rank] < 12)
    {
        
pInfo[playerid][Rank] = 12;
        
format(stringsizeof(string), "You have rank up to %s (%d) - Congratulations, You received a boosting score of 1000."GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessage(playeridCOLOR_LIMEstring);
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessageToAll(COLOR_YELLOWstring);
        
SetPlayerScore(playeridGetPlayerScore(playerid) + 1000);
    }
    else if(
GetPlayerScore(playerid) >= 17000 && pInfo[playerid][Rank] < 13)
    {
        
pInfo[playerid][Rank] = 13;
        
format(stringsizeof(string), "You have rank up to %s (%d) - Congratulations, You received a cash of $2,500,000"GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessage(playeridCOLOR_LIMEstring);
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]);
        
SendClientMessageToAll(COLOR_YELLOWstring);
        
GivePlayerMoney(playerid2500000);
    }
    
Update3DTextLabelText(Label[playerid], GetPlayerColor(playerid), GetRank(playerid));

Help would be appreciated.
Reply
#2

PHP код:
stock RankUp(playerid

    new 
string[128]; 

    if(
GetPlayerScore(playerid) >= 50 && GetPlayerScore(playerid) < 150
    { 
        
pInfo[playerid][Rank] = 1;
         
        
format(stringsizeof(string), "You have rank up to %s (%d) - Congratulations, You received a 10 score+, 5000$ and an armoury."GetRank(playerid), pInfo[playerid][Rank]); 
        
SendClientMessage(playeridCOLOR_LIMEstring); 
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]); 
        
SendClientMessageToAll(COLOR_YELLOWstring); 
         
        
SetPlayerScore(playeridGetPlayerScore(playerid) + 10); 
        
GivePlayerMoney(playerid5000); 
        
SetPlayerArmour(playerid100); 
    } 
    else if(
GetPlayerScore(playerid) >= 150 && GetPlayerScore(playerid) < 300
    { 
        
pInfo[playerid][Rank] = 2

        
format(stringsizeof(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(playeridCOLOR_LIMEstring); 
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]); 
        
SendClientMessageToAll(COLOR_YELLOWstring); 

        
SetPlayerScore(playeridGetPlayerScore(playerid) + 5); 
        
GivePlayerMoney(playerid3500); 
        
GivePlayerWeapon(playerid311000); 
    } 
    else if(
GetPlayerScore(playerid) >= 300 && GetPlayerScore(playerid) < 600
    { 
        
pInfo[playerid][Rank] = 3

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

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

        
format(stringsizeof(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(playeridCOLOR_LIMEstring); 
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]); 
        
SendClientMessageToAll(COLOR_YELLOWstring); 

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

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

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

        
format(stringsizeof(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(playeridCOLOR_LIMEstring); 
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]); 
        
SendClientMessageToAll(COLOR_YELLOWstring); 

        
SetPlayerScore(playeridGetPlayerScore(playerid) + 20); 
        
GivePlayerMoney(playerid10000); 

        
GivePlayerWeapon(playerid311000); 
        
GivePlayerWeapon(playerid291000); 
    } 
    else if(
GetPlayerScore(playerid) >= 2500 && GetPlayerScore(playerid) < 4500
    { 
        
pInfo[playerid][Rank] = 7

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

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

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

        
GivePlayerWeapon(playerid301000); 
        
GivePlayerWeapon(playerid321000); 
    } 
    else if(
GetPlayerScore(playerid) >= 6000 && GetPlayerScore(playerid) < 7500
    { 
        
pInfo[playerid][Rank] = 9

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

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

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

        
format(stringsizeof(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(playeridCOLOR_LIMEstring); 
        
format(stringsizeof(string), "* %s has ranked up to %s (%d)."nameEx(playerid), GetRank(playerid), pInfo[playerid][Rank]); 
        
SendClientMessageToAll(COLOR_YELLOWstring); 

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

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

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

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

        
GivePlayerMoney(playerid2500000); 
    } 
    
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
Reply
#3

You need set rank too
Reply
#4

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.
Reply
#5

Nice cool code dude
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)