Quote:
Originally Posted by Vince
This is for BlueG's plugin, R7 and above:
pawn Code:
// Somewhere new mysqlquery[80];
format(mysqlquery, sizeof(mysqlquery), "SELECT id, money FROM players WHERE name = '%s'", playername); mysql_function_query(1, mysqlquery, true, "OnPlayerDataLoad", "d", playerid);
// Somewhere else forward OnPlayerDataLoad(playerid); public OnPlayerDataLoad(playerid) { new rows, fields;
cache_get_data(1, rows, fields);
if(rows) { new temp[12]; cache_get_row(0, 0, temp); PlayerInfo[playerid][pSQLID] = strval(temp); cache_get_row(0, 1, temp); PlayerInfo[playerid][pMoney] = strval(temp); } return; }
|
And how do I connect? I have the following in OnGameModeInit()
pawn Code:
mysql_debug(ENABLE_DEBUGGING);
g_ConnectionHandle = mysql_connect("host", "user", "database", "password"); //with my real info of course
and the sample gamemode shows them using "g_ConnectionHandle" infront of every query, EX: (from sample GM)
pawn Code:
new szPlayerIP[16], iNumIP, szQuery[128];
GetPlayerIp(playerid, szPlayerIP, sizeof(szPlayerIP));
iNumIP = IpToInteger(szPlayerIP);
mysql_format(g_ConnectionHandle, szQuery, "SELECT `country_code`, `country_name` FROM `ip2c` WHERE \"%d\" BETWEEN `begin_ip_num` AND `end_ip_num` LIMIT 1", iNumIP);
mysql_function_query(g_ConnectionHandle, szQuery, true, "onCountryDetect", "ds", playerid, szPlayerIP);
See how they use "g_ConnectionHandle" infront of the queries? Is that just the "mysqlquery" you used?