20.05.2012, 00:29
(
Last edited by Luis-; 20/05/2012 at 05:37 PM.
)
Got it working
new dbHandle;
new dbHandle;
// Whereever you connect!
mysql_connect("localhost", "root", "database", "password", 3306);
mysql_connect("localhost", "root", "database", "password");
Thank you so much for this, I can't begin to explain how grateful I am. Everything seems to be going along nicely now. I haven't really set up the table properly yet as it's early days.
I now understand the purpose of threaded queries, and shouldn't have said the things I said in the mySQL plugin topic! |
Not bad I guess, thanks for the heads up. Nice to see it forces me using threaded queries, knowing I had to switch over to them a long time ago.
|
if(IsPlayerInAnyVehicle(playerid))
{
vID = GetPlayerVehicleID(playerid);
}
// to:
vID = GetPlayerVehicleID(playerid);
if(vID != 0)
{
}
GetPlayerIp(playerid, plrIP, sizeof(plrIP));
mysql_format(MySQLConnection, MySQL, "SELECT Date FROM bans WHERE IP = '%s' AND Date > UNIX_TIMESTAMP()", plrIP);
mysql_function_query(MySQLConnection, MySQL, true, "OnBanQueryFinish", "i", playerid);
forward OnBanQueryFinish(playerid);
public OnBanQueryFinish(playerid)
{
new rows, fields;
cache_get_data(rows, fields);
// You might also want to add a LIMIT clause to your ban since you don't seem to use more than one row here.
if(rows)
{
new data[12];
cache_get_row(0, 0, data);
new expire = strval(data);
printf("Extracted unban time %d from string '%s'", expire, data);
SendClientMessage(playerid, COLOR, "You banned bro!");
}
return 1;
}
Originally Posted by KyleSmith
pawn Код:
|
mysql_function_query(MySQLConnection, MySQL, false, "", "");
DontShow = true;
public OnPlayerDisconnect(playerid, reason)
{
if(!DontShow)
{
// Send disconnect message
}
else DontShow = false;
}
new resultline[64];
format(querystring,sizeof(querystring), "SELECT Skin, IP, logincam, vcolor, vcolor2, time_h, time_m, weather FROM players WHERE Name = '%s' LIMIT 1", pName[playerid]);
mysql_query(querystring);
mysql_store_result();
mysql_fetch_row_format(resultline);
mysql_fetch_field_row(querystring, "Skin");
SetPVarInt(playerid, "Skin", strval(querystring));
SetPVarInt(playerid, "TempSkin", strval(querystring));
SetPlayerSkin(playerid, strval(querystring));
mysql_fetch_field_row(querystring, "vcolor");
SetPVarInt(playerid, "vcolor", strval(querystring));
mysql_fetch_field_row(querystring, "vcolor2");
SetPVarInt(playerid, "vcolor2", strval(querystring));
mysql_fetch_field_row(querystring, "logincam");
SetPVarInt(playerid, "logincam", strval(querystring));
mysql_fetch_field_row(querystring, "IP");
SetPVarString(playerid, "temp_ip", querystring);
mysql_fetch_field_row(querystring, "time_h");
if(strval(querystring) != -1) curPlayerHour[playerid] = strval(querystring);
else curPlayerHour[playerid] = DEFAULT_HOUR;
SetPVarInt(playerid, "time_h", curPlayerHour[playerid]);
mysql_fetch_field_row(querystring, "time_m");
if(strval(querystring) != -1) curPlayerMin[playerid] = strval(querystring);
else curPlayerMin[playerid] = DEFAULT_MIN;
SetPVarInt(playerid, "time_m", curPlayerHour[playerid]);
mysql_fetch_field_row(querystring, "weather");
if(strval(querystring) != -1) curPlayerWeather[playerid] = strval(querystring);
else curPlayerWeather[playerid] = DEFAULT_WEATHER;
SetPVarInt(playerid, "save_weather", curPlayerWeather[playerid]);
mysql_free_result();
I'm currently using R6 on my server. I need to know if the code will drastically change if I update to R7. For example this is one of my login queries:
pawn Код:
|