AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Clear a variable (https://forums.alliedmods.net/showthread.php?t=195475)

MagNeto 09-08-2012 03:20

Clear a variable
 
I have some issues finding the error.
PHP Code:

#include <amxmodx>

new g_Name[1024][32], first_time 00;

public 
client_authorized(id)
{
    
first_time++;

    if(
first_time)
    {
        
set_task(120.0"clearvar"___"b");
    }
        
    for(; 
1024k++)
    {
        
get_user_name(idg_Name], 31);
    }

    for(new 
0<= ki++)
    {
        if( 
equali(g_Name[i], g_Name[k]) )
        {
            
// exec something
        
}
    }
}

public 
clearvar()
{
    for(new 
01024i++)
    {
        for(new 
032j++)
        {
            
g_Name[i][j] = '\0';
        }
    }


PHP Code:

/tmp/textbxpJsw.sma(33) : error 075input line too long (after substitutions

I'm trying to check if a player has reconnected in the last 120 secs. Also, I want to reuse the g_Name variable, but when I try to assign the NULL value, the compiler won't let me.
Thanks!

OvidiuS 09-08-2012 03:51

Re: Clear a variable
 
Code:
public clearvar() {     for(new i = 0; i < 1024; i++)     {         for(new j = 0; j < 32; j++)         {             g_Name[i][j] = '\0';         }     } }
=>
Code:
public clearvar( ) {     for( new i = 0; i < 1024; i++ )     {         g_Name[ i ][ 0 ] = EOS;     } }

fysiks 09-08-2012 13:49

Re: Clear a variable
 
Using an array like that is extremely inefficient, use a Trie. Also, using a name to identify somebody is very unreliable, use SteamID.

Aooka 09-09-2012 15:28

Re: Clear a variable
 
Code:
g_Name[ i ][ 0 ] = EOS;

EOS is using for clearing variable only ?

micapat 09-09-2012 15:50

Re: Clear a variable
 
EOS = End Of String = '^0' = 0

fysiks 09-09-2012 18:22

Re: Clear a variable
 
Quote:

Originally Posted by Aooka (Post 1795445)
Code:
g_Name[ i ][ 0 ] = EOS;

EOS is using for clearing variable only ?

It is NOT used for "clearing a variable". It is a special character only for strings.

lucas_7_94 09-09-2012 18:52

Re: Clear a variable
 
Explain what you try to do exactly , and we will give you a better answer or method maybe.

Aooka 09-12-2012 13:15

Re: Clear a variable
 
Oh thanks Micapat and Fysiks :)


All times are GMT -4. The time now is 08:12.

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