AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Getting empty string (https://forums.alliedmods.net/showthread.php?t=82811)

Nikol4u 12-30-2008 11:26

Getting empty string
 
How can I get/understand if "player1" is empty (it doesn't have anything in it)?

I would use empty(player1) @ php, but dno what should I use here :s

xPaw 12-30-2008 11:59

Re: Getting empty string
 
try this
PHP Code:

if( player1[0] == "" ) {
    
// stuff



YamiKaitou 12-30-2008 12:28

Re: Getting empty string
 
PHP Code:

if (equal(player1,""))
    
// stuff 

PHP Code:

if (player1[0] == "\0")
    
// stuff 

The first method should work fine. The second one depends on what your escape character is. I think it can also equal 0, but I am not sure.

Hawk552 12-30-2008 14:45

Re: Getting empty string
 
Quote:

Originally Posted by YamiKaitou (Post 735574)
PHP Code:

if (equal(player1,""))
    
// stuff 

PHP Code:

if (player1[0] == "\0")
    
// stuff 

The first method should work fine. The second one depends on what your escape character is. I think it can also equal 0, but I am not sure.

The second won't compile. You would have to use:

Code:
if(player1[0] == '\0')

or

Code:
if(!player1[0])

I prefer the latter because the escape character can be changed using compiler options, but the null character is still 0.

danielkza 12-30-2008 16:08

Re: Getting empty string
 
Quote:

Originally Posted by Hawk552 (Post 735659)
The second won't compile. You would have to use:

Code:
if(player1[0] == '\0')


or

Code:
if(!player1[0])


I prefer the latter because the escape character can be changed using compiler options, but the null character is still 0.

You guys forgot that the default escape char in AMXX is '^'.

Zefir 07-07-2009 09:52

Re: Getting empty string
 
PHP Code:

if(player1[0] != EOS

From pawn manual
Quote:

EOS: predefined constant standing for End Of String; it has the value ’\0’


All times are GMT -4. The time now is 09:15.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.