little help
#1

Im receiving an error from my code::

Код:
forward BotPos(BotPos, Float:X, Float:Y, Float:Z);
public BotPos(BotPos, Float:X, Float:Y, Float:Z)
{
	for(new b=0; b<MAX_PLAYERS; b++)
	{
		if(IsPlayerNPC(b))
		{
			BotPos = GetPlayerPos(b, X, Y, Z);
   			return 1;
		}
	}
	return 1;
}

CMD:findbot(playerid, params[])
{
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(IsPlayerAdmin(i))
  		{
		    SetPlayerPos(i, BotPos);//Error here
  		    SendClientMessage(i, -1, "You arrived successfully");
  		    return 1;
		}
		else return SendClientMessage(playerid, -1, "You are not authorized to use that command!");
	}
	return 1;
}
Error::

Код:
error 076: syntax error in the expression, or invalid function call
Reply
#2

any help please?
Reply
#3

https://sampwiki.blast.hk/wiki/SetPlayerPos
Reply
#4

well I know how to "SetPlayerPos" see all "Botpos" in the code and you will understand me

sorry but this URL is not helping me
Reply
#5

pawn Код:
stock BotPos(&Float:botX, &Float:botY, &Float:botZ) {
    for(new b=0; b<MAX_PLAYERS; ++b) {
        if(IsPlayerNPC(b)) {
            GetPlayerPos(b, botX, botY, botZ);
            break;
        }
    }
    return 1;
}

CMD:findbot(playerid, params[]) {
    for(new i=0; i<MAX_PLAYERS; ++i) {
        if(IsPlayerAdmin(i)) {
            new Float:X, Float:Y, Float:Z;
            BotPos(X, Y, Z);
            SetPlayerPos(i, X, Y, Z);
            SendClientMessage(i, -1, "You arrived successfully");
        }
        else SendClientMessage(playerid, -1, "You are not authorized to use that command!");
    }
    return 1;
}
Should work.
Reply
#6

You clearly do not know how to use SetPlayerPos.

Quote:

Parameters:
(playerid,Float,Float:y,Float:z)

Try this:
pawn Код:
CMD:findbot(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        for(new b=0; b<MAX_PLAYERS; b++)
        {
            if(IsPlayerNPC(b))
            {
                new Float:X,Float:Y,Float:Z;
                GetPlayerPos(b, X, Y, Z);
            }
        }
        SetPlayerPos(i, X, Y, Z);
        SendClientMessage(i, -1, "You arrived successfully");
        return 1;
    }
    else return SendClientMessage(playerid, -1, "You are not authorized to use that command!");
}
Reply
#7

I already made this before! but what happened is::

I receive this error::

Код:
error 017: undefined symbol "X"
lol : )

thats why I made this "public BotPos"
Reply
#8

Quote:
Originally Posted by Youice
Посмотреть сообщение
I already made this before! but what happened is::

I receive this error::

Код:
error 017: undefined symbol "X"
lol : )

thats why I made this "public BotPos"
Try this then:
pawn Код:
CMD:findbot(playerid, params[])
{
    new Float:X,Float:Y,Float:Z;
    if(IsPlayerAdmin(playerid))
    {
        for(new b=0; b<MAX_PLAYERS; b++)
        {
            if(IsPlayerNPC(b))
            {
                GetPlayerPos(b, X, Y, Z);
            }
        }
        SetPlayerPos(i, X, Y, Z);
        SendClientMessage(i, -1, "You arrived successfully");
        return 1;
    }
    else return SendClientMessage(playerid, -1, "You are not authorized to use that command!");
}
It should work.. and there's no need to loop through the players to make sure they're admin, playerid is already defined in the cmd.
Reply
#9

Quote:
Originally Posted by Youice
Посмотреть сообщение
I already made this before! but what happened is::

I receive this error::

Код:
error 017: undefined symbol "X"
lol : )

thats why I made this "public BotPos"
Look carefully, I didn't only change it to stock, I changed most of the things in the code.

Also I just saw you're LOOPING to find out if a player is admin...

pawn Код:
CMD:findbot(playerid, params[]) {
    if(!IsPlayerAdmin(i)) return 0; // Will return "Unknown Command" for non-admins.
    new Float:X, Float:Y, Float:Z;
    BotPos(X, Y, Z);
    SetPlayerPos(playerid, X, Y, Z);
    SendClientMessage(i, -1, "You arrived successfully");
    return 1;
}
Reply
#10

Quote:
Originally Posted by Mean
Посмотреть сообщение
Look carefully, I didn't only change it to stock, I changed most of the things in the code.
You also kept the un-wanted loop making a double loop which isn't needed.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)