05.05.2015, 11:02
Create an array for the player:
PHP код:
#define MAX_PLAYER_OWNED_VEHICLES 2 // edit to how much vehicles a player can own
#define DIALOG_PLAYER_VEHICLES 587 // change it if it collides
// global:
new Player_OwnedVehicles[MAX_PLAYER_OWNED_VEHICLES][MAX_PLAYERS];
// OnPlayerConnect:
for (new i; i != MAX_PLAYER_OWNED_VEHICLES; ++i)
{
Player_OwnedVehicles[i][playerid] = INVALID_VEHICLE_ID;
}
// When creating the vehicle:
new bool: full = true;
for (new i; i != MAX_PLAYER_OWNED_VEHICLES; ++i)
{
if (GetVehicleModel(Player_OwnedVehicles[i][playerid])) continue; // vehicle exists
Player_OwnedVehicles[i][playerid] = CreateVehicle(...); // modify it
full = false;
}
if (full) return SendClientMessage(playerid, -1, "No more slots available");
// when you want to show the vehicles:
new veh_string[50]; // if you increase the slots, make sure the string is enough
for (new i; i != MAX_PLAYER_OWNED_VEHICLES; ++i)
{
if (!GetVehicleModel(Player_OwnedVehicles[i][playerid])) continue;
format(veh_string, sizeof (veh_string), "%s%i) Vehicle ID: %i & Model ID: %i\n", veh_string, i + 1, Player_OwnedVehicles[i][playerid], GetVehicleModel(Player_OwnedVehicles[i][playerid]));
}
ShowPlayerDialog(playerid, DIALOG_PLAYER_VEHICLES, DIALOG_STYLE_MSGBOX, "Owned Vehicles", veh_string, "Close", "");