SA-MP Forums Archive
Lost use of commands. - 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: Lost use of commands. (/showthread.php?tid=611553)



Lost use of commands. - Lynn - 08.07.2016

Alright so I was doing some things, messing around with modules for a gamemode,
Loading code from one file to anther, along with a few other things.
However, when I finally did a restart I noticed I lost the use of commands.
Regardless of the command I used it wouldn't work.
It just does nothing.

What are some common errors made, that would cause this?
I was using Pawn.cmd plugin, however I switched to ZCMD to see if that solved the issue
No results. My commands were working fine but I tried removing the module from my script, that didn't work
So if It wasn't that I have no idea the cause.

I do have
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    return 
0;

Located under my commands.

So it looks like this:

PHP код:
CMD:somecmd(playeridparams[])
{
    return 
1;
}
CMD:somecmd2(playeridparams[])
{
    return 
1;
}
CMD:somecmd3(playeridparams[])
{
    return 
1;
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
    return 
0;




Re: Lost use of commands. - Lynn - 08.07.2016

FIXED:

How I resolved the issue:

PHP код:
CMD:somecmd(playeridparams[])
{
    if(
somevariable == true)
    {
         
//Do some stuff
    
}
    else
    {
        
SendClientMessage(playerid, -1"Error Message);
    }
    return 1;

Changed to:

PHP код:
CMD:somecmd(playeridparams[])
{
    if(
somevariable == true)
    {
         
//Do some stuff
    
}
    else
    {
        
SendClientMessage(playerid, -1"Error Message);
        return 1;
    }
    return 1;

Conclusion:

Commands didn't work due to a missing return value.
Don't forget to return values in your commands!