+REP how to empty and check for an empty string var
#1

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

Try:

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

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]="";
}
Reply
#4

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

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

thx, +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)