Sv: Unkown Cmd || Where it is the bug ?
#1

Hello everyone !
I've tried to make a /radio command for the faction LSPD, but I have a little problem. After usign the command it show to me Server Unkown Cmd... and I can't understand where it's the problem...

Code
pawn Код:
CMD:radio(playerid,params[])
{
    new name[MAX_PLAYER_NAME],string[128],rank[128];
    if(PlayerInfo[playerid][pFaction] == 1 || PlayerInfo[playerid][pFaction] == 2)
    {
        if(isnull(params)) return SendClientMessage(playerid,COLOR_GREY,"Syntax: (/r)adio [Text]");
        else
        {
            if(PlayerInfo[playerid][pMute] == 0)
            {
                rank = GetPlayerFactionRank(playerid);
                GetPlayerName(playerid,name,sizeof(name));
                for(new i=0; i<=MAX_PLAYERS;i++)
                {
                    if(PlayerInfo[i][pFaction] == 1 || PlayerInfo[i][pFaction] == 2)
                    {
                        format(string,sizeof(string),"(Radio) {ffffff}%s{9999ff} {ffffff}%s{9999ff}: %s",rank,name,params);
                        SendClientMessage(i,0x9999FFFF,string);
                    }
                }
            }
            else{SendClientMessage(playerid,COLOR_RED,"[Mute]: You are muted and you can't speak !");}
        }
    }
    else{SendClientMessage(playerid,COLOR_GREY,"You aren't authorized to talk on this frequency !");}
    return 1;
}
Here it's the Stock for ranks.
pawn Код:
stock GetPlayerFactionRank(playerid)
{
    new rank[128];
    if(PlayerInfo[playerid][pFaction] == 0){rank = "Civil";}
    if(PlayerInfo[playerid][pFaction] == 1)
    {
        if(PlayerInfo[playerid][pRank] == 1){rank = "Patrol Officer";}
        if(PlayerInfo[playerid][pRank] == 2){rank = "Police Officer";}
        if(PlayerInfo[playerid][pRank] == 3){rank = "Sergeant";}
        if(PlayerInfo[playerid][pRank] == 4){rank = "Lieutant";}
        if(PlayerInfo[playerid][pRank] == 5){rank = "Police Captain";}
        if(PlayerInfo[playerid][pRank] == 6){rank = "Deputy Inspector";}
        if(PlayerInfo[playerid][pRank] == 7){rank = "Colonel";}
        if(PlayerInfo[playerid][pRank] == 8){rank = "Commander";}
        if(PlayerInfo[playerid][pRank] == 9){rank = "Deputy Chief";}
        if(PlayerInfo[playerid][pRank] == 10){rank = "Police Chief";}
    }
    return rank;
}
I put a screenshot to see how it's showing


Sorry for some gramatical english mistakes
Reply
#2

Are you using callback OnPlayerCommandText? And where are you put this command /Radio?
Reply
#3

I puted out of callback's and I used ZCMD/sscanf
Reply
#4

post your OnPlayerCommandText
Reply
#5

i think you need to..
Put it under OnPlayerCommandText
Reply
#6

I can't put it under OnPlayerCommandText because it won't work using ZCMD at the same time...

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    return 0;
}
Reply
#7

Check this:

https://sampforum.blast.hk/showthread.php?tid=91354

Quote:
Originally Posted by Zeex
Посмотреть сообщение
Description

Important: Since v0.3 OnPlayerCommandText cannot be used anymore (also ZCMD_NO_CALLBACK option has been removed), but there are two new callbacks instead:

pawn Код:
OnPlayerCommandReceived(playerid, cmdtext[])
This one is called when someone sends a command. If you return 0 here, the command won't be performed.

pawn Код:
OnPlayerCommandPerformed(playerid, cmdtext[], success)
And this one gets called after command execution, here if you do "return 0" the player will see standard "Unknown command" message. The "success" parameter is equal to value returned by command function returns (if it doesn't exist success will be 0).

Note that it's not necessary to add these callbacks to your script if you don't use them.


How to make two different commands doing the same thing
Reply
#8

pawn Код:
rank = GetPlayerFactionRank(playerid);
GetPlayerFactionRank returns a string, so you cannot assign it like that. Using switch in the function is also faster.

pawn Код:
CMD:radio(playerid,params[])
{
    if(PlayerInfo[playerid][pFaction] != 1 && PlayerInfo[playerid][pFaction] != 2) return SendClientMessage(playerid,COLOR_GREY,"You aren't authorized to talk on this frequency !");
    if(isnull(params)) return SendClientMessage(playerid,COLOR_GREY,"Syntax: (/r)adio [Text]");
    if(PlayerInfo[playerid][pMute] != 0) return SendClientMessage(playerid,COLOR_RED,"[Mute]: You are muted and you can't speak !");
    new name[21],string[128];
    GetPlayerName(playerid,name,sizeof(name));
    for(new i=0; i<MAX_PLAYERS;i++)
    {
        if(PlayerInfo[i][pFaction] == 1 || PlayerInfo[i][pFaction] == 2)
        {
            format(string,sizeof(string),"(Radio) {ffffff}%s{9999ff} {ffffff}%s{9999ff}: %s",GetPlayerFactionRank(playerid),name,params);
            SendClientMessage(i,0x9999FFFF,string);
        }
    }
    return 1;
}

stock GetPlayerFactionRank(playerid)
{
    new rank[32];
    switch (PlayerInfo[playerid][pFaction])
    {
        case 0: rank = "Civil";
        case 1:
        {
            switch (PlayerInfo[playerid][pRank])
            {
                case 1: rank = "Patrol Officer";
                case 2: rank = "Police Officer";
                case 3: rank = "Sergeant";
                case 4: rank = "Lieutant";
                case 5: rank = "Police Captain";
                case 6: rank = "Deputy Inspector";
                case 7: rank = "Colonel";
                case 8: rank = "Commander";
                case 9: rank = "Deputy Chief";
                case 10: rank = "Police Chief";
            }
        }
    }
    return rank;
}
Reply
#9

Oooh... Thanks everyone who helped me

Problem Solved !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)