cmd:showhbadge
#1

Hello,when i do /showhbadge it just tells me the usage and it doesn't work ,can someone tell me what the problem is ?
pawn Код:
CMD:showhbadge(playerid, params[])
{
    if(PlayerInfo[playerid][pMember] >= 8 || PlayerInfo[playerid][pLeader] >= 8)
    {
        new string[128], giveplayerid, badge[262];
        if(sscanf(badge, "i", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /showhbadge [Name (lapd,fbi,lafd,ccfd,lasd,lvmpd)] [playerid]");

        if(giveplayerid != INVALID_PLAYER_ID) {
            if(ProxDetectorS(10.0, playerid, giveplayerid)) {
                if(strcmp(badge,"lapd",true) == 0)
                {
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                format(string, sizeof(string), "Officer %s is a duly sworn member of the Los Angeles Police Department.", GetPlayerNameEx(playerid));
                format(string, sizeof(string), "Current Assignment: General Duties.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the City of Los Angeles.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to arrest.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to assist in arrests.");
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                }
                if(strcmp(badge,"fbi",true) == 0)
                {
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                format(string, sizeof(string), "Agent %s is a duly sworn member of the Federal Bureau Investigations.", GetPlayerNameEx(playerid));
                format(string, sizeof(string), "Current Assignment: NBS.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the United States Government.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to arrest.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to assist in arrests.");
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                }
                if(strcmp(badge,"lafd",true) == 0)
                {
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                format(string, sizeof(string), "Lieutenant %s is a duly sworn member of the Los Angeles Fire Department.", GetPlayerNameEx(playerid));
                format(string, sizeof(string), "Current Assignment: General Duties.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the City of Los Angeles.");
                SendClientMessageEx(giveplayerid, COLOR_RED, "** Official has no authority to arrest, or assist in arrests. **");
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                }
                if(strcmp(badge,"ccfd",true) == 0)
                {
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                format(string, sizeof(string), "Lieutenant %s is a duly sworn member of the Clark County Fire Department.", GetPlayerNameEx(playerid));
                format(string, sizeof(string), "Current Assignment: General Duties.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of Clark County Nevada.");
                SendClientMessageEx(giveplayerid, COLOR_RED, "** Official has no authority to arrest, or assist in arrests. **");
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                }
                if(strcmp(badge,"lasd",true) == 0)
                {
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                format(string, sizeof(string), "Deputy %s is a duly sworn member of the Los Angeles Sheriff's Department.", GetPlayerNameEx(playerid));
                format(string, sizeof(string), "Current Assignment: CIA.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the City of Los Angeles.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to arrest.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to assist in arrests.");
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                }
                if(strcmp(badge,"lvmpd",true) == 0)
                {
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                format(string, sizeof(string), "Sergeant %s is a duly sworn member of the Las Vegas Metropolitan Police Department.", GetPlayerNameEx(playerid));
                format(string, sizeof(string), "Current Assignment: Investigations.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the State of Nevada.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to arrest.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to assist in arrests.");
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                }
                format(string, sizeof(string), "* %s shows their badge to %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
            else SendClientMessageEx(playerid, COLOR_GREY, "That player isn't near you.");
        }
        else SendClientMessageEx(playerid, COLOR_WHITE, "You are not in the Hitman Agency.");
    }
    return 1;
}
Reply
#2

Try this:
Quote:
Originally Posted by Drago987
Посмотреть сообщение
Hello,when i do /showhbadge it just tells me the usage and it doesn't work ,can someone tell me what the problem is ?
pawn Код:
CMD:showhbadge(playerid, params[])
{
    if(PlayerInfo[playerid][pMember] >= 8 || PlayerInfo[playerid][pLeader] >= 8)
    {
        new string[128], giveplayerid, badge[262];
        if(sscanf(params, "u", badge)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /showhbadge [Name (lapd,fbi,lafd,ccfd,lasd,lvmpd)] [playerid]");//badge changed on params

        if(giveplayerid != INVALID_PLAYER_ID) {
            if(ProxDetectorS(10.0, playerid, giveplayerid)) {
                if(strcmp(badge,"lapd",true) == 0)
                {
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                format(string, sizeof(string), "Officer %s is a duly sworn member of the Los Angeles Police Department.", GetPlayerNameEx(playerid));
                format(string, sizeof(string), "Current Assignment: General Duties.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the City of Los Angeles.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to arrest.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to assist in arrests.");
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                }
                if(strcmp(badge,"fbi",true) == 0)
                {
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                format(string, sizeof(string), "Agent %s is a duly sworn member of the Federal Bureau Investigations.", GetPlayerNameEx(playerid));
                format(string, sizeof(string), "Current Assignment: NBS.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the United States Government.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to arrest.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to assist in arrests.");
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                }
                if(strcmp(badge,"lafd",true) == 0)
                {
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                format(string, sizeof(string), "Lieutenant %s is a duly sworn member of the Los Angeles Fire Department.", GetPlayerNameEx(playerid));
                format(string, sizeof(string), "Current Assignment: General Duties.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the City of Los Angeles.");
                SendClientMessageEx(giveplayerid, COLOR_RED, "** Official has no authority to arrest, or assist in arrests. **");
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                }
                if(strcmp(badge,"ccfd",true) == 0)
                {
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                format(string, sizeof(string), "Lieutenant %s is a duly sworn member of the Clark County Fire Department.", GetPlayerNameEx(playerid));
                format(string, sizeof(string), "Current Assignment: General Duties.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of Clark County Nevada.");
                SendClientMessageEx(giveplayerid, COLOR_RED, "** Official has no authority to arrest, or assist in arrests. **");
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                }
                if(strcmp(badge,"lasd",true) == 0)
                {
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                format(string, sizeof(string), "Deputy %s is a duly sworn member of the Los Angeles Sheriff's Department.", GetPlayerNameEx(playerid));
                format(string, sizeof(string), "Current Assignment: CIA.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the City of Los Angeles.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to arrest.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to assist in arrests.");
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                }
                if(strcmp(badge,"lvmpd",true) == 0)
                {
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                format(string, sizeof(string), "Sergeant %s is a duly sworn member of the Las Vegas Metropolitan Police Department.", GetPlayerNameEx(playerid));
                format(string, sizeof(string), "Current Assignment: Investigations.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the State of Nevada.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to arrest.");
                SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to assist in arrests.");
                SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                }
                format(string, sizeof(string), "* %s shows their badge to %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
            else SendClientMessageEx(playerid, COLOR_GREY, "That player isn't near you.");
        }
        else SendClientMessageEx(playerid, COLOR_WHITE, "You are not in the Hitman Agency.");
    }
    return 1;
}
Reply
#3

pawn Код:
if(sscanf(badge, "us[262]", badge, giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /showhbadge [Name (lapd,fbi,lafd,ccfd,lasd,lvmpd)] [playerid]");
Reply
#4

it gives me this only
pawn Код:
format(string, sizeof(string), "* %s shows their badge to %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
Reply
#5

i've changed it to this
pawn Код:
if(sscanf(params, "us[262]", badge, giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /showhbadge [Name (lapd,fbi,lafd,ccfd,lasd,lvmpd)] [playerid]");
but it says "That player isn't near you"
Reply
#6

Bump
Reply
#7

Cant someone help me fixing it ?
Reply
#8

Nope...
Quote:
Originally Posted by ConnorHunter
Посмотреть сообщение
pawn Код:
if(sscanf(badge, "us[262]", badge, giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /showhbadge [Name (lapd,fbi,lafd,ccfd,lasd,lvmpd)] [playerid]");
Yep...
pawn Код:
if(sscanf(params, "s[262]u", badge, giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /showhbadge [Name (lapd,fbi,lafd,ccfd,lasd,lvmpd)] [playerid]");
You have to scan the params of the command (which is what goes after the command itself), then every operator must be respective to the parameters they are stored at. Strings with strings, integers with integers.

Also, why are you using a 262 cell array for a string that at most will use 6 cells?
Reply
#9

Try this:
pawn Код:
CMD:showbadge(playerid, params[])
{
    if(PlayerInfo[playerid][pMember] >= 1 || PlayerInfo[playerid][pLeader] >= 1)
    {
        new string[128], giveplayerid;
        if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /showbadge [playerid]");

        if(giveplayerid != INVALID_PLAYER_ID) {
            if(ProxDetectorS(5.0, playerid, giveplayerid)) {
                switch(PlayerInfo[playerid][pMember]) {
                    case 1 .. 4, 5, 6, 7, 11, 12, 13: {

                        new
                        infoArrays[3][64];

                        GetPlayerFactionInfo(playerid, infoArrays[0], infoArrays[1], infoArrays[2]);

                        SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                        format(string, sizeof(string), "%s %s is a duly sworn member of the %s.", infoArrays[0], GetPlayerNameEx(playerid), infoArrays[2]);
                        SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
                        format(string, sizeof(string), "Current Assignment: %s.", infoArrays[1]);
                        SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
                        switch(PlayerInfo[playerid][pMember]) {
                            case 1: SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the City of Los Santos.");
                            case 2: SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the United States Government.");
                            case 3: SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the City of San Fierro.");
                            case 12: SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the Nation of Tierra Robada.");
                            case 13: SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the United States Government.");
                            default: SendClientMessageEx(giveplayerid, COLOR_WHITE, "Under the Authority of the State of San Andreas.");
                        }
                        if(PlayerInfo[playerid][pMember] != 6 && PlayerInfo[playerid][pMember] != 12) SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to arrest.");
                        else if(PlayerInfo[playerid][pMember] == 12 && PlayerInfo[playerid][pDivision] == 2) SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to arrest.");
                        else SendClientMessageEx(giveplayerid, COLOR_WHITE, "Official has the authority to assist in arrests.");
                        SendClientMessageEx(giveplayerid, COLOR_GRAD2, "----------------------------------------------------------------------------------------------------");
                        format(string, sizeof(string), "* %s shows their badge to %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    }
                    default: SendClientMessageEx(playerid, COLOR_WHITE, "You are not in a civil service faction.");
                }
            }
            else SendClientMessageEx(playerid, COLOR_GREY, "That player isn't near you.");
        }
        else SendClientMessageEx(playerid, COLOR_WHITE, "You are not in a civil service faction.");
    }
    return 1;
}
Its my code from my script. Note: In this code its /showbadge and not /showhbadge. Enjoy.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)