15.04.2014, 14:18
Код:
CMD:bagitem(playerid, params[]) { new string[128]; if(!CheckAdmin(playerid, HIGH_ADMIN_LEVEL)) return NotAuthMSG(playerid); if(sscanf(params, "dd", params[0], params[1])) { SendClientMessage(playerid, COLOR_RED, "/bagitem [itemID] [itemAmount]"); return 1; } if(GetBagItemCount(playerid) >= MAX_ITEMS) return SCM(playerid, COLOR_RED, "数量已经超出最大物品限制"); format(string, sizeof(string), "%s", GetName(playerid)); _AddDatabaseItem(params[0], params[1], string); LoadPlayerBag(playerid); SCM(playerid, COLOR_GREEN, "成功添加 !"); return 1; }
Код:
LoadPlayerBag(playerid) { for(new i = 0,j = MAX_ITEMS; i < j; i ++) { Bag[playerid][bagItemID][i] = 0; Bag[playerid][bagItem][i] = 0; Bag[playerid][bagItemAmount][i] = 0; Bag[playerid][bagItemLoaded][i] = 0; Bag[playerid][bagItemLoadAmount][i] = 0; Bag[playerid][bagItemServer][i] = 0; } new temp[256], id = 0; format(query, sizeof(query), "SELECT * FROM `bagitems` WHERE `Owner` = %d", GetName(playerid)); mysql_query(query); mysql_store_result(); if(mysql_num_rows()) { while(mysql_retrieve_row()) { mysql_fetch_field_row(temp, "ID"), Bag[playerid][bagItemID][id] = strval(temp); mysql_fetch_field_row(temp, "Item"), Bag[playerid][bagItem][id] = strval(temp); mysql_fetch_field_row(temp, "ItemAmount"), Bag[playerid][bagItemAmount][id] = strval(temp); mysql_fetch_field_row(temp, "ItemLoaded"), Bag[playerid][bagItemLoaded][id] = strval(temp); mysql_fetch_field_row(temp, "ItemLoadAmount"), Bag[playerid][bagItemLoadAmount][id] = strval(temp); mysql_fetch_field_row(temp, "ItemServer"), Bag[playerid][bagItemServer][id] = strval(temp); id ++; } } mysql_free_result(); return 1; }
Код:
stock _AddDatabaseItem(item, amount, owner) { format(query, sizeof(query), "INSERT INTO `bagitems`(`Owner`, `Item`, `ItemAmount`) VALUES (%d, %d, %d)", owner, item, amount); mysql_query(query); return 1; }
Код:
stock _AddDatabaseItem(item, amount, owner) { format(query, sizeof(query), "INSERT INTO `bagitems`(`Owner`, `Item`, `ItemAmount`) VALUES (%d, %d, %d)", owner, item, amount); mysql_query(query); return 1; }
Код:
stock _RemoveDatabaseItem(id) { format(query, sizeof(query), "DELETE FROM `bagitems` WHERE `ID` = %d", id); mysql_query(query); return 1; }
pls...