24.09.2011, 07:43
Quote:
#define DATA_GET 0 #define DATA_SET 1 #define DATA_MONEY 0 PlayerData(playerid, DATA_SET, DATA_MONEY, 9999); printf("%d", PlayerData(playerid, DATA_GET, DATA_MONEY, 0); stock PlayerData(playerid, get_set, data_type, value) { if(get_set < 0 || get_set > 1) { print("PlayerData - get_set"); } new query[256]; switch(data_type) { case DATA_MONEY: { if(get_set == DATA_GET) { format(query,sizeof(query),"SELECT Money FROM `"TABLENAME"` WHERE Username = '%s' LIMIT 1",gPlayerData[playerid][Player_Name]); mysql_query(query); mysql_store_result(); gPlayerData[playerid][Money] = mysql_fetch_int(); return gPlayerData[playerid][Money]; } else { format(query,sizeof(query),"UPDATE `"TABLENAME"` SET Money='%d' WHERE Username='%s'", value, gPlayerData[playerid][Player_Name]); mysql_query(query); ResetPlayerMoney(playerid); GivePlayerMoney(playerid, value); } } } return 1; } |
Thanks.