SA-MP Forums Archive
+REP how to empty and check for an empty string var - 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: +REP how to empty and check for an empty string var (/showthread.php?tid=316776)



+REP how to empty and check for an empty string var - PawnoQ - 08.02.2012

hi,

like the title says.

pawn Код:
new pNames[11][24];
            for(new q = 0; q < sizeof(pNames); q++)
            {
                pNames[q]="";
            }
Now my question is how to empty these strings and how to check if they are empty.
Can i do it like above?
And if yes then how to check for it (if it is emtpy?)

thx.


Re: +REP how to empty and check for an empty string var - Shabi RoxX - 08.02.2012

Try:

Код:
new pNames[11][24];
            for(new q = 0; q < sizeof(pNames); q++)
            {
                IsNull(pNames[q]);
            }



Re: +REP how to empty and check for an empty string var - PawnoQ - 08.02.2012

let me explain better:
pawn Код:
//This is my variable/array defining or whatever its called ;)
new pNames[11][24];

//Now e.g. i store a players name in one of these variables like:
GetPlayerName(playerid,pNames[0],24);

//So now i wanna check somehow if a variable is empty or if there is already a name stored in it.
//But i dont know how.

//After the check i want to emtpy all variables, so can i do it like this?:
for(new q = 0; q < sizeof(pNames); q++)
{
      pNames[q]="";
}



Re: +REP how to empty and check for an empty string var - T0pAz - 08.02.2012

pawn Код:
if(strcmp(pNames[0], "") == 0)
{
     
}



Re: +REP how to empty and check for an empty string var - Vince - 08.02.2012

isnull definition:
pawn Код:
#define isnull(%1) \
    ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
To explicitly empty a string:
pawn Код:
string[0] = EOS // End-Of-String
//or
string[0] = '\0'



Re: +REP how to empty and check for an empty string var - PawnoQ - 08.02.2012

thx, +rep