Disconnect destroy vehicle
#6

I think this will work way better for you (No strcmp/looping is needed)

PHP код:
enum carEnum{
    
id_x,
    
carowner[MAX_PLAYER_NAME], // Since you have this variable, only player-created vehicles will be used in this enum.
    
carmodelid,
    
Float:c_x,
    
Float:c_y,
    
Float:c_z,
    
Float:c_r,
    
c_color1,
    
c_color2,
    
c_respawntime,
    
cnitro,
    
paintjob,
    
plate,
    
c_autorespawn,
    
carteam,
    
db_id
};
new 
cInfo[MAX_PLAYERS][carEnum]; // Changed to MAX_PLAYERS. This enum is related to player-created vehicles, no vehicles created by the server. Right? 
I'm assuming you create the vehicle doing something like this (Triggered by the player). This is an example..

PHP код:
new Float:XFloat:YFloat:ZFloat:A;
GetPlayerPos(playeridXYZ);
GetPlayerFacingAngle(playeridA);
cInfo[playerid][id_x] = CreateVehicle(...) // We store the vehicle id on playerid -> id_x variable.
cInfo[playerid][carmodelid] = GetPlayerVehicleModelID(cInfo[playerid][id_x]); // Stuff..
cInfo[playerid][c_x] = X// Stuff..
cInfo[playerid][c_y] = Y// Stuff..
cInfo[playerid][c_z] = Z// More Stuff..
cInfo[playerid][c_r] = A// Etc.. 
Now the callbacks..

PHP код:
public OnPlayerConnect(playerid)
{
    
// Set id_x to -1.. (You should reset the entire enum to their original values when a player connects)
    
cInfo[playerid][id_x] = -1// We set it to -1, because what if the player creates a vehicles, when there is no other vehicle created yet?.
    // for(;;) cInfo[playerid][Enum_Variable] = DEFAULT_VALUE   ...
    
return 1;
}
// Player-created vehicle, no loop needed. Just a check if the vehicle has been created.
public OnPlayerDisconnect(playeridreason)
{
    
// You check if carteam is 255 so..
    
if(cInfo[playerid][carteam] == 255 && cInfo[playerid][id_x] >= 0DestroyVehicle(cInfo[playerid][id_x]);
    
    
// Then you must reset id_x.. (You should reset the entire enum to their original values, again)
    
cInfo[playerid][id_x] = -1;
    
    
// for(;;) cInfo[playerid][Enum_Variable] = DEFAULT_VALUE   ...
    
return 1;

Hope it helps.
Reply


Messages In This Thread
Disconnect destroy vehicle - by justjamie - 24.05.2016, 17:05
Re: Disconnect destroy vehicle - by ilijap - 24.05.2016, 17:09
Re: Disconnect destroy vehicle - by Dayrion - 24.05.2016, 17:12
Re: Disconnect destroy vehicle - by justjamie - 24.05.2016, 17:12
Re: Disconnect destroy vehicle - by justjamie - 24.05.2016, 17:51
Re: Disconnect destroy vehicle - by Jf - 24.05.2016, 19:04

Forum Jump:


Users browsing this thread: 3 Guest(s)