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; }
cache_get_value(i, "NAME", Business[i][Name], 128);
cache_get_value_name(i, "NAME", Business[i][Name], 128);
Assuming your business name enum is saved as a string you could try replacing:
Код:
cache_get_value(i, "NAME", Business[i][Name], 128); Код:
cache_get_value_name(i, "NAME", Business[i][Name], 128); |
it ain't working it's not even being called because when I try to create a new business ig it gets ID 0 like the old one.
and in the mysql.log file there's nothing suspecious. There's only alot of this "[13:31:45] [ERROR] cache_get_row_count: no active cache" and that's it. |
Assuming your business name enum is saved as a string you could try replacing:
Код:
cache_get_value(i, "NAME", Business[i][Name], 128); Код:
cache_get_value_name(i, "NAME", Business[i][Name], 128); |
Are u using auto increment? Also note that update only works if the row exists. to create a new row use INSERT INTO
|
CMD:createbusiness(playerid, params[]) { if(IsPlayerConnected(playerid)) { if(pInfo[playerid][Admin] >= 3) { for(new i; i <= MAX_BUSINESS; i++) { if(Business[i][Used] = false) { new Float: x,Float: y,Float: z; new string[500]; new DB_Query[500]; new name[24] = "BUSINESS"; GetPlayerPos(playerid, x,y,z); Business[i][PosX] = x; Business[i][PosY] = y; Business[i][PosZ] = z; Business[i][Fee] = 0; Business[i][Type] = 0; Business[i][Product] = 0; Business[i][Owner] = -1; Business[i][Price] = 30000; Business[i][Vw] = GetPlayerVirtualWorld(playerid); Business[i][Int] = GetPlayerInterior(playerid); Business[i][Used] = true; format(string, sizeof(string),"\t ID : %d\nName : 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][PosY], Business[i][PosZ], 10.0, Business[i][Vw], Business[i][Int]); mysql_format(Database, DB_Query, sizeof(DB_Query), "INSERT INTO `BUSINESS` (`NAME`, `PosX`, `PosY`,`PosZ`, `FEE`, `TYPE`, `ID` , `PRODUCT`, `OWNER`, `VW`, `INT`, `PRICE` ) VALUES ('%s', '%f','%f','%f','0','0','%d','0','-1','%d','%d','30000')",name,Business[i][PosX],Business[i][PosY], Business[i][PosZ],i,Business[i][Vw],Business[i][Int]); mysql_tquery(Database, DB_Query); break; } } } } return 1; }
[02:40:18] [WARNING] mysql_connect: no password specified [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:18] [ERROR] cache_get_row_count: no active cache [02:40:56] [ERROR] error #1062 while executing query "INSERT INTO `BUSINESS` (`NAME`, `PosX`, `PosY`,`PosZ`, `FEE`, `TYPE`, `ID` , `PRODUCT`, `OWNER`, `VW`, `INT`, `PRICE` ) VALUES ('BUSINESS', '1957.813721','1342.186157','15.374607','0','0','0','0','-1','0','0','30000')": Duplicate entry '0' for key 'PRIMARY'
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);
mysql_query(Database, DB_Query);
if(cache_num_rows() > 0)
{
cache_get_value(0, "NAME", Business[i][Name], 128);
cache_get_value_int(0, "TYPE", Business[i][Type]);
cache_get_value_int(0, "PRODUCT", Business[i][Product]);
cache_get_value_int(0, "FEE", Business[i][Fee]);
cache_get_value_int(0, "SAFE", Business[i][Safe]);
cache_get_value_int(0, "OWNER", Business[i][Owner]);
cache_get_value_int(0, "VW", Business[i][Vw]);
cache_get_value_int(0, "INT", Business[i][Int]);
cache_get_value_int(0, "OWNER", Business[i][Owner]);
cache_get_value_int(0, "PRICE", Business[i][Price]);
cache_get_value_name_float(0, "PosX", Business[i][PosX]);
cache_get_value_name_float(0, "PosY", Business[i][PosY]);
cache_get_value_name_float(0, "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;
}
Try this
PHP код:
|
stock SaveBusiness() { for(new i; i <= MAX_BUSINESS; i++) { if(Business[i][Used]) { new DB_Query[1000]; mysql_format(Database, DB_Query, sizeof(DB_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[i][Name],Business[i][Type],Business[i][Product],Business[i][Fee],Business[i][Owner], Business[i][Safe],Business[i][Vw], Business[i][Int], Business[i][Price],Business[i][PosX],Business[i][PosY],Business[i][PosZ],i); mysql_tquery(Database, DB_Query); } } return 1; }