is this right? -
thefatshizms - 06.06.2012
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?
Re: is this right? -
MadeMan - 06.06.2012
SetPlayerPos isn't good
https://sampwiki.blast.hk/wiki/SetPlayerPos
Re: is this right? -
JaKe Elite - 06.06.2012
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);
Re: is this right? -
XStormiest - 06.06.2012
Код:
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
Re: is this right? -
thefatshizms - 06.06.2012
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
Re: is this right? -
blewert - 06.06.2012
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;
}
Re: is this right? -
JaKe Elite - 06.06.2012
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.
Re: is this right? -
thefatshizms - 06.06.2012
thanks guys helped