SQL Load problem -
anou1 - 23.01.2014
Hi,
I did something that load the reason if a player is banned.
I did this:
Код:
public OnPlayerSpawn(playerid)
{
if(pInfo[playerid][Bannis] == 1)
{
new string[128];
cache_get_row(0, 16, pInfo[playerid][RaisonBan]);
printf("%s", pInfo[playerid][RaisonBan]);
format(string, sizeof(string), "Vous кtes bannis du serveur. Raison: %s", pInfo[playerid][RaisonBan]);
SendClientMessage(playerid, Rouge, string);
SetTimerEx("KickJoueur", 1000, 0, "d", playerid);
}
return 1;
}
But it doesn't load the reason, how should I get the reason from the database ? Thank you !
mysql log:
[18:10:50] [DEBUG] cache_get_row - row: 0, field_idx: 16, connection: 1, max_len: 1
[18:10:50] [WARNING] cache_get_row - no active cache
Anyone could help me with this please ?
Re : SQL Load problem -
anou1 - 23.01.2014
No one have an idea ?
Please I'm really blocked with this
Re: SQL Load problem -
WopsS - 23.01.2014
Follow this steps:
1.
Add
after
Код:
cache_get_data(rows, fields, mysqlhandle);
2.
Replace with
Код:
cache_get_field_content(0, "field", variable), format(pInfo[playerid][RaisonBan], 128, variable);
3.
Optionally add
Код:
if(rows != 0)
{ ... }
Re : SQL Load problem -
anou1 - 23.01.2014
Hi,
I tried what you told me to do but I think I'm not doing it good.
Код:
public OnPlayerSpawn(playerid)
{
horloge();
if(pInfo[playerid][Bannis] == 1)
{
new string[128], raison[128];
new rows,fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
cache_get_field_content(0, "RaisonBan", raison), format(pInfo[playerid][RaisonBan], 128, raison);
format(string, sizeof(string), "Vous кtes bannis du serveur. Raison: %s", pInfo[playerid][RaisonBan]);
printf("%s", pInfo[playerid][RaisonBan]);
SendClientMessage(playerid, Rouge, string);
SetTimerEx("KickJoueur", 1000, 0, "d", playerid);
}
else
{
printf("bug");
}
}
SetPlayerHealth(playerid, pInfo[playerid][Vie]);
SetPlayerArmour(playerid, pInfo[playerid][Armure]);
return 1;
}
And I tried like this too:
Код:
public OnPlayerSpawn(playerid)
{
horloge();
if(pInfo[playerid][Bannis] == 1)
{
new string[128], raison[128];
new rows,fields;
cache_get_data(rows, fields, mysql);
cache_get_field_content(0, "RaisonBan", raison), format(pInfo[playerid][RaisonBan], 128, raison);
format(string, sizeof(string), "Vous кtes bannis du serveur. Raison: %s", pInfo[playerid][RaisonBan]);
printf("%s", pInfo[playerid][RaisonBan]);
SendClientMessage(playerid, Rouge, string);
SetTimerEx("KickJoueur", 1000, 0, "d", playerid);
}
SetPlayerHealth(playerid, pInfo[playerid][Vie]);
SetPlayerArmour(playerid, pInfo[playerid][Armure]);
return 1;
}
Nothing work for me.
And I got in mysql:
[21:46:01] [DEBUG] cache_get_data - connection: 1
[21:46:01] [WARNING] cache_get_data - no active cache
Re: SQL Load problem -
WopsS - 23.01.2014
Hmm, I think you must to put a variable Cache:Reason at pInfo, and in code put
Код:
cache_set_active(pInfo[playerid][Reason])
// rest of code
cache_set_active(Cache:0)
https://sampwiki.blast.hk/wiki/MySQL/R33#cache_set_active
Re : SQL Load problem -
anou1 - 23.01.2014
I'm surprised, there isnt other way to do it ?
Re: SQL Load problem -
WopsS - 23.01.2014
Yes, without cache you can do it with
Код:
mysql_format(etc., "SELECT * FROM etc.);
mysql_query(etc.)
with store results etc. look at wiki.
But I'm not sure about Cache:Reason.