Vehicle ID
#1

hi all...

i have a little bit bug here... i want to make a vehicle spawner, and when i test it alone, it's work fine.
but when i try it with some of my friends, it's got bugged. What i want is destroy previouse player's spawned vehicle. but it's destroy my friend's vehicle can somebody help me?

pawn Code:
//
if(IsPlayerInAnyVehicle(playerid))
    {
        new vid = GetPlayerVehicleID(playerid);
        DestroyVehicle(vid);
        if(VehicleSpawn[playerid]==0)
        {
            new Float:x,Float:y,Float:z,Float:a;
            GetPlayerPos(playerid,x,y,z);
            GetPlayerFacingAngle(playerid,a);
            DestroyVehicle(pInfo[playerid][pSpawnVehicle]);
            pInfo[playerid][pSpawnVehicle] = AddStaticVehicle(model, x, y, z+1, a, -1, -1);
            PutPlayerInVehicle(playerid, pInfo[playerid][pSpawnVehicle], 0);
            SetVehicleHealth(pInfo[playerid][pSpawnVehicle],  1000.0);
            LinkVehicleToInterior(pInfo[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
        }
    }
Reply
#2

I guess AddStaticvehicle only works under GameModeInit.
AddStaticVehicle
Reply
#3

is this under a command?
Reply
#4

Quote:
Originally Posted by BroZeus
View Post
is this under a command?
no
this is the full script

pawn Code:
public VehicleSpawner(playerid,model)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vid = GetPlayerVehicleID(playerid);
        DestroyVehicle(vid);
        if(VehicleSpawn[playerid]==0)
        {
            new Float:x,Float:y,Float:z,Float:a;
            GetPlayerPos(playerid,x,y,z);
            GetPlayerFacingAngle(playerid,a);
            DestroyVehicle(pInfo[playerid][pSpawnVehicle]);
            pInfo[playerid][pSpawnVehicle] = AddStaticVehicleEx(model, x, y, z+1, a, -1, -1, -1);
            PutPlayerInVehicle(playerid, pInfo[playerid][pSpawnVehicle], 0);
            SetVehicleHealth(pInfo[playerid][pSpawnVehicle],  1000.0);
            LinkVehicleToInterior(pInfo[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
        }
    }
    else
    {
        if(VehicleSpawn[playerid]==0)
        {
            new Float:x,Float:y,Float:z,Float:a;
            GetPlayerPos(playerid,x,y,z);
            GetPlayerFacingAngle(playerid,a);
            DestroyVehicle(pInfo[playerid][pSpawnVehicle]);
            pInfo[playerid][pSpawnVehicle] = AddStaticVehicleEx(model, x, y, z+1, a, -1, -1, -1);
            PutPlayerInVehicle(playerid, pInfo[playerid][pSpawnVehicle], 0);
            SetVehicleHealth(pInfo[playerid][pSpawnVehicle],  1000.0);
            LinkVehicleToInterior(pInfo[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
        }
    }
    return 1;
}
Reply
#5

Maybe make it out of stock?
Reply
#6

were u in ur friend's vehicle
or
your friend was in your vehicle when u tried that?
Reply
#7

Quote:
Originally Posted by BroZeus
View Post
were u in ur friend's vehicle
or
your friend was in your vehicle when u tried that?
no, my friend is in another vehicle,, when i use the command to spawn the vehicle, his vehicle gone.
Reply
#8

sorry for bumping, but i still have this bug can somebody help me?
Reply
#9

I don't know where you're using VehicleSpawner, but this should work:
pawn Code:
public VehicleSpawner(playerid, model)
{
    if(!VehicleSpawn[playerid]) //Dunno what this means, but oh well.
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new vid = GetPlayerVehicleID(playerid);
            if(vid) SetVehicleToRespawn(vid);
        }
        new Float:x, Float:y, Float:z, Float:a;
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, a);
        if(pInfo[playerid][pSpawnVehicle] != INVALID_VEHICLE_ID)
        {
            DestroyVehicle(pInfo[playerid][pSpawnVehicle]);
            pInfo[playerid][pSpawnVehicle] = INVALID_VEHICLE_ID;
        }
        pInfo[playerid][pSpawnVehicle] = CreateVehicle(model, x, y, z + 1, a, -1, -1, -1);
        PutPlayerInVehicle(playerid, pInfo[playerid][pSpawnVehicle], 0);
        LinkVehicleToInterior(pInfo[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
        return pInfo[playerid][pSpawnVehicle];
    }
    return INVALID_VEHICLE_ID;
}
Reply
#10

Quote:
Originally Posted by BenzoAMG
View Post
I don't know where you're using VehicleSpawner, but this should work:
pawn Code:
public VehicleSpawner(playerid, model)
{
    if(!VehicleSpawn[playerid]) //Dunno what this means, but oh well.
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new vid = GetPlayerVehicleID(playerid);
            if(vid) SetVehicleToRespawn(vid);
        }
        new Float:x, Float:y, Float:z, Float:a;
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, a);
        if(pInfo[playerid][pSpawnVehicle] != INVALID_VEHICLE_ID)
        {
            DestroyVehicle(pInfo[playerid][pSpawnVehicle]);
            pInfo[playerid][pSpawnVehicle] = INVALID_VEHICLE_ID;
        }
        pInfo[playerid][pSpawnVehicle] = CreateVehicle(model, x, y, z + 1, a, -1, -1, -1);
        PutPlayerInVehicle(playerid, pInfo[playerid][pSpawnVehicle], 0);
        LinkVehicleToInterior(pInfo[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
        return pInfo[playerid][pSpawnVehicle];
    }
    return INVALID_VEHICLE_ID;
}
yeah, i think it will work, by reading the code...
going to test it

EDIT:
it's work! thanks BenzoAMG and +REP
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)