SA-MP Forums Archive
What is wrong with this command - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: What is wrong with this command (/showthread.php?tid=254812)



What is wrong with this command - BizzyD - 12.05.2011

Hello, I got a problem with my /admin command. It is a admin chat. But it dont work, When i do /admin Hey, It just says [LOST:RP] (/admin] [TEXT]

Anyone know how to fix?

This is my code:

pawn Код:
CMD:admin(playerid,params[])
    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        new result[64];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        if(sscanf(params, "us[128]", sendername,result))
        return SendClientMessage(playerid, RED, "[LOST:RP] (/a)dmin [TEXT]");
        if(PlayerInfo[playerid][pAdmin] == 0)
        return SendClientMessage(playerid, RED, "[LOST:RP] You arent a admin");
        {
            new adminstext[64];
            if(PlayerInfo[playerid][pAdmin] == 6) { adminstext = "Owner/Developer"; }
            else if(PlayerInfo[playerid][pAdmin] == 5) { adminstext = "Lead Admin"; }
            else if(PlayerInfo[playerid][pAdmin] == 4) { adminstext = "Admin"; }
            else if(PlayerInfo[playerid][pAdmin] == 3) { adminstext = "Low Admin"; }
            else if(PlayerInfo[playerid][pAdmin] == 2)  { adminstext = "Moderator"; }
            else if(PlayerInfo[playerid][pAdmin] == 1)  { adminstext = "Trial Adminstratior"; }
            format(string, sizeof(string), "[%s %s]: %s", adminstext, sendername, result);
            if (PlayerInfo[playerid][pAdmin] >= 1)
            {
                aMessage(COLOR_GREEN, string,1);
            }
            printf("Admin %s: %s", sendername, result);
        }
        return 1;
    }
Thanks for your response!

Regards, Alex


Re: What is wrong with this command - nemesis_567 - 12.05.2011

Try this.
pawn Код:
CMD:admin(playerid,params[])
    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        new result[64];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        if(sscanf(params, "s[64]"result))//sscanf recognizes a string input with the u parameter and returns the player id, but not his name. In here what matters is the string only since it is the only parameter
        return SendClientMessage(playerid, RED, "[LOST:RP] (/a)dmin [TEXT]");
        if(PlayerInfo[playerid][pAdmin] == 0)
        return SendClientMessage(playerid, RED, "[LOST:RP] You arent a admin");
        {
            new adminstext[64];
            if(PlayerInfo[playerid][pAdmin] == 6) { adminstext = "Owner/Developer"; }
            else if(PlayerInfo[playerid][pAdmin] == 5) { adminstext = "Lead Admin"; }
            else if(PlayerInfo[playerid][pAdmin] == 4) { adminstext = "Admin"; }
            else if(PlayerInfo[playerid][pAdmin] == 3) { adminstext = "Low Admin"; }
            else if(PlayerInfo[playerid][pAdmin] == 2)  { adminstext = "Moderator"; }
            else if(PlayerInfo[playerid][pAdmin] == 1)  { adminstext = "Trial Adminstratior"; }
            format(string, sizeof(string), "[%s %s]: %s", adminstext, sendername, result);
            if (PlayerInfo[playerid][pAdmin] >= 1)
            {
                aMessage(COLOR_GREEN, string,1);
            }
            printf("Admin %s: %s", sendername, result);
        }
        return 1;
    }



Re: What is wrong with this command - Laronic - 12.05.2011

Are you trying to make a admin chat? if so:

Not tested
pawn Код:
COMMAND:admin(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, RED, "[LOST:RP] You arent a admin");
    {
        new message[128], AdminRank, string[128], playername[24];
        GetPlayerName(playerid, playername, sizeof(playername));
        if(sscanf(params, "s[128]", message)) return SendClientMessage(playerid, RED, "[LOST:RP] (/a)dmin [TEXT]");
        {
            switch(PlayerInfo[playerid][pAdmin])
            {
                case 1: AdminRank = strval("Trial Adminstratior");
                case 2: AdminRank = strval("Moderator");
                case 3: AdminRank = strval("Low Admin");
                case 4: AdminRank = strval("Admin");
                case 5: AdminRank = strval("Owner/Developer");
                default: AdminRank = strval("Unknown");
            }
            format(string, sizeof(string), "[%s %s]: %s", AdminRank, playername, message);
            SendClientMessageToAdmins(COLOR_GREEN, string);
            printf(string);
        }
    }
    return 1;
}
pawn Код:
stock SendClientMessageToAdmins(color, message[])
{
    for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
    {
        if(PlayerInfo[i][pAdmin] >= 0)
        {
            SendClientMessageToAll(color, message);
        }
    }
    return 1;
}



Re: What is wrong with this command - BizzyD - 13.05.2011

Quote:
Originally Posted by nemesis_567
Посмотреть сообщение
Try this.
pawn Код:
CMD:admin(playerid,params[])
    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        new result[64];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        if(sscanf(params, "s[64]"result))//sscanf recognizes a string input with the u parameter and returns the player id, but not his name. In here what matters is the string only since it is the only parameter
        return SendClientMessage(playerid, RED, "[LOST:RP] (/a)dmin [TEXT]");
        if(PlayerInfo[playerid][pAdmin] == 0)
        return SendClientMessage(playerid, RED, "[LOST:RP] You arent a admin");
        {
            new adminstext[64];
            if(PlayerInfo[playerid][pAdmin] == 6) { adminstext = "Owner/Developer"; }
            else if(PlayerInfo[playerid][pAdmin] == 5) { adminstext = "Lead Admin"; }
            else if(PlayerInfo[playerid][pAdmin] == 4) { adminstext = "Admin"; }
            else if(PlayerInfo[playerid][pAdmin] == 3) { adminstext = "Low Admin"; }
            else if(PlayerInfo[playerid][pAdmin] == 2)  { adminstext = "Moderator"; }
            else if(PlayerInfo[playerid][pAdmin] == 1)  { adminstext = "Trial Adminstratior"; }
            format(string, sizeof(string), "[%s %s]: %s", adminstext, sendername, result);
            if (PlayerInfo[playerid][pAdmin] >= 1)
            {
                aMessage(COLOR_GREEN, string,1);
            }
            printf("Admin %s: %s", sendername, result);
        }
        return 1;
    }
This one works :P And CyberGhost, Yes im trying to make a admin chat :P But its solved now


Re: What is wrong with this command - Artix - 13.05.2011

is that from LUX?