SA-MP Forums Archive
Requesting help with this function. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Requesting help with this function. (/showthread.php?tid=411120)



Requesting help with this function. - ThePhenix - 27.01.2013

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.


Re: Requesting help with this function. - Bakr - 27.01.2013

You are returning the level from the function instead of the string.


Re: Requesting help with this function. - Roach_ - 27.01.2013

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;
}



Re: Requesting help with this function. - ThePhenix - 27.01.2013

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


Re: Requesting help with this function. - Bakr - 27.01.2013

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