Command not working(worked earlyer)
#1

Hello today my server restarted and from that moment /myrank command is not working :/ Could you look at it
If this is the code which i need to paste here it is:

Код:
CMD:myrank(playerid, params[])
		{
			GetPlayerRank(playerid);
			return 1;

		}

Код:
//=============================//
forward GetPlayerRank(playerid);
public GetPlayerRank(playerid)
{
            new string[64];
            if(GetPlayerScore(playerid) <= 10)
            {
            SendClientMessage(playerid, COLOR_WHITE, "Your Rank Is "#COL_GREEN#" Free Man");
            format(string, sizeof(string),"Your score is: "#COL_GREEN#"%d", GetPlayerScore(playerid));
            SendClientMessage(playerid, COLOR_WHITE, string);
            }
            else if(GetPlayerScore(playerid) <= 100)
            {
            SendClientMessage(playerid, COLOR_WHITE, "Your Rank Is "#COL_GREEN#" Drug User");
            format(string, sizeof(string),"Your score is: "#COL_GREEN#"%d", GetPlayerScore(playerid));
            SendClientMessage(playerid, COLOR_WHITE, string);
            }
            else if(GetPlayerScore(playerid) <= 250)
            {
            SendClientMessage(playerid, COLOR_WHITE, "Your Rank Is "#COL_GREEN#" Addicted");
            format(string, sizeof(string),"Your score is: "#COL_GREEN#"%d", GetPlayerScore(playerid));
            SendClientMessage(playerid, COLOR_WHITE, string);
            }
            else if(GetPlayerScore(playerid) <= 400)
            {
            SendClientMessage(playerid, COLOR_WHITE, "Your Rank Is "#COL_GREEN#" OutLaw Hunter");
            format(string, sizeof(string),"Your score is: "#COL_GREEN#"%d", GetPlayerScore(playerid));
            SendClientMessage(playerid, COLOR_WHITE, string);
            }
            else if(GetPlayerScore(playerid) <= 650)
            {
            SendClientMessage(playerid, COLOR_WHITE, "Your Rank Is "#COL_GREEN#" Prisoner");
            format(string, sizeof(string),"Your score is: "#COL_GREEN#"%d", GetPlayerScore(playerid));
            SendClientMessage(playerid, COLOR_WHITE, string);
            }
            else if(GetPlayerScore(playerid) <= 920)
            {
            SendClientMessage(playerid, COLOR_WHITE, "Your Rank Is "#COL_GREEN#" Blood Addicted");
            format(string, sizeof(string),"Your score is: "#COL_GREEN#"%d", GetPlayerScore(playerid));
            SendClientMessage(playerid, COLOR_WHITE, string);
            }
            else if(GetPlayerScore(playerid) <= 1150)
            {
            SendClientMessage(playerid, COLOR_WHITE, "Your Rank Is "#COL_GREEN#"Serial Killer");
            format(string, sizeof(string),"Your score is: "#COL_GREEN#"%d", GetPlayerScore(playerid));
            SendClientMessage(playerid, COLOR_WHITE, string);
            }
            else if(GetPlayerScore(playerid) <= 1500)
            {
            SendClientMessage(playerid, COLOR_WHITE, "Your Rank Is "#COL_GREEN#"Mass Murderer");
            format(string, sizeof(string),"Your score is: "#COL_GREEN#"%d", GetPlayerScore(playerid));
            SendClientMessage(playerid, COLOR_WHITE, string);
            }
            else if(GetPlayerScore(playerid) <= 2000)
            {
            SendClientMessage(playerid, COLOR_WHITE, "Your Rank Is "#COL_GREEN#"Silent Specter");
            format(string, sizeof(string),"Your score is: "#COL_GREEN#"%d", GetPlayerScore(playerid));
            SendClientMessage(playerid, COLOR_WHITE, string);
            }
            else if(GetPlayerScore(playerid) <= 2700)
            {
            SendClientMessage(playerid, COLOR_WHITE, "Your Rank Is "#COL_GREEN#"Ghost");
            format(string, sizeof(string),"Your score is: "#COL_GREEN#"%d", GetPlayerScore(playerid));
            SendClientMessage(playerid, COLOR_WHITE, string);
            }
            else if(GetPlayerScore(playerid) <= 3000)
            {
            SendClientMessage(playerid, COLOR_WHITE, "Your Rank Is "#COL_GREEN#"Unstopable");
            format(string, sizeof(string),"Your score is: "#COL_GREEN#"%d", GetPlayerScore(playerid));
            SendClientMessage(playerid, COLOR_WHITE, string);
            }
        	return 1;
}

stock PlayerName2(playerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	return name;
}
P.s It compiles fine but ingame not working :/

Sincerely,
Niko
Reply
#2

There is a more easy way to do this without writing a lot of code for each outcome, if you're confused you should read this. It's the best explanation of Switch Statements.

pawn Код:
stock GetRank(playerid) // A new stock to get their rank according to their score.
{
    new rank[34];

    switch(GetPlayerScore(playerid))
    {
        case 0 .. 10: rank = "Free Man"; // If their rank is between 0 and 10 then they are a free man.
        case 11 .. 100: rank = "Drug User"; // etc...
        case 101 .. 250: rank = "Addicted";
        case 251 .. 400: rank = "Outlaw";
        case 401 .. 650: rank = "Prisoner";
        case 651 .. 920: rank = "Blood Addicted";
        case 921 .. 1150: rank = "Serial Killer";
        case 1151 .. 1500: rank = "Mass Murdered";
        case 1501 .. 2000: rank = "Silent Suspect";
        case 2001 .. 2700: rank = "Ghost";
        case 2701 .. 3000: rank = "Unstoppable";
        default: rank = "God"; // If the player has more than 3000 score, then their rank is god.
    }
    return rank; // Returns the string for later use.
}
CMD:myrank(playerid,params[])
{
    new string[124];
    format(string,sizeof(string),"Your rank is: %s.",GetRank(playerid)); // Gets their rank according to the stock above.
    SendClientMessage(playerid,-1,string);
    return 1;
}
See? Now you don't have to write a whole new line for each code. Much more efficient than writing a lot of if statements.
Reply
#3

Thank you for this very much ,i got the meaning now ,thanks

Regards,
Niko
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)