SA-MP Forums Archive
Problem with my 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: Problem with my command. (/showthread.php?tid=435559)



Problem with my command. - Hand-Scripter - 07.05.2013

Hi, I made a /stealbomb command.

Only the terrorists can steal the bomb, but when I typ /stealbomb at the location, it says unknown command.

When I am not at the location, it also says unknown command + the clientmessage you are not at the point.

Code:

pawn Код:
CMD:stealbomb(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 5.0, 275.3401, 1860.3333, 8.7578))
    {
        if(GetPlayerTeam(playerid) == Terrorists)
        SendClientMessageToAll(COLOR_DARKORANGE, "%s has stolen the bomb!");
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You are not near the stealing point!");
    }
}
Can anyone help me out? Thanks.


Re: Problem with my command. - Yashas - 07.05.2013

The unknown command comes when a number other than 1 is returned.Add return 1 at the end of the command block and its fixed.

Actually the comamnd works fine but you never told the server that it was fine.return 1 is used to tell that the command worked smoothly without any problems.return 0 will give Unkown Command.

So your code must look something like this
Код:
CMD:stealbomb(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 5.0, 275.3401, 1860.3333, 8.7578))
    {
        if(GetPlayerTeam(playerid) == Terrorists)
        SendClientMessageToAll(COLOR_DARKORANGE, "%s has stolen the bomb!");
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You are not near the stealing point!");
    }
    return 1;
}



Re: Problem with my command. - Mitchy - 07.05.2013

Try This:
Код:
CMD:stealbomb(playerid, params[])
{
	if(IsPlayerInRangeOfPoint(playerid, 5.0, 275.3401, 1860.3333, 8.7578
	{
	    if(GetPlayerTeam(playerid) == Terrorists)
	    SendClientMessageToAll(COLOR_DARKORANGE, "%s has stolen the bomb!", GetPlayerName(playerid));
	}
	else SendClientMessage(playerid, "You are not near the stealing point!");
        return 1;
}



Re: Problem with my command. - Hand-Scripter - 07.05.2013

Quote:
Originally Posted by Mitchy
Посмотреть сообщение
Try This:
Код:
CMD:stealbomb(playerid, params[])
{
	if(IsPlayerInRangeOfPoint(playerid, 5.0, 275.3401, 1860.3333, 8.7578
	{
	    if(GetPlayerTeam(playerid) == Terrorists)
	    SendClientMessageToAll(COLOR_DARKORANGE, "%s has stolen the bomb!", GetPlayerName(playerid));
	}
	else SendClientMessage(playerid, "You are not near the stealing point!");
        return 1;
}
^ Did not work.

Quote:
Originally Posted by Yashas
Посмотреть сообщение
The unknown command comes when a number other than 1 is returned.Add return 1 at the end of the command block and its fixed.

Actually the comamnd works fine but you never told the server that it was fine.return 1 is used to tell that the command worked smoothly without any problems.return 0 will give Unkown Command.

So your code must look something like this
Код:
CMD:stealbomb(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 5.0, 275.3401, 1860.3333, 8.7578))
    {
        if(GetPlayerTeam(playerid) == Terrorists)
        SendClientMessageToAll(COLOR_DARKORANGE, "%s has stolen the bomb!");
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You are not near the stealing point!");
    }
    return 1;
}
^ Did work.

Thank you both.


Re: Problem with my command. - Yashas - 07.05.2013

Both are the same!!Both do the same work.I just added braces.


Re: Problem with my command. - Mitchy - 07.05.2013

Quote:
Originally Posted by Hand-Scripter
Посмотреть сообщение
^ Did not work.



^ Did work.

Thank you both.
Woooops. Look at my command, I forgot to put the brackets on the "IsPlayerInRangeOfPoint". My bad, I'm a sloppy typer. :/


Re: Problem with my command. - Yashas - 07.05.2013

Quote:
Originally Posted by Mitchy
Посмотреть сообщение
Woooops. Look at my command, I forgot to put the brackets on the "IsPlayerInRangeOfPoint". My bad, I'm a sloppy typer. :/
LOL Your error was there, I tought it did not work because you had removed the braces xD and was confused!!!


Re: Problem with my command. - Mitchy - 07.05.2013

Quote:
Originally Posted by Yashas
Посмотреть сообщение
LOL Your error was there, I tought it did not work because you had removed the braces xD and was confused!!!
Nah, no need to put braces on the "else", you can just "else SendClientMessage(etc)" and "else if (code blabla)"


Re: Problem with my command. - Yashas - 07.05.2013

Quote:
Originally Posted by Mitchy
Посмотреть сообщение
Nah, no need to put braces on the "else", you can just "else SendClientMessage(etc)" and "else if (code blabla)"
Thats what I meant, both of our codes must work! with or without braces since its just one statement.I was telling both of ours should work but actually the problem in your code was )) which I did not see!