Problem with my command.
#1

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.
Reply
#2

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;
}
Reply
#3

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;
}
Reply
#4

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.
Reply
#5

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

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. :/
Reply
#7

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!!!
Reply
#8

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)"
Reply
#9

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)