SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 11/11/2018, 02:33 AM   #1
dabv_astur
Little Clucker
 
Join Date: May 2011
Posts: 12
Reputation: 0
Default Problem getting string variable

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 Code:
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 Code:
[23:11:58] [DEBUG] cache_get_value_name(0, "Clan", 0x03AD6C00, 1)
[23:11:58] [DEBUG] cache_get_value_name: assigned value: 'TAW'
PHP Code:
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 Code:
[23:11:58] No eres TAW, eres:
Thanks in advance again!.
dabv_astur is offline   Reply With Quote
Old 11/11/2018, 02:41 AM   #2
Jefff
High-roller
 
Join Date: Dec 2007
Posts: 2,659
Reputation: 322
Default Re: Problem getting string variable

You need add size at the end
Jefff is offline   Reply With Quote
Old 11/11/2018, 03:18 AM   #3
dabv_astur
Little Clucker
 
Join Date: May 2011
Posts: 12
Reputation: 0
Default Re: Problem getting string variable

Quote:
Originally Posted by Jefff View Post
You need add size at the end
Can you explain that please?

EDIT:
I replace cache line with that:
PHP Code:
cache_get_value(0"Clan"pInfo[playerid][Clan], 25); 
As you say me but now I receive the next following SendClientMessage
HTML Code:
[00:56:49] No eres TAW, eres: TAW
when it should enter to the conditional..

Last edited by dabv_astur; 11/11/2018 at 04:00 AM. Reason: Gramatical error
dabv_astur is offline   Reply With Quote
Old 11/11/2018, 03:56 AM   #4
Jefff
High-roller
 
Join Date: Dec 2007
Posts: 2,659
Reputation: 322
Default Re: Problem getting string variable

cache_get_value(0, "Clan", pInfo[playerid][Clan], 25);
Jefff is offline   Reply With Quote
Old 11/11/2018, 04:02 AM   #5
dabv_astur
Little Clucker
 
Join Date: May 2011
Posts: 12
Reputation: 0
Default Re: Problem getting string variable

Quote:
Originally Posted by Jefff View Post
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
dabv_astur is offline   Reply With Quote
Old 11/11/2018, 04:05 AM   #6
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 2,012
Reputation: 491
Default Re: Problem getting string variable

Quote:
Originally Posted by dabv_astur View Post
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 Code:
if(!strcmp(pInfo[playerid][Clan],"TAW",true))
SyS is offline   Reply With Quote
Old 11/11/2018, 04:14 AM   #7
dabv_astur
Little Clucker
 
Join Date: May 2011
Posts: 12
Reputation: 0
Default Re: Problem getting string variable

Quote:
Originally Posted by SyS View Post
strcmp returns 0 if the strings match so you should do

pawn Code:
if(!strcmp(pInfo[playerid][Clan],"TAW",true))
I proof with other account has not set Clan on database
HTML Code:
[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 Code:
[nick] DabvAsturDemo nick changed to []DabvAsturDemo
When with that I should enter in else of condition.
dabv_astur is offline   Reply With Quote
Old 14/11/2018, 01:54 AM   #8
dabv_astur
Little Clucker
 
Join Date: May 2011
Posts: 12
Reputation: 0
Default Re: Problem getting string variable

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 Code:
if(pInfo[playerid][Clan][0] && !strcmp(pInfo[playerid][Clan],"TAW",true))

Solved!, thanks you guys!.
dabv_astur is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
warning 219: local variable "string" shadows a variable at a preceding level s3ek Scripting Help 3 30/07/2015 03:42 AM
warning 219: local variable "string" shadows a variable at a preceding level 0B3Y Scripting Help 4 05/07/2014 09:37 AM
warning 219: local variable "string" shadows a variable at a preceding level Uberanwar Scripting Help 8 17/08/2013 09:55 AM
warning 219: local variable "string" shadows a variable at a preceding level Facerafter Scripting Help 4 06/06/2013 10:33 AM
Compile error(warning 219: local variable "string" shadows a variable at a preceding level) calin1996 Scripting Help 6 25/04/2012 04:13 PM


All times are GMT. The time now is 11:29 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.