Help - CreateVehicle ID
#3

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript

#define FILTERSCRIPT

#if defined FILTERSCRIPT

#include <a_samp>

new vehicle_spawn[MAX_PLAYERS];

public OnGameModeInit()
{
    for(new i = 0; i < MAX_PLAYERS; i++) // We restarted the variable of all players(0).
    {
        vehicle_spawn[i] = 0;
    }
    return 1;
}

public OnPlayerConnect(playerid) //When the player is ah connected must be in 0, because when you disconnect will destroy the last vehicle.
{
    vehicle_spawn[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason) //When you disconnect restarted its variable and destroy the last vehicle created.
{
    if(vehicle_spawn[playerid] != 0)
    {
        DestroyVehicle(vehicle_spawn[playerid]);
        vehicle_spawn[playerid] = 0;
    }
    return 1;
}

stock CreateVehicleEx(playerid, modelid) // With this feature we can create vehicles in all our indent usage CreateVehicleEx(playerid, modelid);
{
    new Float:pos[4]; // Create float 4 slots to obtain pos_x, pos_y, pos_z and GetVehicleZangle If you are in a vehicle the user.

    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) // obtain getplayerstate (if this driver)..
    {
        GetVehiclePos(GetPlayerVehicleID(playerid), pos[0], pos[1], pos[2]); // Obtain position in the floats.
        GetVehicleZAngle(GetPlayerVehicleID(playerid), pos[3]); // obtan angle vehicle.
        DestroyVehicle(GetPlayerVehicleID(playerid)); // Destroy last vehicle created and continue function.
    }
    else // if not this driver..
    {
        GetPlayerPos(playerid, pos[0], pos[1], pos[2]);  // obtain position in the floats.
        GetPlayerFacingAngle(playerid, pos[3]); // obtain angle playerid and continue function..
    }
    if(vehicle_spawn[playerid] != 0)
    {
        DestroyVehicle(vehicle_spawn[playerid]); // if variable is greater than 0 destroy the last vehicle created.
    }
    vehicle_spawn[playerid] = CreateVehicle(modelid, pos[0], pos[1], pos[2], pos[3], -1, -1, 60); // Create vehicle in pos obtain the floats.
    LinkVehicleToInterior(vehicle_spawn[playerid], GetPlayerInterior(playerid)); // Changes inside the vehicle to which the user is located.
    SetVehicleVirtualWorld(vehicle_spawn[playerid], GetPlayerVirtualWorld(playerid)); // Change the world the vehicle spawn to which you will find a player
    PutPlayerInVehicle(playerid, vehicle_spawn[playerid], 0); // The playerid enters the vehicle and driver.
    SetVehicleZAngle(vehicle_spawn[playerid], pos[3]); // Set angle te obtain float.
    return true;
}

#endif
Create Vehicle using:
pawn Код:
CreateVehicleEx(playerid, modelid);
Reply


Messages In This Thread
Help - CreateVehicle ID - by Hrb - 03.01.2015, 12:30
AW: Help - CreateVehicle ID - by CutX - 03.01.2015, 12:42
Re: Help - CreateVehicle ID - by JuanStone - 03.01.2015, 14:40

Forum Jump:


Users browsing this thread: 1 Guest(s)