[Help]Problem with cache_get_row_int [ REP ++ ] - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help]Problem with cache_get_row_int [ REP ++ ] (
/showthread.php?tid=557708)
[Help]Problem with cache_get_row_int [ REP ++ ] -
buburuzu19 - 14.01.2015
I am trying to get a value for playerDays from my database but it's saying 0 in-game.
I am using mysql r39-2 and i am getting those errors in mysql_log:
pawn Код:
[21:46:57] [WARNING] cache_get_field_content - no active cache
My code is:
pawn Код:
else
{
new query2[1000];
new dstring[500];
new query[1000];
new days;
new playerID = cache_get_row_int(0, 0);
mysql_format(handle, query2, sizeof(query2), "SELECT `playerID` FROM `playeraccounts` WHERE `playerName` = '%s' LIMIT 1",playerVariables[playerid][pSelected]);
mysql_tquery(handle, query2);
mysql_format(handle, query, sizeof(query), "SELECT playerDays FROM playeraccounts WHERE playerID = '%d' ", playerID);
new Cache: result690 = mysql_query(handle, query);
cache_get_field_content(0, "playerDays", query2);
days = strval(query2);
format(dstring, sizeof(dstring), "%s has left the faction with %d days.",playerVariables[playerid][pSelected], days);
SCM(playerid, -1 , dstring);
cache_delete(result690);
}
Thanks for helping me! I rep!
Re: [Help]Problem with cache_get_row_int [ REP ++ ] -
xVIP3Rx - 14.01.2015
Try this, I've edited few lines
pawn Код:
else
{
new query[1000],
dstring[128],
tmp[128];
new days;
new Cache:result690;
mysql_format(handle, query, sizeof(query), "SELECT `playerID` FROM `playeraccounts` WHERE `playerName` = '%s' LIMIT 1",playerVariables[playerid][pSelected]);
result690 = mysql_query(handle, query);
playerID = cache_get_row_int(0, 0);
mysql_format(handle, query, sizeof(query), "SELECT `playerDays` FROM `playeraccounts` WHERE `playerID` = '%d' ", playerID);
result690 = mysql_query(handle, query);
cache_get_field_content(0, "playerDays", tmp);
days = strval(tmp);
format(dstring, sizeof(dstring), "%s has left the faction with %d days.",playerVariables[playerid][pSelected], days), SCM(playerid, -1 , dstring);
cache_delete(result690);
}
Re: [Help]Problem with cache_get_row_int [ REP ++ ] -
CodeStyle175 - 14.01.2015
PHP код:
else
{
new query[200],param,Cache:cquery;
mysql_format(handle, query, sizeof(query), "SELECT playerID FROM playeraccounts WHERE playerName = '%e' LIMIT 0,1",playerVariables[playerid][pSelected]);
cquery=mysql_query(handle,query);
param=cache_get_field_content_int(0,"playerID");
cache_delete(cuqery);
mysql_format(handle,query, sizeof(query), "SELECT playerDays FROM playeraccounts WHERE playerID = '%d' LIMIT 0,1",param);
cquery=mysql_query(handle,query);
param=cache_get_field_content_int(0,"playerDays");
cache_delete(cquery);
format(query,sizeof(query),"%s has left the faction with %d days.",playerVariables[playerid][pSelected],param);
SCM(playerid,-1,query);
return 1;
}