Command Problem - 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: Command Problem (
/showthread.php?tid=327306)
Command Problem -
Chris' - 20.03.2012
pawn Код:
CMD:goto(playerid, params[])
{
new Float:pX,Float:pY,Float:pZ, id;
if(sscanf(params, "u", id)) SendClientMessage(playerid, LIGHTBLUE, "USAGE: {FFFFFF}/goto [playerid]");
else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, ORANGERED, "ERROR: Invalid PlayerID");
else
{
if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
GetPlayerPos(id,pX,pY,pZ);
SetVehiclePos(GetPlayerVehicleID(playerid),pX,pY,pZ+2);
}
else
{
GetPlayerPos(id,pX,pY,pZ);
SetPlayerPos(playerid,pX,pY,pZ+2);
}
SetPlayerInterior(playerid,GetPlayerInterior(id));
}
return 1;
}
I get no error from this code, but if i enter an invalid player id it doesent say Invalid PlayerID yet it teleports me somwhere in the map. I use zcmd and sscanf2 plugin for the command. Please help
Re: Command Problem -
Daddy Yankee - 20.03.2012
Try this
pawn Код:
CMD:goto(playerid, params[])
{
new Float:pX,Float:pY,Float:pZ, id;
if(sscanf(params, "u", id)) return SendClientMessage(playerid, LIGHTBLUE, "USAGE: {FFFFFF}/goto [playerid]");
else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, ORANGERED, "ERROR: Invalid PlayerID");
else
{
if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
GetPlayerPos(id,pX,pY,pZ);
SetVehiclePos(GetPlayerVehicleID(playerid),pX,pY,pZ+2);
}
else
{
GetPlayerPos(id,pX,pY,pZ);
SetPlayerPos(playerid,pX,pY,pZ+2);
}
SetPlayerInterior(playerid,GetPlayerInterior(id));
}
return 1;
}
Re: Command Problem -
Skribblez - 20.03.2012
edited your code and came up with this:
pawn Код:
cmd:goto(playerid, params[])
{
if(IsPlayerConnecteD(playerid))
{
new Float:pX, Float:pY, Float:pZ, id;
if(sscanf(params, "u", id)) return SendClientMessage(playerid, LIGHTBLUE, "USAGE: {FFFFFF}/goto [playerid]");
if(id != INVALID_PLAYER_ID)
{
GetPlayerPos(id, pX, pY, pZ);
new playerint = GetPlayerInterior(id);
new playerworld = GetPlayerVirtualWorld(id);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(GetPlayerVehicleID(playerid), pX, pY, pZ+2);
}
else
{
SetPlayerPos(playerid, pX, pY, pZ+);
}
SetPlayerInterior(playerid, playerint);
SetPlayerVirtualWorld(playerid, playerworld);
}
else SendClientMessage(playerid, ORANGERED, "ERROR: Invalid PlayerID");
}
return 1;
}
try it, i also added variables wherein it gets the target id's interior and virtual world.
Re: Command Problem -
Chris' - 20.03.2012
I dont know why, but for some reason this wont work, maybe somethings wrong with my script.
Re: Command Problem -
Skribblez - 20.03.2012
have you tried the code that i posted?
Re: Command Problem -
Chris' - 20.03.2012
Yes i have, it still teleports me to a random location if i type an invalid id.