Teleport question - 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: Teleport question (
/showthread.php?tid=499278)
Teleport question -
Djsoulhart - 07.03.2014
So, I've been pondering how to set up a code that allows me to teleport to another area while keeping the same car I found lying around.
I mean so far I have just the basic code:
PHP код:
if (strcmp("/lspd", cmdtext, true, 10) == 0)
{
SetPlayerPos(playerid, 1521.8848,-1670.7667,13.5469);
SendClientMessage(playerid, COLOR_WHITE, "Welcome to the local police station of Las Santos!");
return 1;
}
but that code will rip me from my car and place me on my feet in front of the PD.
Now, I've also been surfing the web to find a similar case with this but all the examples I seen surround a vehicle spawn system. That's not what I've been wanting.
I have it set up so there are random cars lying around the map that a player can go up to and get in/drive. But currently if they use a teleport command that I have set up it will rip them from their car..
Is there a way to check if a player is in a car and then teleport them to the desired location with that same car?
Re: Teleport question -
Stinged - 07.03.2014
Try this:
pawn Код:
if (strcmp("/lspd", cmdtext, true, 10) == 0)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vid = GetPlayerVehicleID(playerid);
SetVehiclePos(vehicleid, 1521.8848, -1670.7667, 13.5469);
SendClientMessage(playerid, COLOR_WHITE, "Welcome to the local police station of Las Santos!");
}
else
{
SetPlayerPos(playerid, 1521.8848,-1670.7667,13.5469);
SendClientMessage(playerid, COLOR_WHITE, "Welcome to the local police station of Las Santos!");
}
return 1;
}
Re: Teleport question -
Djsoulhart - 07.03.2014
Quote:
Originally Posted by Stinged
Try this:
pawn Код:
if (strcmp("/lspd", cmdtext, true, 10) == 0) { if(IsPlayerInAnyVehicle(playerid)) { new vid = GetPlayerVehicleID(playerid); SetVehiclePos(vehicleid, 1521.8848, -1670.7667, 13.5469); SendClientMessage(playerid, COLOR_WHITE, "Welcome to the local police station of Las Santos!"); } else { SetPlayerPos(playerid, 1521.8848,-1670.7667,13.5469); SendClientMessage(playerid, COLOR_WHITE, "Welcome to the local police station of Las Santos!"); } return 1; }
|
error 017: undefined symbol "vehicleid"
warning 204: symbol is assigned a value that is never used: "vid"
nvm, you typo'ed.
It should read this:
pawn Код:
if (strcmp("/lspd", cmdtext, true, 10) == 0)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vid = GetPlayerVehicleID(playerid);
SetVehiclePos(vid, 1521.8848, -1670.7667, 13.5469);
SendClientMessage(playerid, COLOR_WHITE, "Welcome to the local police station of Las Santos!");
}
else
{
SetPlayerPos(playerid, 1521.8848,-1670.7667,13.5469);
SendClientMessage(playerid, COLOR_WHITE, "Welcome to the local police station of Las Santos!");
}
return 1;
}
Now it works. Thank you kind person