PHP код:
stock UpdateBusinessOwner(BizID, BizOwner[])
{
new query[150];
format(query, sizeof(query), "UPDATE businessdata SET Owner='%s' WHERE BusinessID=%i", BizOwner, bInfo[BizID][ID]);
mysql_format(); // 20386
UpdateBusiness(BizID);
return 1;
}
stock UpdateBusiness(BizID)
{
new query[300], string[128];
format(query, sizeof(query), "UPDATE businessdata SET Price=%i, EnterX=%f, EnterY=%f, EnterZ=%f, ExitX=%f, ExitY=%f, ExitZ=%f, Interior=%i, World=%i, ", bInfo[BizID][Price], bInfo[BizID][EnterX], bInfo[BizID][EnterY], bInfo[BizID][EnterZ], bInfo[BizID][ExitX], bInfo[BizID][ExitY], bInfo[BizID][ExitZ], bInfo[BizID][Interior], bInfo[BizID][World]);
format(string, sizeof(string), "Text='%s', Owner='%s', Minutes=%i, Money=%i WHERE BusinessID=%i", bInfo[BizID][Text], bInfo[BizID][Owner], bInfo[BizID][Minutes], bInfo[BizID][Money], bInfo[BizID][ID]);
strcat(query, string);
mysql_format(); // 20397
ReloadBusinesses();
return 1;
}
stock CreateBusiness(BizID, BizPrice, BizEnterX, BizEnterY, BizEnterZ, BizExitX, BizExitY, BizExitZ, BizInterior, BizWorld, BizText[])
{
new query[300];
format(query, sizeof(query), "INSERT INTO businessdata (BusinessID, Price, EnterX, EnterY, EnterZ, ExitX, ExitY, ExitZ, Interior, World, Text, Owner, Minutes, Money) VALUES(%i, %i, %f, %f, %f, %f, %f, %f, %i, %i, '%s', 'None', 0, 0)", BizID, BizPrice, BizEnterX, BizEnterY, BizEnterZ, BizExitX, BizExitY, BizExitZ, BizInterior, BizWorld, BizText);
mysql_format(); // 20406
ReloadBusinesses();
return 1;
}
stock ReloadBusinesses()
{
for(new i = 0; i < MAX_BUSINESSES; i++)
{
DestroyDynamic3DTextLabel(bInfo[i][Label]);
DestroyDynamicPickup(bInfo[i][Pickup]);
}
LoadBusinesses();
return 1;
}
stock LoadBusinesses()
{
for(new i = 0; i < MAX_BUSINESSES; i++)
{
new query[600], savingstring[24], string[128];
mysql_function_query(MainPipeline, "SELECT * FROM `Business`", true, "OnLoadBusiness", "");
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(savingstring, "BusinessID"); bInfo[i][ID] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Price"); bInfo[i][Price] = strval(savingstring);
mysql_fetch_field_row(savingstring, "EnterX"); bInfo[i][EnterX] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "EnterY"); bInfo[i][EnterY] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "EnterZ"); bInfo[i][EnterZ] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "ExitX"); bInfo[i][ExitX] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "ExitY"); bInfo[i][ExitY] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "ExitZ"); bInfo[i][ExitZ] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "Interior"); bInfo[i][Interior] = strval(savingstring);
mysql_fetch_field_row(savingstring, "World"); bInfo[i][World] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Text"); bInfo[i][Text] = savingstring;
mysql_fetch_field_row(savingstring, "Owner"); bInfo[i][Owner] = savingstring;
mysql_fetch_field_row(savingstring, "Minutes"); bInfo[i][Minutes] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Money"); bInfo[i][Money] = strval(savingstring);
}
new BizName[24]; format(BizName, 24, "%s", bInfo[i][Text]);
printf(BizName, '_', ' ');
if(!strcmp(bInfo[i][Owner], "None", false)) format(string, sizeof(string), "%s [Unowned]\nPrice: %i\nType /enter or push f to enter the building", BizName, bInfo[i][Price]);
else format(string, sizeof(string), "%s [Owner]: %s\nType /enter or push f to enter the building", bInfo[i][Text], bInfo[i][Owner]);
bInfo[i][Label] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, bInfo[i][EnterX],bInfo[i][EnterY], bInfo[i][EnterZ], 12, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1);
bInfo[i][Pickup] = CreateDynamicPickup(1272, 1, bInfo[i][EnterX], bInfo[i][EnterY], bInfo[i][EnterZ], 0);
if(IsBusinessOwned(i)) printf("Business ID %i has loaded; Named: %s", i, bInfo[i][Text]);
}
return 1;
}
stock DeleteBusiness(businessid)
{
new query[100];
format(query, sizeof(query), "DELETE FROM businessdata WHERE BusinessID = %i", businessid);
mysql_format(); // 20458
ReloadBusinesses();
return 1;
}
stock IsBusinessCreated(businessid)
{
new query[200];
format(query, sizeof(query), "SELECT * FROM `businessdata` WHERE BusinessID = %i", businessid);
mysql_function_query(query); // 20466
mysql_store_result();
new rows = mysql_num_rows();
mysql_free_result();
if(!rows) return false;
else return true;
}
stock IsBusinessOwned(businessid)
{
new query[200];
format(query, sizeof(query), "SELECT Owner FROM 'businessdata' WHERE BusinessID = %i", businessid);
mysql_format(); // 20477
mysql_store_result();
new rows = mysql_num_rows();
mysql_free_result();
if(!rows) return false;
else return true;
}
((This is OnGameModeInit() ))
mysql_function_query("CREATE TABLE IF NOT EXISTS businessdata(BusinessID INT(3), Price Int(10), EnterX FLOAT(20), EnterY FLOAT(20), EnterZ FLOAT(20), ExitX FLOAT(20), ExitY FLOAT(20), ExitZ FLOAT(20), Interior INT(2), World INT(4), Text VARCHAR(24), Owner VARCHAR(24), Minutes INT(2), Money INT(5) )");
Your parameters are empty.