16.02.2017, 16:34
(
Последний раз редактировалось Banditul18; 16.02.2017 в 17:43.
)
I have a problem, i try to convert the PPC Trucking v1 to MySQL to learn and whatever....
But at business system i have a problem , imediatly after i create a business i can't buy it at all, only after a restart....
Creating:
Buybus:
I can't figure out how to make it to work....When i type /buybus nothing happens...
But at business system i have a problem , imediatly after i create a business i can't buy it at all, only after a restart....
Creating:
PHP код:
// This dialog processes the chosen business-type and creates the business
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, bool:EmptySlotFound = false,query[240];
// 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}Maximum number of businesses reached");
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] = 0;
mysql_format(g_SQL, query, sizeof(query), "INSERT INTO `business` (`BusinessX`,`BusinessY`, `BusinessZ`, `BusinessType`,`BusinessLevel` ,`Owned`) VALUES (%f,%f,%f,%i,%i,%i)",ABusinessData[BusID][BusinessX],ABusinessData[BusID][BusinessY],ABusinessData[BusID][BusinessZ],ABusinessData[BusID][BusinessType],ABusinessData[BusID][BusinessLevel],ABusinessData[BusID][Owned]);
mysql_tquery(g_SQL, query, "InsertIDBus","ii",BusID,playerid);
// 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);
// Inform the player that he created a new house
return 1;
}
forward InsertIDBus(BusID,playerid);
public InsertIDBus(BusID,playerid)
{
ABusinessData[BusID][BusIDD] = cache_insert_id(g_SQL);
new Msg[64];
format(Msg, sizeof(Msg), "You've succesfully created business %i", ABusinessData[BusID][BusIDD]);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
return 1;
}
PHP код:
// This command lets the player buy a business when he's standing in range of a business that isn't owned yet
CMD:buybus(playerid, params[])
{
// Setup local variables
new Msg[128], BusType;
// Send the command to all admins so they can see it
SendAdminText(playerid, "/buybus", params);
// Make sure the player isn't inside a vehicle
if (GetPlayerVehicleID(playerid) == 0)
{
// Check if the player is near a business-pickup
for (new i = 0; i < MAX_BUSINESS; i++)
{
// Check if this business is created (it would have a valid pickup in front of the door)
if (ABusinessData[i][PickupID] != 0)
{
// Check if the player is in range of the business-pickup
if (IsPlayerInRangeOfPoint(playerid, 2.5, ABusinessData[i][BusinessX], ABusinessData[i][BusinessY], ABusinessData[i][BusinessZ]))
{
// Check if the business isn't owned yet
if (ABusinessData[i][Owned] == 0)
{
// Get the type of business
BusType = ABusinessData[i][BusinessType];
// Check if the player can afford this type of business business
if (APlayerData[playerid][PlayerMoney] >= ABusinessInteriors[BusType][BusPrice])
Business_SetOwner(playerid, i); // Give ownership of the business to the player
else
SendClientMessage(playerid, 0xFF0000FF, "Nu ai bani"); // The player cannot afford this business
}
else
{
// Let the player know that this business is already owned by a player
format(Msg, 128, "{FF0000}Aceasta afacere este deja detinuta de {00FF00}%s{FFFFFF}", ABusinessData[i][Owner]);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
// The player was in range of a business-pickup, so stop searching for the other business pickups
return 1;
}
}
else
return 1; // If there are no more houses (no more pickup-id's found), stop searching
}
// All businesses have been processed, but the player wasn't in range of any business-pickup, let him know about it
SendClientMessage(playerid, 0xFF0000FF, "Trebuie sa fi langa o afacere");
}
else
SendClientMessage(playerid, 0xFF0000FF, "Nu poti cumpara afacerea din masina");
// Let the server know that this was a valid command
return 1;
}