/tp [id] 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /tp [id] Problem (
/showthread.php?tid=274235)
/tp [id] Problem -
XVK - 05.08.2011
pawn Код:
#include <a_samp>
new tmp[256];
new OtherID = strval(tmp);
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/tp", cmdtext, true, 6) == 0)
{
new tmp[256];
new OtherID = strval(tmp);
}
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /tp [id]");
if(!IsPlayerConnected(OtherID) || IsPlayerNPC(OtherID)) return SendClientMessage(playerid,0xFF0000FF,"The player is not online!");
new Float:X, Float:Y, Float:Z;
}
GetPlayerPos(OtherID, X, Y, Z);
}
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(GetPlayerVehicleID(playerid), X+5, Y+5, Z);
}
else
{
SetPlayerPos(playerid, X+5, Y+5, Z);
}
SendClientMessage(playerid, 0xFF0000FF, "You've been teleported to the requested player!");
return 1;
}
return 0;
}
It gives me this error "Windows has stopped working"
Re: /tp [id] Problem -
dr.pepper - 05.08.2011
All your brackets are wrongly positioned as for one thing.
Re: /tp [id] Problem -
Famalamalam - 05.08.2011
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/tp", cmdtext, true, 6) == 0)
{
new tmp[256];
new OtherID = strval(tmp);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /tp [id]");
if(!IsPlayerConnected(OtherID) || IsPlayerNPC(OtherID)) return SendClientMessage(playerid,0xFF0000FF,"The player is not online!");
new Float:X, Float:Y, Float:Z;
GetPlayerPos(OtherID, X, Y, Z);
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(GetPlayerVehicleID(playerid), X+5, Y+5, Z);
}
else
{
SetPlayerPos(playerid, X+5, Y+5, Z);
}
SendClientMessage(playerid, 0xFF0000FF, "You've been teleported to the requested player!");
return 1;
}
return 0;
}
This command won't do what you expect it to do anyway, what it will do is take you or your, and move it +5 degrees forwards. I suggest you use ZCMD and sscanf.
Re: /tp [id] Problem -
XVK - 05.08.2011
I give 5 dollars to the person who helps me do it!
Re: /tp [id] Problem -
Kingunit - 05.08.2011
pawn Код:
if(!strcmp(cmd, "/tp"))
{
{
new targetid, string[128];
if(sscanf(params, "uz", targetid)) return SendClientMessage(playerid, COLOR_WHITE, ""[CMD] / [PlayerID/PartOfName]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "[ERROR] Player not connected!");
else
{
new pName[24];
GetPlayerRame(targetid,pName,128);
format(string, sizeof(string), "You succesfully teleported to [%d] %s.",targetid, pName);
SendClientMessage(playerid,COLOR_RED,string);
SetPlayerInterior(playerid,GetPlayerInterior(targetid));
new Float:TPX, Float:TPY, Float:TPZ;
GetPlayerPos(targetid, TPX, TPY, TPZ);
SetPlayerPos(playerid, TPX, TPY, TPZ+1);
}
}
return 1;
}
Replace your command with this one. Works fine