SA-MP Forums Archive
Invalid 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)
+--- Thread: Invalid Command! (/showthread.php?tid=593891)



Invalid Command! - YoussefHammad - 11.11.2015

i've made that if the player types in an invalid command , that code does its function
Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{	
        if(!success)
	{
	    SendClientMessage(playerid,COL_GREEN,"ERROR: Invalid command! Check /CMDS for the commands list");
	}
	return 1;
}
yes it does show when a player types an invalid cmd but it also shows up when a player types a valid one

any help ?


Re: Invalid Command! - jlalt - 11.11.2015

PHP код:
public OnPlayerCommandPerformed(playeridcmdtext[], success)
{    
        if(
success == 0)
    {
        
SendClientMessage(playerid,COL_GREEN,"ERROR: Invalid command! Check /CMDS for the commands list");
    }
    return 
1;




Re: Invalid Command! - PrO.GameR - 11.11.2015

Quote:
Originally Posted by jlalt
Посмотреть сообщение
PHP код:
public OnPlayerCommandPerformed(playeridcmdtext[], success)
{    
        if(
success == 0)
    {
        
SendClientMessage(playerid,COL_GREEN,"ERROR: Invalid command! Check /CMDS for the commands list");
    }
    return 
1;

Changing ! to ==0 doesn't fix a fucking code god damn it, stop being a kosmaghz
You should use this callback for invalid command since latest YSI update
PHP код:
public e_COMMAND_ERRORS:OnPlayerCommandReceived(playeridcmdtext[], e_COMMAND_ERRORS:success)
{
    if (
success != COMMAND_OK)
    {
        return 
SendClientMessage(playerid,COL_GREEN,"ERROR: Invalid command! Check /CMDS for the commands list");
    }
    return 
1;




Re: Invalid Command! - jlalt - 11.11.2015

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
Changing ! to ==0 doesn't fix a fucking code god damn it, stop being a kosmaghz
You should use this callback for invalid command since latest YSI update
PHP код:
public e_COMMAND_ERRORS:OnPlayerCommandReceived(playeridcmdtext[], e_COMMAND_ERRORS:success)
{
    if (
success != COMMAND_OK)
    {
        return 
SendClientMessage(playerid,COL_GREEN,"ERROR: Invalid command! Check /CMDS for the commands list");
    }
    return 
1;

stop swearing nab just wait for he's own reply to see if it does not work


Re: Invalid Command! - yvoms - 11.11.2015

pro.gamer was right lol.


Re: Invalid Command! - YoussefHammad - 11.11.2015

In this topic https://sampforum.blast.hk/showthread.php?tid=593886

btw i tried both , they dont work


Re: Invalid Command! - Jefff - 11.11.2015

Can you show a valid command from your gamemode?


Re: Invalid Command! - YoussefHammad - 11.11.2015

Quote:
Originally Posted by Jefff
Посмотреть сообщение
Can you show a valid command from your gamemode?
here:

Код:
CMD:aa(playerid,params[])
{
	SetPlayerPos(playerid, 404.7529,2439.8262,16.5000);
	SendClientMessage(playerid,COLOR_YELLOW,"Welcome to Abandand Airport.");
	GameTextForPlayer(playerid,"~w~Abandand Airport",3000,4);
}



Re: Invalid Command! - Jefff - 11.11.2015

Thats the problem, you need add return 1; at the end of command because in this case CallLocalFunction from zcmd returns 0 so 'success' is always false

pawn Код:
CMD:aa(playerid,params[])
{
    SetPlayerPos(playerid, 404.7529,2439.8262,16.5000);
    SendClientMessage(playerid,COLOR_YELLOW,"Welcome to Abandand Airport.");
    GameTextForPlayer(playerid,"~w~Abandand Airport",3000,4);
    return 1;
}



Re: Invalid Command! - YoussefHammad - 11.11.2015

alright thanks
EDIT: will reputate when i can