Problem getting string variable
#1

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],
    
CachePlayer_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(playeridnombresizeof(nombre)); 
                
format(stringsizeof(string), "[%s]%s",pInfo[playerid][Clan], nombre);
                
SetPlayerName(playeridstring);
           }
           else
           {
            new 
string[29];
            
format(stringsizeof(string), "No eres TAW, eres: %s",pInfo[playerid][Clan]);
            
SendClientMessage(playeridCOLOR_REDstring);
           } 
I receive the SendClientMessage with empty string:
Код HTML:
[23:11:58] No eres TAW, eres:
Thanks in advance again!.
Reply
#2

You need add size at the end
Reply
#3

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..
Reply
#4

cache_get_value(0, "Clan", pInfo[playerid][Clan], 25);
Reply
#5

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
Reply
#6

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))
Reply
#7

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.
Reply
#8

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!.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)