How to do this?
#1

Hello guys, today I created a teleport, just wondered how to teleport to a place with your vehicle? My script is just teleporting without cars.

pawn Код:
if (strcmp("/beach", cmdtext, true, 10) == 0)
    {
        SetPlayerPos(playerid, 309.7616,-1798.7969,4.4990);
        SendClientMessage(playerid, 0x00FF00, "Welcome to Los Santo Beach");
        new name[MAX_PLAYER_NAME+1], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format (string, sizeof(string), "[TP]: %s has teleported to /beach.", name);
        SendClientMessageToAll (0x0000BBAA, string);
        return 1;
    }
I need some pros to teach me.
Reply
#2

pawn Код:
if (strcmp("/beach", cmdtext, true, 10) == 0)
    {
        SetPlayerPos(playerid, 309.7616,-1798.7969,4.4990);
        SendClientMessage(playerid, 0x00FF00, "Welcome to Los Santo Beach");
        new name[MAX_PLAYER_NAME+1], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format (string, sizeof(string), "[TP]: %s has teleported to /beach.", name);
        SendClientMessageToAll (0x0000BBAA, string);
        if(IsPlayerInAnyVehicle(playerid) &&  GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
         v = GetPlayerVehicleID(playerid);
         SetVehiclePos(v, 309.7616,-1798.7969,4.4990);
         PutPlayerInVehicle(playerid, v, 0);
        }
        return 1;
    }
// if its the drive :D
Reply
#3

Explained at the comments.

pawn Код:
if (strcmp("/beach", cmdtext, true, 10) == 0)
{
    if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER) // The player is a driver of a vehicle!
    {
        new iVeh = GetPlayerVehicleID(playerid); // Get's the player's current vehicle ID.
        SetVehiclePos(iVeh, 309.7616, -1798.7969, 4.4990); // Set's the vehicle's position.
    }
   
    else // The player is not a driver of a vehicle!
    {
        SetPlayerPos(playerid, 309.7616, -1798.7969, 4.4990); // Set's the player's current position
    }
   
    // Sends the player a client message
    SendClientMessage(playerid, 0x00FF00, "Welcome to Los Santos Beach!");
   
    new name[MAX_PLAYER_NAME], string[128]; // Create 2 new variables.
    GetPlayerName(playerid, name, sizeof(name)); // Get's the player's name.
   
    format(string, sizeof(string), "[TP]: %s has teleported to /beach.", name); // Formats the string.
    SendClientMessageToAll(0x0000BBAA, string); // Sends a message to all players
   
    return true;
}
Reply
#4

Thanks, I'll give a +1 rep to greentarch as it works for me.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)