[Help] Mixing vehicles ID - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help] Mixing vehicles ID (
/showthread.php?tid=651295)
[Help] Mixing vehicles ID -
David (Sabljak) - 17.03.2018
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;
Re: [Help] Mixing vehicles ID -
David (Sabljak) - 17.03.2018
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(playerid, vehicleid, color1, color2, respawn_delay, addsiren)
{
new Float:x, Float:y, Float:z, Float:za;
PutPlayerInVehicle(playerid, p_veh[playerid], 0);
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, za);
DestroyVehicleEx(playerid);
return p_veh[playerid] = CreateVehicle(vehicleid, x, y, z, za, color1, color2, respawn_delay, addsiren);
}
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 i = 0; i < MAX_VEHICLES; i ++)
{
if(!IsVehicleExistsEx(i)) continue;
DestroyVehicleEx(i);
}
return 1;
}
public OnPlayerConnect(playerid)
{
DestroyVehicleEx(playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
DestroyVehicleEx(playerid);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
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.
Re: [Help] Mixing vehicles ID -
m4karow - 17.03.2018
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
Re: [Help] Mixing vehicles ID -
m1kas - 17.03.2018
Why are you getting a variable for a vehicle if you can just destroy the vehicle itself by using DestroyVehicle(vehicleid); ?
Re: [Help] Mixing vehicles ID -
David (Sabljak) - 19.03.2018
Help... need some advanced helper.. here..