Teleport question
#1

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"cmdtexttrue10) == 0)
        {
            
SetPlayerPos(playerid1521.8848,-1670.7667,13.5469);
            
SendClientMessage(playeridCOLOR_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?
Reply
#2

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;
}
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)