27.12.2014, 21:54
Pretty easy to do this just make an enum to store all your vehicle data you can use variables but I prefer it this way because it keeps your data grouped and makes it easy to add more if you need to.
// enum variable example
That should give you an idea of what to do.
// enum variable example
pawn Код:
enum VINFO
{
Text3D:v_Text, // Text label
v_OwnerID, // OwnerID of the vehicle
bool:v_Used // Marks if used
}
new VehicleData[MAX_VEHICLES][VINFO];
pawn Код:
// Destroy vehicle when player disconnects
public OnPlayerDisconnect(playerid, reason)
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(VehicleData[i][v_Used] && VehicleData[i][v_OwnerID] == playerid)
{
DestroyVehicle(i);
Delete3DTextLabel(VehicleData[i][v_OwnerID]);
VehicleData[i][v_OwnerID] = false;
}
}
}
pawn Код:
// Add a new vehicle also creates and attaches 3D Text label.
AddVehicle(ownerid, modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay, Float:offsetx, Float:offsety, Float:offsetz, text[], color, virtualworld = 0, Float:DrawDistance = 100.0, testLOS, = 1)
{
vid = CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
if(vid == INVALID_VEHICLE_ID) return INVALID_VEHICLE_ID;
VehicleData[vid][v_OwnerID] = ownerid;
VehicleData[vid][v_Used] = true;
VehicleData[vid][v_Text] = Create3DTextLabel(text, color, 0.0, 0.0, 0.0, DrawDistance, virtualworld, testLOS);
Attach3DTextLabelToVehicle(VehicleData[vid][v_Text], vid, offsetx, offsety, offsetz);
return vid;
}