SA-MP Forums Archive
Marks CMD as invalid - 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)
+--- Thread: Marks CMD as invalid (/showthread.php?tid=605301)



Marks CMD as invalid - NeXoR - 17.04.2016

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;




Re: Marks CMD as invalid - Konstantinos - 17.04.2016

"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.


Re: Marks CMD as invalid - NeXoR - 17.04.2016

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 ?


Re: Marks CMD as invalid - Konstantinos - 17.04.2016

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.


Re: Marks CMD as invalid - NeXoR - 17.04.2016

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