Problem getting string variable -
dabv_astur - 11.11.2018
Hi and thanks in advance for your help
In advance, I apologize for my bad english, is not my native language.
Look, I'm trying getting string variable from MYSQL. I get string perfectly from database but when use it as user variable it's as if there was void variable
Script of enum with player data and cache
PHP код:
enum ENUM_PLAYER_DATA
{
//more variables behind here
Clan[25],
Cache: Player_Cache,
bool:LoggedIn
}
new pInfo[MAX_PLAYERS][ENUM_PLAYER_DATA];
cache_get_value(0, "Clan", pInfo[playerid][Clan]);
LOG of MySQL plugin
Код HTML:
[23:11:58] [DEBUG] cache_get_value_name(0, "Clan", 0x03AD6C00, 1)
[23:11:58] [DEBUG] cache_get_value_name: assigned value: 'TAW'
PHP код:
if(strcmp(pInfo[playerid][Clan],"TAW",true))
{
new nombre[24], string[29];
GetPlayerName(playerid, nombre, sizeof(nombre));
format(string, sizeof(string), "[%s]%s",pInfo[playerid][Clan], nombre);
SetPlayerName(playerid, string);
}
else
{
new string[29];
format(string, sizeof(string), "No eres TAW, eres: %s",pInfo[playerid][Clan]);
SendClientMessage(playerid, COLOR_RED, string);
}
I receive the SendClientMessage with empty string:
Код HTML:
[23:11:58] No eres TAW, eres:
Thanks in advance again!.
Re: Problem getting string variable -
Jefff - 11.11.2018
You need add size at the end
Re: Problem getting string variable -
dabv_astur - 11.11.2018
Quote:
Originally Posted by Jefff
You need add size at the end
|
Can you explain that please?
EDIT:
I replace cache line with that:
PHP код:
cache_get_value(0, "Clan", pInfo[playerid][Clan], 25);
As you say me but now I receive the next following SendClientMessage
Код HTML:
[00:56:49] No eres TAW, eres: TAW
when it should enter to the conditional..
Re: Problem getting string variable -
Jefff - 11.11.2018
cache_get_value(0, "Clan", pInfo[playerid][Clan], 25);
Re: Problem getting string variable -
dabv_astur - 11.11.2018
Quote:
Originally Posted by Jefff
cache_get_value(0, "Clan", pInfo[playerid][Clan], 25);
|
Yeah, when I re-read it, I understood. Look the edit in the previous reply please
Re: Problem getting string variable -
SyS - 11.11.2018
Quote:
Originally Posted by dabv_astur
Yeah, when I re-read it, I understood. Look the edit in the previous reply please
|
strcmp returns 0 if the strings match so you should do
pawn Код:
if(!strcmp(pInfo[playerid][Clan],"TAW",true))
Re: Problem getting string variable -
dabv_astur - 11.11.2018
Quote:
Originally Posted by SyS
strcmp returns 0 if the strings match so you should do
pawn Код:
if(!strcmp(pInfo[playerid][Clan],"TAW",true))
|
I proof with other account has not set Clan on database
Код HTML:
[01:08:52] [DEBUG] cache_get_value_name(0, "Clan", 0x03BCDBC8, 25)
[01:08:52] [DEBUG] cache_get_value_name: assigned value: ''
[01:08:52] [DEBUG] cache_get_value_name: return value: '1'
And that's is result:
Код HTML:
[nick] DabvAsturDemo nick changed to []DabvAsturDemo
When with that I should enter in else of condition.
Re: Problem getting string variable -
dabv_astur - 14.11.2018
Finally, with help of Sys and Jefff (Jeff was the one who helped me the most, even by PM), we solved my problem with this conditional line:
pawn Код:
if(pInfo[playerid][Clan][0] && !strcmp(pInfo[playerid][Clan],"TAW",true))
Solved!, thanks you guys!.