PHP код:
enum InfoVehicles
{
vehicle,
model,
world,
interior,
Float:x_,
Float:y_,
Float:z_,
Float:angel_,
vehicle1,
model1,
world1,
interior1,
Float:x_1,
Float:y_1,
Float:z_1,
Float:angel_1,
vehicle2,
model2,
world2,
interior2,
Float:x_2,
Float:y_2,
Float:z_2,
Float:angel_2,
vehicle3,
model3,
world3,
interior3,
Float:x_3,
Float:y_3,
Float:z_3,
Float:angel_3,
vehicle4,
model4,
world4,
interior4,
Float:x_4,
Float:y_4,
Float:z_4,
Float:angel_4,
};
new vInfo[MAX_PLAYERS][InfoVehicles];
public OnPlayerConnect(playerid)
{
if(fexist(FolderVehicles(playerid)))
{
inline loadvehicle(string:name[], string:value[])
{
INI_Int("model", vInfo[playerid][model]);
INI_Int("world", vInfo[playerid][world]);
INI_Int("interior", vInfo[playerid][interior]);
INI_Float("pos:x", vInfo[playerid][x_]);
INI_Float("pos:y", vInfo[playerid][y_]);
INI_Float("pos:z", vInfo[playerid][z_]);
INI_Float("angel:az", vInfo[playerid][angel_]);
INI_Int("model1", vInfo[playerid][model1]);
INI_Int("world1", vInfo[playerid][world1]);
INI_Int("interior1", vInfo[playerid][interior1]);
INI_Float("pos:x1", vInfo[playerid][x_1]);
INI_Float("pos:y1", vInfo[playerid][y_1]);
INI_Float("pos:z1", vInfo[playerid][z_1]);
INI_Float("angel:az1", vInfo[playerid][angel_1]);
INI_Int("model2", vInfo[playerid][model2]);
INI_Int("world2", vInfo[playerid][world2]);
INI_Int("interior2", vInfo[playerid][interior2]);
INI_Float("pos:x2", vInfo[playerid][x_2]);
INI_Float("pos:y2", vInfo[playerid][y_2]);
INI_Float("pos:z2", vInfo[playerid][z_2]);
INI_Float("angel:az2", vInfo[playerid][angel_2]);
INI_Int("model3", vInfo[playerid][model3]);
INI_Int("world3", vInfo[playerid][world3]);
INI_Int("interior3", vInfo[playerid][interior3]);
INI_Float("pos:x3", vInfo[playerid][x_3]);
INI_Float("pos:y3", vInfo[playerid][y_3]);
INI_Float("pos:z3", vInfo[playerid][z_3]);
INI_Float("angel:az3", vInfo[playerid][angel_3]);
INI_Int("model3", vInfo[playerid][model3]);
INI_Int("world3", vInfo[playerid][world3]);
INI_Int("interior3", vInfo[playerid][interior3]);
INI_Float("pos:x3", vInfo[playerid][x_3]);
INI_Float("pos:y3", vInfo[playerid][y_3]);
INI_Float("pos:z3", vInfo[playerid][z_3]);
INI_Float("angel:az3", vInfo[playerid][angel_3]);
INI_Int("model4", vInfo[playerid][model4]);
INI_Int("world4", vInfo[playerid][world4]);
INI_Int("interior4", vInfo[playerid][interior4]);
INI_Float("pos:x4", vInfo[playerid][x_4]);
INI_Float("pos:y4", vInfo[playerid][y_4]);
INI_Float("pos:z4", vInfo[playerid][z_4]);
INI_Float("angel:az4", vInfo[playerid][angel_4]);
}
INI_ParseFile(FolderVehicles(playerid), "loadvehicle");
vInfo[playerid][vehicle] = 1;
}
else if(!fexist(FolderVehicles(playerid)))
{
vInfo[playerid][vehicle] = 0;
}
return true;
}
public OnPlayerDisconnect(playerid, reason)
{
if(vInfo[playerid][vehicle] != 0)
{
new Float:pos[5];
GetVehiclePos(vInfo[playerid][vehicle], pos[0], pos[1], pos[2]);
GetVehicleZAngle(vInfo[playerid][vehicle], pos[4]);
PutPlayerInVehicle(playerid, vInfo[playerid][vehicle], 0);
new INI:File = INI_Open(FolderVehicles(playerid));
INI_SetTag(File, "Info vehicle");
INI_WriteInt(File, "model", vInfo[playerid][model]);
INI_WriteInt(File, "world", GetVehicleVirtualWorld(vInfo[playerid][vehicle]));
INI_WriteInt(File, "interior", GetPlayerInterior(playerid));
INI_WriteFloat(File, "pos:x", pos[0]);
INI_WriteFloat(File, "pos:y", pos[1]);
INI_WriteFloat(File, "pos:z", pos[2]);
INI_WriteFloat(File, "angel:az", pos[4]);
INI_SetTag(File, "Info vehicle");
INI_WriteInt(File, "model1", vInfo[playerid][model1]);
INI_WriteInt(File, "world1", GetVehicleVirtualWorld(vInfo[playerid][vehicle]));
INI_WriteInt(File, "interior1", GetPlayerInterior(playerid));
INI_WriteFloat(File, "pos:x1", pos[0]);
INI_WriteFloat(File, "pos:y1", pos[1]);
INI_WriteFloat(File, "pos:z1", pos[2]);
INI_WriteFloat(File, "angel:az1", pos[4]);
INI_SetTag(File, "Info vehicle");
INI_WriteInt(File, "model2", vInfo[playerid][model2]);
INI_WriteInt(File, "world2", GetVehicleVirtualWorld(vInfo[playerid][vehicle]));
INI_WriteInt(File, "interior2", GetPlayerInterior(playerid));
INI_WriteFloat(File, "pos:x2", pos[0]);
INI_WriteFloat(File, "pos:y2", pos[1]);
INI_WriteFloat(File, "pos:z2", pos[2]);
INI_WriteFloat(File, "angel:az2", pos[4]);
INI_SetTag(File, "Info vehicle");
INI_WriteInt(File, "model2", vInfo[playerid][model2]);
INI_WriteInt(File, "world2", GetVehicleVirtualWorld(vInfo[playerid][vehicle]));
INI_WriteInt(File, "interior2", GetPlayerInterior(playerid));
INI_WriteFloat(File, "pos:x2", pos[0]);
INI_WriteFloat(File, "pos:y2", pos[1]);
INI_WriteFloat(File, "pos:z2", pos[2]);
INI_WriteFloat(File, "angel:az2", pos[4]);
INI_SetTag(File, "Info vehicle");
INI_WriteInt(File, "model3", vInfo[playerid][model3]);
INI_WriteInt(File, "world3", GetVehicleVirtualWorld(vInfo[playerid][vehicle]));
INI_WriteInt(File, "interior3", GetPlayerInterior(playerid));
INI_WriteFloat(File, "pos:x3", pos[0]);
INI_WriteFloat(File, "pos:y3", pos[1]);
INI_WriteFloat(File, "pos:z3", pos[2]);
INI_WriteFloat(File, "angel:az3", pos[4]);
INI_SetTag(File, "Info vehicle");
INI_WriteInt(File, "model4", vInfo[playerid][model4]);
INI_WriteInt(File, "world4", GetVehicleVirtualWorld(vInfo[playerid][vehicle]));
INI_WriteInt(File, "interior4", GetPlayerInterior(playerid));
INI_WriteFloat(File, "pos:x4", pos[0]);
INI_WriteFloat(File, "pos:y4", pos[1]);
INI_WriteFloat(File, "pos:z4", pos[2]);
INI_WriteFloat(File, "angel:az4", pos[4]);
INI_Close(File);
//..
DestroyVehicle(vInfo[playerid][vehicle]);
}
return true;
}
public OnPlayerRequestSpawn(playerid)
{
if(vInfo[playerid][vehicle] != 0)
{
vInfo[playerid][vehicle] = CreateVehicle(vInfo[playerid][model], vInfo[playerid][x_], vInfo[playerid][y_], vInfo[playerid][z_],vInfo[playerid][angel_], 3, random(126), random(126), (60*60));
SetVehicleVirtualWorld(vInfo[playerid][vehicle], vInfo[playerid][world]);
LinkVehicleToInterior(vInfo[playerid][vehicle], vInfo[playerid][interior]);
vInfo[playerid][vehicle] = CreateVehicle(vInfo[playerid][model1], vInfo[playerid][x_1], vInfo[playerid][y_1], vInfo[playerid][z_1],vInfo[playerid][angel_1], 3, random(126), random(126), (60*60));
SetVehicleVirtualWorld(vInfo[playerid][vehicle], vInfo[playerid][world1]);
LinkVehicleToInterior(vInfo[playerid][vehicle], vInfo[playerid][interior1]);
vInfo[playerid][vehicle] = CreateVehicle(vInfo[playerid][model2], vInfo[playerid][x_2], vInfo[playerid][y_2], vInfo[playerid][z_2],vInfo[playerid][angel_2], 3, random(126), random(126), (60*60));
SetVehicleVirtualWorld(vInfo[playerid][vehicle], vInfo[playerid][world2]);
LinkVehicleToInterior(vInfo[playerid][vehicle], vInfo[playerid][interior2]);
vInfo[playerid][vehicle] = CreateVehicle(vInfo[playerid][model3], vInfo[playerid][x_3], vInfo[playerid][y_3], vInfo[playerid][z_3],vInfo[playerid][angel_3], 3, random(126), random(126), (60*60));
SetVehicleVirtualWorld(vInfo[playerid][vehicle], vInfo[playerid][world3]);
LinkVehicleToInterior(vInfo[playerid][vehicle], vInfo[playerid][interior3]);
vInfo[playerid][vehicle] = CreateVehicle(vInfo[playerid][model4], vInfo[playerid][x_4], vInfo[playerid][y_4], vInfo[playerid][z_4],vInfo[playerid][angel_4], 3, random(126), random(126), (60*60));
SetVehicleVirtualWorld(vInfo[playerid][vehicle], vInfo[playerid][world4]);
LinkVehicleToInterior(vInfo[playerid][vehicle], vInfo[playerid][interior4]);
}
return true;
}
FolderVehicles(playerid)
{
new string[80], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "/vehicles/%s.ini", name);
return string;
}