is this right?
#1

pawn Код:
CMD:goto(playerid, params[])
{
    new id;
    new Float:X, Float:Y, Float:Z;
    if(sscanf(params,"u",id)) return SendClientMessage(playerid, -1, "USAGE: /goto [id]");
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerPos(id, X, Y, Z);
    SetPlayerPos(playerid, id);
    return 1;
}
you can guess what its supposed to do, would it work?
Reply
#2

SetPlayerPos isn't good

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

no it will not work, you see.
you will get an error/warning already in this part

pawn Код:
SetPlayerPos(playerid, id);
it must be

pawn Код:
SetPlayerPos(playerid, X, Y, Z);
Reply
#4

Код:
CMD:goto(playerid, params[])
{
    new id;
    new Float:X, Float:Y, Float:Z;
          new carid;
         new interior;
              interior = GetPlayerInterior(id);
        carid = GetPlayerVehiclelID(playerid);
    new Float:rX, Float:rY, Float:rZ;
    if(sscanf(params,"u",id)) return SendClientMessage(playerid, -1, "USAGE: /goto [id]");
       if(id == playerid) return SendClientMessage(playerid,COLOR_RED,"You can't teleport to yourself!"):
         if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"This id is invalid");
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerPos(id, rX, rY, rZ);
                  SetPlayerPos(playerid,rX,rY,rZ);
                if( IsPlayerInAnyVehicle(id) )
                  {
                                  SetPlayerPos(playerid,rX,rY,rZ);
                                       SetPlayerInterior(playerid,interior);
                              PutPlayerInVehicle(playerid,carid,1);
                  }
    return 1;
}
i think this will be usefull
Reply
#5

Quote:
Originally Posted by Romel
Посмотреть сообщение
no it will not work, you see.
you will get an error/warning already in this part

pawn Код:
SetPlayerPos(playerid, id);
it must be

pawn Код:
SetPlayerPos(playerid, X, Y, Z);
but how would that send to the "id" as it could just send you to yourself
Reply
#6

Quote:
Originally Posted by thefatshizms
Посмотреть сообщение
pawn Код:
CMD:goto(playerid, params[])
{
    new id;
    new Float:X, Float:Y, Float:Z;
    if(sscanf(params,"u",id)) return SendClientMessage(playerid, -1, "USAGE: /goto [id]");
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerPos(id, X, Y, Z);
    SetPlayerPos(playerid, id);
    return 1;
}
you can guess what its supposed to do, would it work?
Like everyone else said, no. SetPlayerPos takes in x, y and z variables to set position to, not player ids.

Also, I don't see the point in this line:

pawn Код:
GetPlayerPos(playerid, X, Y, Z);
A line later, you overwrite it with the position of the target id - you never need the player's position anyways.

Try this, this should be ok:

pawn Код:
CMD:goto(playerid, params[])
{
    //Target id:
    new id;

    //Variables for target id's position:
    new Float:X, Float:Y, Float:Z;

    if(sscanf(params,"u",id)) return SendClientMessage(playerid, -1, "USAGE: /goto [id]");

    //Get position of target id:
    GetPlayerPos(id, X, Y, Z);

    //Set player's position to their position.
    SetPlayerPos(playerid, X, Y, Z);
    //..

    return 1;
}
Reply
#7

you see you already get the player pos of the targetid
so you just need to set playerid pos to x, y, z
the x, y, z is the targetid position.
Reply
#8

thanks guys helped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)