Requesting help with this function.
#1

Hi,
I'm doing a function but I have a problem, first I will explain the behavior of this "function".
I want to get the name of "Administrator Level" by a number.

0 = Junior Administrator

0 = number(quantitative value)
Junior Administrator = Administrator level name(qualitative value)

For example someone wants to know how is called the level "1".
This function will send the name.

PHP код:
stock GetAdmNameLevelByNumber(lvl)
{
new 
string[21];
    switch(
lvl)
    {
        case 
0string "Newbie";
        case 
1string "Operator";
        case 
2string "Moderator";
        case 
3string "Junior Administrator";
        case 
4string "Senior Administrator";
        case 
5string "Head Administrator";
        case 
6string "Hero Administrator";
        case 
7string "Community Owner";
    }
    return 
lvl;

Under my "CMD:makeadmin":

PHP код:
//stuff here
//stuff here
//stuff here
new string[128], str2[128];
        
format(stringsizeof(string), "You have made %s, Level %s(%d)"Name(player), GetAdmNameLevelByNumber(alevel), alevel);
        
SendClientMessage(playeridSUCCESSstring);
        
format(str2sizeof(str2), "Administrator %s has made you %s(%d)"Name(playerid), GetAdmNameLevelByNumber(alevel), alevel);
        
SendClientMessage(playerSUCCESSstr2);
        
PlayerInfo[player][pAdmin] = alevel
It prints in game:

PHP код:
You have made DrakeLevel @Drake(7)
Administrator Drake has made you @Drake(7
The help will be appreciated.
Reply
#2

You are returning the level from the function instead of the string.
Reply
#3

Quote:
Originally Posted by Bakr
Посмотреть сообщение
You are returning the level from the function instead of the string.
This should work:
pawn Код:
stock GetAdmNameLevelByNumber(lvl)
{
    new string[21];
    switch(lvl)
    {
        case 0: string = "Newbie";
        case 1: string = "Operator";
        case 2: string = "Moderator";
        case 3: string = "Junior Administrator";
        case 4: string = "Senior Administrator";
        case 5: string = "Head Administrator";
        case 6: string = "Hero Administrator";
        case 7: string = "Community Owner";
    }
    return string;
}
Reply
#4

I did not notice it.
It has worked.
Thank you so much.
Reply
#5

Quote:
Originally Posted by Roach_
Посмотреть сообщение
This should work:
Herp-Derp.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)