Marks CMD as invalid
#1

Hey guys, I scripted a faction MOTD command
Everything works good when I type the command, but it still tells me that the CMD is invalid

Code:
PHP код:
CMD:adjustfacmotd(playeridparams[])
{
    new 
motdstring[128];
    if(!
IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playeridCOLOR_GREY"You are not allowed to use this command.");
    if(!
PlayerInfo[playerid][pFacLeader]) return SendClientMessage(playeridCOLOR_GREY"You are not a faction leader.");
    if(
sscanf(params"s[128]"motd)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /adjustfacmotd [MOTD]");
    
format(FacInfo[PlayerInfo[playerid][pFac]][facMOTD], 128"%s"motd);
    
format(stringsizeof(string), " %s %s has edited the faction Message of The Day."RPFRN(playerid), RPN(playerid));
    
SendPlayerFactionMessage(playerid0COLOR_RADIOstring);
    
format(stringsizeof(string), " %s"motd);
    
SendPlayerFactionMessage(playerid0COLOR_RADIOstring);
    
SendClientMessage(playeridCOLOR_WHITE"You have edited your faction's MOTD");
    return 
1;

CommandPerformed:
PHP код:
public OnPlayerCommandPerformed(playeridcmdtext[], success)
{
    new 
string[128];
    
format(stringsizeof(string), "[cmd] [%s]: %s"RPN(playerid), cmdtext);
     print(string);
    if(!
success)
    {
        
SendClientMessage(playeridCOLOR_RED"** The command you attempt to use doesn't exist on our server.");
    }
    return 
1;

Reply
#2

"motd" would need to be a string/array. sscanf is not needed actually for such a case, use isnull and params instead.

pawn Код:
FacInfo[PlayerInfo[playerid][pFac]][facMOTD]
You also need to check that the value of PlayerInfo[playerid][pFac] is in bounds (between 0 and sizeof FacInfo - 1) otherwise run time error 4 will be caused and show the unknown command message.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
"motd" would need to be a string/array. sscanf is not needed actually for such a case, use isnull and params instead.

pawn Код:
FacInfo[PlayerInfo[playerid][pFac]][facMOTD]
You also need to check that the value of PlayerInfo[playerid][pFac] is in bounds (between 0 and sizeof FacInfo - 1) otherwise run time error 4 will be caused and show the unknown command message.
Thanks for the tip, but would that solve the Invalid CMD issue ?
Reply
#4

The last part I mentioned is the actual problem that needs to get fixed.
About the sscanf, it will probably throw a warning in the console and print wrong data to format but that wouldn't cause the unknown command. You need to change that though in order for it to work properly.
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The last part I mentioned is the actual problem that needs to get fixed.
About the sscanf, it will probably throw a warning in the console and print wrong data to format but that wouldn't cause the unknown command. You need to change that though in order for it to work properly.
Works perfect, thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)