Business Buy Problem
#1

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:
PHP код:
// This dialog processes the chosen business-type and creates the business
Dialog_CreateBusSelType(playeridresponselistitem)
{
    
// Just close the dialog if the player clicked "Cancel"
    
if(!response) return 1;
    
// Setup some local variables
    
new BusTypeBusIDFloat:xFloat:yFloat:zbool:EmptySlotFound false,query[240];
    
// Get the player's position
    
GetPlayerPos(playeridxyz);
    
// Get the business-type from the option the player chose
    
BusType listitem 1;
    
// Find a free business-id
    
for (BusID 1BusID MAX_BUSINESSBusID++)
    {
        
// 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(playerid0xFFFFFFFF"{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_SQLquerysizeof(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_SQLquery"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(Msgsizeof(Msg), "You've succesfully created business %i"ABusinessData[BusID][BusIDD]);
    
SendClientMessage(playerid0xFFFFFFFFMsg);
    return 
1;

Buybus:
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(playeridparams[])
{
    
// 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 0MAX_BUSINESSi++)
        {
            
// 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(playerid2.5ABusinessData[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(playeridi); // Give ownership of the business to the player
                        
else
                            
SendClientMessage(playerid0xFF0000FF"Nu ai bani"); // The player cannot afford this business
                    
}
                    else
                    {
                           
// Let the player know that this business is already owned by a player
                        
format(Msg128"{FF0000}Aceasta afacere este deja detinuta de {00FF00}%s{FFFFFF}"ABusinessData[i][Owner]);
                        
SendClientMessage(playerid0xFFFFFFFFMsg);
                    }
                    
// 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(playerid0xFF0000FF"Trebuie sa fi langa o afacere");
    }
    else
        
SendClientMessage(playerid0xFF0000FF"Nu poti cumpara afacerea din masina");
    
// Let the server know that this was a valid command
    
return 1;

I can't figure out how to make it to work....When i type /buybus nothing happens...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)