19.03.2018, 21:28
Aigh so I have a problem with saving and loading a business system idk why it compiles correctly and I get 0 errors but it's not working.
here's the code
loading
and saving
Help please.
here's the code
loading
Код:
stock LoadBusiness() { new DB_Query[228]; new string[500]; for(new i; i <= MAX_BUSINESS; i++) { mysql_format(Database, DB_Query, sizeof(DB_Query), "SELECT * FROM `BUSINESS` WHERE `ID` = '%d' LIMIT 1", i); if(cache_num_rows() > 0) { cache_get_value(i, "NAME", Business[i][Name], 128); cache_get_value_int(i, "TYPE", Business[i][Type]); cache_get_value_int(i, "PRODUCT", Business[i][Product]); cache_get_value_int(i, "FEE", Business[i][Fee]); cache_get_value_int(i, "SAFE", Business[i][Safe]); cache_get_value_int(i, "OWNER", Business[i][Owner]); cache_get_value_int(i, "VW", Business[i][Vw]); cache_get_value_int(i, "INT", Business[i][Int]); cache_get_value_int(i, "OWNER", Business[i][Owner]); cache_get_value_int(i, "PRICE", Business[i][Price]); cache_get_value_name_float(i, "PosX", Business[i][PosX]); cache_get_value_name_float(i, "PosY", Business[i][PosY]); cache_get_value_name_float(i, "PosZ", Business[i][PosZ]); Business[i][Used] = true; if(Business[i][Owner] != -1) { format(string, sizeof(string),"\t ID : %d\nName : %s\nType : %s\nOwner : %s\nEntrance Fee : $ %d",i,Business[i][Name],GetBusinessType(Business[i][Type]),GetNameFromUniqueID(Business[i][Owner]),Business[i][Fee]); Business[i][BizText] = Create3DTextLabel(string, COLOR_ADMIN, Business[i][PosX], Business[i][PosX], Business[i][PosX], 10.0, Business[i][Vw], Business[i][Int]); } else { format(string, sizeof(string),"\t ID : %d\nName : NEW BUSINESS\nType : %s\nPrice : %d",i,GetBusinessType(Business[i][Type]),Business[i][Price]); Business[i][BizText] = Create3DTextLabel(string, COLOR_ADMIN, Business[i][PosX], Business[i][PosX], Business[i][PosX], 10.0, Business[i][Vw], Business[i][Int]); } } else { Business[i][Used] = false; } } return 1; }
Код:
stock SaveBusiness(bizid) { if(Business[bizid][Used]) { new query[512]; format(query, sizeof(query),"UPDATE `BUSINESS` SET `NAME` = %s, `TYPE` = %d, `PRODUCT` = %d, `FEE` = %d, `OWNER` = %d, `SAFE` = %d, `VW` = %d, `INT` = %d, `PRICE` = %d, `PosX` = %f, `PosY` = %f, `PosZ` = %f WHERE `ID` = %d LIMIT 1", Business[bizid][Name],Business[bizid][Type],Business[bizid][Product],Business[bizid][Fee],Business[bizid][Owner], Business[bizid][Safe],Business[bizid][Vw], Business[bizid][Int], Business[bizid][Price],Business[bizid][PosX],Business[bizid][PosY],Business[bizid][PosZ],bizid); mysql_query(Database, query); } return 1; }