05.04.2019, 17:57
Code:
Dialog_CreateBusSelType(playerid, response, listitem)
{
// Just close the dialog if the player clicked "Cancel"
if(!response) return 1;
// Setup some local variables
new BusType, BusID, Float:x, Float:y, Float:z, Msg[128], bool:EmptySlotFound = false;
// Get the player's position
GetPlayerPos(playerid, x, y, z);
// Get the business-type from the option the player chose
BusType = listitem + 1;
// Find a free business-id
for (BusID = 1; BusID < MAX_BUSINESS; BusID++)
{
// Check if this business ID is free
if (ABusinessData[BusID][BusinessType] == 0)
{
EmptySlotFound = true;
break; // Stop processing
}
}
// Check if an empty slot has been found
if (EmptySlotFound == false)
{
// If no empty slot was found, let the player know about it and exit the function
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Numero mбximo de empresas atingido");
return 1;
}
// Set some default data at the index of NextFreeBusinessID (NextFreeBusinessID will point to the next free business-index)
ABusinessData[BusID][BusinessX] = x;
ABusinessData[BusID][BusinessY] = y;
ABusinessData[BusID][BusinessZ] = z;
ABusinessData[BusID][BusinessType] = BusType;
ABusinessData[BusID][BusinessLevel] = 1;
ABusinessData[BusID][Owned] = false;
// Add the pickup and 3DText at the location of the business-entrance (where the player is standing when he creates the business)
Business_CreateEntrance(BusID);
// Save the business
BusinessFile_Save(BusID);
// Inform the player that he created a new house
format(Msg, 128, "{FFFFFF}Empresa criada com sucesso. ID: {ffffff}%i{FF0000}.", BusID);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
return 1;
}

