AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Empty an array (https://forums.alliedmods.net/showthread.php?t=155841)

killergirl 04-27-2011 08:03

Empty an array
 
I tried to search, but I havent found any respons to my question. I'm trying to empty an array, but I don't know how. I need to give a value, or... I don't know.

eg:
PHP Code:

new g_SelectedAuthId[32]

public function(
id)
{
    
//bla bla
    
    
new szID[32]
    
get_user_authid(targetszIDcharsmax(szID))
    
    if(
is_user_connected(target))
    {
        
copy(g_SelectedAuthId31szID)
    }
}

public 
AnotherFunction(id)
{
    
client_print(0print_chat"%s"g_SelectedAuthId)



Arkshine 04-27-2011 09:02

Re: Empty an array
 
For a string, you can do simply : g_SelectedAuthId[0] = EOS;

Bugsy 04-27-2011 09:17

Re: Empty an array
 
For an entire array:

arrayset( theArray , 0 , sizeof( theArray ) )

.Dare Devil. 04-27-2011 09:18

Re: Empty an array
 
Or you can make this way too

PHP Code:

 
new g_SelectedAuthId[32]

public function(
id)
{
    
//bla bla
    
    
new szID[32]
    
get_user_authid(targetszIDcharsmax(szID))
    
    if(
is_user_connected(target))
    {
        
copy(g_SelectedAuthId31szID)
    }
}

public 
AnotherFunction(id)
{
    
client_print(0print_chat"%s"g_SelectedAuthId)
    
g_SelectedAuthId[0] = 0


Or i am wrong? :)

SonicSonedit 04-27-2011 09:54

Re: Empty an array
 
PHP Code:

new g_SelectedAuthId[32]

public function(
id)
{
         
//bla bla

     
g_SelectedAuthId[0]=0
 
     
if(!is_user_connected(target))
          return
         
     new 
szID[32]
     
get_user_authid(targetSelectedAuthIdcharsmax(SelectedAuthId))
}

public 
AnotherFunction(id)
     
client_print(0print_chat"player %d SelectedAuthId: %s"idg_SelectedAuthId[id]) 


Arkshine 04-27-2011 09:59

Re: Empty an array
 
SonicSonedit, EOS = '^0' = 0.

SonicSonedit 04-27-2011 10:07

Re: Empty an array
 
Arkshine
EOS 3 symbols, 0 is just one :D

Bugsy 04-27-2011 10:13

Re: Empty an array
 
Quote:

Originally Posted by SonicSonedit (Post 1458914)
Arkshine
EOS 3 symbols, 0 is just one :D

Really?

[/thread]

SonicSonedit 04-27-2011 10:17

Re: Empty an array
 
Quote:

Originally Posted by Bugsy (Post 1458917)
Really?

[/thread]

Deadly serious.

hleV 04-27-2011 10:35

Re: Empty an array
 
Why create szID[]?


All times are GMT -4. The time now is 04:20.

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