Dialog_Car(playerid, response, listitem)
{
// Just close the dialog if the player clicked "Cancel"
if(!response)
{
// Reset the FirstCar (so the list won't start at an unexpected location in the list, but back at the start of the list)
APlayerData[playerid][DialogCarFirstCar] = 0;
return 1; // Exit the function
}
// Process the selected listitem
switch (listitem)
{
case 10: // Player chooses the empty line between the carlist and "Next...", so refresh the current list
{
// Refresh the current list of cars and let the player choose one (show dialog)
CarList_Create(playerid);
// Exit the function
return 1;
}
case 11: // Player chooses "Next..."
{
// Add 10 to the FirstCar, so the list will start further down the array (will show the next 10 cars)
APlayerData[playerid][DialogCarFirstCar] = APlayerData[playerid][DialogCarFirstCar] + 10;
// Create a new list of cars and show the dialog
CarList_Create(playerid);
}
default: // Player chooses a car
{
// Setup local variables
new Float
, Float:y, Float:z, Float:rot, CarIndex, msg[128], vID;
new engine,lights,alarm,doors,bonnet,boot,objective;
// FirstCar is the index of the first car in the list, so select the proper index when a car is chosen by the player
CarIndex = APlayerData[playerid][DialogCarFirstCar] + listitem;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, rot);
vID = Vehicle_Create(ACars[CarIndex][CarModel], x, y, z, rot, random(126), random(126), 600);
// Put the player in the vehicle
PutPlayerInVehicle(playerid, vID, 0);
// Turn on the engine and lights
GetVehicleParamsEx(vID, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vID, 1, 1, alarm, doors, bonnet, boot, objective);
// Store the player's current location and interior-id, otherwise anti-airbreak hack code could kick you
GetPlayerPos(playerid, APlayerData[playerid][PreviousX], APlayerData[playerid][PreviousY], APlayerData[playerid][PreviousZ]);
APlayerData[playerid][PreviousInt] = GetPlayerInterior(playerid);
// Inform all players about it
if(APlayerData[playerid][DJLevel] == 2)
{
format(msg, 128, "{FFD700}O VIP {FFFFFF}%s {FFD700}criou um(a) {FFFFFF}%s{FFD700}.", rNome(playerid), Vehicles[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
SendClientMessageToAll(-1, msg);
}
if(APlayerData[playerid][PlayerLevel] == 1)
{
format(msg, 128, "{FFD700}O VIP {FFFFFF}%s {FFD700}criou um(a) {FFFFFF}%s{FFD700}.", rNome(playerid), Vehicles[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
SendClientMessageToAll(-1, msg);
}
if(APlayerData[playerid][PlayerLevel] >= 2)
{
format(msg, 128, "{32CD32}O Administrador {FFFFFF}%s {32CD32}criou um(a) {FFFFFF}%s{32CD32}.", rNome(playerid), Vehicles[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
SendClientMessageToAll(-1, msg);
}
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(PlayerInfo[p][NoEvento] == 1)
{
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, rot);
vID = Vehicle_Create(ACars[CarIndex][CarModel], x, y, z, rot, random(126), random(126), 600);
// Put the player in the vehicle
PutPlayerInVehicle(playerid, vID, 0);
// Turn on the engine and lights
GetVehicleParamsEx(vID, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vID, 1, 1, alarm, doors, bonnet, boot, objective);
LinkVehicleToInterior(vID, EventInfo[Interior]);
SetVehicleVirtualWorld(vID, EventInfo[VirtualWorld]);
PutPlayerInVehicle(p, vID, 0);
PlayerInfo[p][Carro] = vID;
}
}
// Also, after spawning a vehicle, reset FirstCar (so next time, the list starts from the start)
APlayerData[playerid][DialogCarFirstCar] = 0;
}
}
return 1;
}