should return a value
#7

Quote:
Originally Posted by Mencent
Посмотреть сообщение
@J4Rr3x:

You should write it like this:
PHP код:
stock GetAdminName(playerid)
{
    new 
adminname[64];
    switch(
pInfo[playerid][pAdminLevel])
    {
        case 
1:adminname "Test";
        case 
2:adminname "Test";
        case 
3:adminname "Test";
        case 
4:adminname "Test";
        case 
5:adminname "Test";
        default:return 
0;
    }
    return 
adminname;

If the player is admin level 0, it return nothing.
Yes, i've fixed my code. Thanks you!

pawn Код:
GetAdminName(playerid) // Use plain function instead of stock if you aren't making an include
{
    new adminname[128];
    switch(pInfo[playerid][pAdminLevel])
    {
        case 0: strpack(adminname, "Test"); // Right method and more faster.
        case 1: strpack(adminname, "Test");
        case 2: strpack(adminname, "Test");
        case 3: strpack(adminname, "Test");
        case 4: strpack(adminname, "Test");
        case 5: strpack(adminname, "Test");
                default: return 0;
    }
    return adminname;
}

// Example
public OnPlayerConnect(playerid)
{
    new string[128], name[MAX_PLAYER_NAME+1];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s %s has connected to the server!", GetAdminName(playerid), name);

    for(new i = 0; i <= GetPlayerPoolSize(); ++i) // This send message like "Founder J4Rr3x has connected to the server!" to all online admins
        if(IsPlayerConnected(i) && pInfo[playerid][pAdminLevel] > 0)
            SendClientMessage(i, -1, string);

    return 1;
}
Reply


Messages In This Thread
~fixed~ - by Blackazur - 09.05.2015, 15:35
Re: should return a value - by Konstantinos - 09.05.2015, 15:39
AW: should return a value - by Blackazur - 09.05.2015, 15:40
AW: should return a value - by Mencent - 09.05.2015, 16:01
Re: should return a value - by J4Rr3x - 09.05.2015, 16:05
AW: should return a value - by Mencent - 09.05.2015, 16:07
Re: AW: should return a value - by J4Rr3x - 09.05.2015, 16:10
Re: should return a value - by Nirzor - 09.05.2015, 16:12
Re: should return a value - by Konstantinos - 09.05.2015, 16:21
AW: should return a value - by Blackazur - 09.05.2015, 16:27

Forum Jump:


Users browsing this thread: 1 Guest(s)