[Help] Mixing vehicles ID
#1

Hello, i dont know what im doing wrong, vehicles ID get mixed by other vehicles and everything get's f*** up...

On creating vehicle (loading)

I'm doing

PHP код:
CInfo[i][SpawnID] = CreateVehicle.... 
On every destroy im using

PHP код:
DestroyVehicle(CInfo[vehid][SpawnID]);
CInfo[vehid][SpawnID] = INVALID_VEHICLE_ID
Reply
#2

Quote:
Originally Posted by Lokii
Посмотреть сообщение
replace urs with mine:

PHP код:
#include <a_samp>
new p_veh[MAX_PLAYERS];
new 
bool:veh_exists[MAX_PLAYERS];
CreateVehicleEx(playeridvehicleidcolor1color2respawn_delayaddsiren)
{
    new 
Float:xFloat:yFloat:zFloat:za;
    
PutPlayerInVehicle(playeridp_veh[playerid], 0);
    
GetPlayerPos(playeridxyz);
    
GetPlayerFacingAngle(playeridza);
       
DestroyVehicleEx(playerid);
    return 
p_veh[playerid] = CreateVehicle(vehicleidxyzzacolor1color2respawn_delayaddsiren);
}
DestroyVehicleEx(playerid)
{
    if(
IsVehicleExistsEx(playerid))
    {
         
DestroyVehicle(p_veh[playerid]);
         
p_veh[playerid] = INVALID_VEHICLE_ID;
    }
    return 
1;
}
IsVehicleExistsEx(playerid)
{
    if(!
veh_exists[playerid]) return 0;
    return 
1;
}
public 
OnFilterScriptExit()
{
    for(new 
0MAX_VEHICLES++)
    {
        if(!
IsVehicleExistsEx(i)) continue;
        
DestroyVehicleEx(i);
    }
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
DestroyVehicleEx(playerid);
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    
DestroyVehicleEx(playerid);
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    new 
Float:hp;
    if(
IsVehicleExistsEx(playerid))
    {
        if(
GetVehicleHealth(p_veh[playerid], hp) < 251)
        {
            
DestroyVehicle(p_veh[playerid]);
        }
    }
    return 
1;

I have ownership for Vehicles,Bikes,Motorbikes,Aero,yacht... this is not answer what im looking for.
Reply
#3

i'm using vehicle id's for index, and foreach. it's working well so far

i mean:
Код:
new vehicleid = CreateVehicle(...);
if(!Iter_Contains(Vehicles, vehicleid)
{
    Iter_Add(Vehicles, vehicleid);
}
Код:
new vehicleid = GetPlayerVehicleID(playerid);
if(Vehicle[vehicleid][vType] == VEHICLE_TYPE_MISSION)
{
    ....
}
but you have to skip index 0
Reply
#4

Why are you getting a variable for a vehicle if you can just destroy the vehicle itself by using DestroyVehicle(vehicleid); ?
Reply
#5

Help... need some advanced helper.. here..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)