Hello everyone... There a problem... i need
Too if A Player leave server Remove His vehicles From Server.
And after connecting again Load To Him his Vehicles...
PHP код:
public OnPlayerConnect(playerid)
{
SetPVarInt(playerid, "xv_teklif_id", INVALID_PLAYER_ID);
SetPVarInt(playerid, "xv_teklif_gonderen", INVALID_PLAYER_ID);
LoadxVehicleKeys(playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(GetPVarInt(playerid, "xv_teklif_gonderen") != INVALID_PLAYER_ID)
{
new gonderen = GetPVarInt(playerid, "xv_teklif_gonderen");
KillTimer(offerTimer[playerid]);
SetPVarInt(gonderen, "xv_teklif_id", INVALID_PLAYER_ID);
SendClientMessage(gonderen, -1, "{FF0000}[ERROR]:- {DCDC22}Your vehicle offer has cancelled because of the player that you offered has disconnected.");
}
if(GetPVarInt(playerid, "xv_teklif_id") != INVALID_PLAYER_ID)
{
new alan = GetPVarInt(playerid, "xv_teklif_id");
SetPVarInt(alan, "xv_teklif_gonderen", INVALID_PLAYER_ID);
DeletePVar(alan, "xv_teklif_xid");
DeletePVar(alan, "xv_teklif_fiyat");
KillTimer(offerTimer[alan]);
SendClientMessage(alan, -1, "{FF0000}[ERROR]:- {DCDC22}The offer has cancelled because of the player that make the offer has disconnected.");
}
if(IsPlayerInAnyVehicle(playerid))
{
new xid = xVeh[GetPlayerVehicleID(playerid)], Float:xvHP;
GetVehicleHealth(GetPlayerVehicleID(playerid), xvHP);
if(xid != 0 && xVehicle[xid][xv_HizliPark] == 1 && !IsVehicleFlipped(GetPlayerVehicleID(playerid)) && xvHP > 300)
{
GetVehiclePos(GetPlayerVehicleID(playerid), xVehicle[xid][xv_Pos][0], xVehicle[xid][xv_Pos][1], xVehicle[xid][xv_Pos][2]);
GetVehicleZAngle(GetPlayerVehicleID(playerid), xVehicle[xid][xv_Pos][3]);
SavexVehicle(xid);
}
}
return 1;
}
Код:
public LoadxVehicles()
{
new rows = cache_num_rows();
new id, loaded;
if(rows)
{
while(loaded < rows)
{
cache_get_value_name_int(loaded, "ID", id);
cache_get_value_name(loaded, "Sahip", xVehicle[id][xv_Sahip], MAX_PLAYER_NAME);
cache_get_value_name_int(loaded, "Fiyat", xVehicle[id][xv_Fiyat]);
cache_get_value_name_float(loaded, "X", xVehicle[id][xv_Pos][0]);
cache_get_value_name_float(loaded, "Y", xVehicle[id][xv_Pos][1]);
cache_get_value_name_float(loaded, "Z", xVehicle[id][xv_Pos][2]);
cache_get_value_name_float(loaded, "A", xVehicle[id][xv_Pos][3]);
cache_get_value_name_int(loaded, "HizliPark", xVehicle[id][xv_HizliPark]);
cache_get_value_name_int(loaded, "Model", xVehicle[id][xv_ModelID]);
cache_get_value_name_int(loaded, "Renk1", xVehicle[id][xv_Renk][0]);
cache_get_value_name_int(loaded, "Renk2", xVehicle[id][xv_Renk][1]);
cache_get_value_name(loaded, "Plaka", xVehicle[id][xv_Plaka], 8);
cache_get_value_name_int(loaded, "Garajda", xVehicle[id][xv_Garajda]);
cache_get_value_name_int(loaded, "PJ", xVehicle[id][xv_Paintjob]);
cache_get_value_name_int(loaded, "Parca1", xVehicle[id][xv_Parca][0]);
cache_get_value_name_int(loaded, "Parca2", xVehicle[id][xv_Parca][1]);
cache_get_value_name_int(loaded, "Parca3", xVehicle[id][xv_Parca][2]);
cache_get_value_name_int(loaded, "Parca4", xVehicle[id][xv_Parca][3]);
cache_get_value_name_int(loaded, "Parca5", xVehicle[id][xv_Parca][4]);
cache_get_value_name_int(loaded, "Parca6", xVehicle[id][xv_Parca][5]);
cache_get_value_name_int(loaded, "Parca7", xVehicle[id][xv_Parca][6]);
cache_get_value_name_int(loaded, "Parca8", xVehicle[id][xv_Parca][7]);
cache_get_value_name_int(loaded, "Parca9", xVehicle[id][xv_Parca][8]);
cache_get_value_name_int(loaded, "Parca10", xVehicle[id][xv_Parca][9]);
cache_get_value_name_int(loaded, "Parca11", xVehicle[id][xv_Parca][10]);
cache_get_value_name_int(loaded, "Parca12", xVehicle[id][xv_Parca][11]);
cache_get_value_name_int(loaded, "Parca13", xVehicle[id][xv_Parca][12]);
cache_get_value_name_int(loaded, "Parca14", xVehicle[id][xv_Parca][13]);
if(!xVehicle[id][xv_Garajda])
{
xVehicle[id][xv_Veh] = CreateVehicle(xVehicle[id][xv_ModelID], xVehicle[id][xv_Pos][0], xVehicle[id][xv_Pos][1], xVehicle[id][xv_Pos][2], xVehicle[id][xv_Pos][3], xVehicle[id][xv_Renk][0], xVehicle[id][xv_Renk][1], -1);
xVeh[xVehicle[id][xv_Veh]] = id;
SetVehicleNumberPlate(xVehicle[id][xv_Veh], xVehicle[id][xv_Plaka]);
SetVehicleToRespawn(xVehicle[id][xv_Veh]);
}
Iter_Add(xVehicles, id);
loaded++;
if(!strlen(xVehicle[id][xv_Sahip]))
{
new str[150];
format(str, sizeof(str), "{FF0000}This Vehicle Is For Sale!\n{FF0000}Vehicle Name: {04FF00}%s\n{FF0000}Plate Number: {04FF00}%s\n{FF0000}Price: {04FF00}$%d", GetVehicleNameFromModel(xVehicle[id][xv_ModelID]), xVehicle[id][xv_Plaka], xVehicle[id][xv_Fiyat]);
xVehicle[id][xv_Text] = Create3DTextLabel(str, 0x008080FF, 0.0, 0.0, 0.0, 15.0, 0);
Attach3DTextLabelToVehicle(xVehicle[id][xv_Text], xVehicle[id][xv_Veh], 0.0, 0.0, 1.0);
SendClientMessage(id, -1, "{FF0000}[ERROR]{0098FF}:- You Dont have Keys This car.{FFFFFF}.");
}
else
{
new str[150];
format(str, sizeof(str), "{FF0000}Vehicle By: {8B8B8B}%s", xVehicle[id][xv_Sahip]);
xVehicle[id][xv_Text] = Create3DTextLabel ( str, 0xFF0000FF, 0.0, 0.0, 0.0, 15.0, 0, 1 );
Attach3DTextLabelToVehicle ( xVehicle[id][xv_Text], xVehicle[id][xv_Veh], 0.0, 0.0, 0.0 );
}
}
}
printf("[xVehicle] %d vehicle loaded.", loaded);
return 1;
}
hello.. man i want only if player disconnect his vehicles Removed and after connecting his vehicles Load.
EDITED:- I Just needed if player disconenct from server And After Connecting Load to him Vehicles Owned. in same park.