SA-MP Forums Archive
Several commands, error ??? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Several commands, error ??? (/showthread.php?tid=186964)



Several commands, error ??? - Hudgens - 31.10.2010

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/skatepark", cmdtext, true, 10) == 0)
    {
    SetPlayerPos(playerid,1893.8850,-1388.2507,13.5703);
    SendClientMessage(playerid, COLOR_BLACK , "Have fun in skatepark!");
        // Do something here
    }
    if (strcmp("/commands", cmdtext, true, 10) == 0)
    {
            SendClientMessage(playerid,COLOR_YELLOW, "/skatepark");
	}
	if (strcmp("/kill", cmdtext, true, 10) == 0)
			SetPlayerHealth(playerid,0.0);
	}
			 return 1;
    }
	return 0;
}
Код:
And I get this error
C:\Documents and Settings\Дgaren\Skrivbord\SERVER\gamemodes\Hudgens.pwn(136) : error 010: invalid function or declaration
C:\Documents and Settings\Дgaren\Skrivbord\SERVER\gamemodes\Hudgens.pwn(138) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: Several commands, error ??? - admantis - 31.10.2010

what are lines 136 and 138? by the way, improve your identation


Re: Several commands, error ??? - admantis - 31.10.2010

sorry for double post but i actually found why, you had a missing bracket and a missing ; semicolon, and other thing, always add return to your command or it will say SERVER: Unknown command

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/skatepark", cmdtext, true, 10) == 0)
    {
        SetPlayerPos(playerid,1893.8850,-1388.2507,13.5703);
        return SendClientMessage(playerid, COLOR_BLACK , "Have fun in skatepark!");
    }
    if (strcmp("/commands", cmdtext, true, 10) == 0)
    {
        return SendClientMessage(playerid,COLOR_YELLOW, "/skatepark");
    }
    if (strcmp("/kill", cmdtext, true, 10) == 0)
    {
        return SetPlayerHealth(playerid,0.0);
    }
    return 0;
}



Re: Several commands, error ??? - Hudgens - 31.10.2010

Thanks, I'm new to scripting : )


Re: Several commands, error ??? - admantis - 31.10.2010

Quote:
Originally Posted by Hudgens
Посмотреть сообщение
Thanks, I'm new to scripting : )
no problem i was like you once im still newb but learning, remember always return values in your command to avoid SERVER: Unknown command and improve your identation for easier reading.

P.S: i made a small mistake, re read my code.


Re: Several commands, error ??? - Hudgens - 31.10.2010

I saw that u missed return 1;