Raised This Month: $51 Target: $400
 12% 

Clear a variable


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MagNeto
Member
Join Date: May 2009
Old 09-08-2012 , 03:20   Clear a variable
Reply With Quote #1

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!
MagNeto is offline
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 09-08-2012 , 03:51   Re: Clear a variable
Reply With Quote #2

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;     } }
OvidiuS is offline
Send a message via Skype™ to OvidiuS
Old 09-08-2012, 06:13
hleV
This message has been deleted by hleV.
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-08-2012 , 13:49   Re: Clear a variable
Reply With Quote #3

Using an array like that is extremely inefficient, use a Trie. Also, using a name to identify somebody is very unreliable, use SteamID.
__________________
fysiks is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 09-09-2012 , 15:28   Re: Clear a variable
Reply With Quote #4

Code:
g_Name[ i ][ 0 ] = EOS;

EOS is using for clearing variable only ?
__________________
Pawn ? Useless
Aooka is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 09-09-2012 , 15:50   Re: Clear a variable
Reply With Quote #5

EOS = End Of String = '^0' = 0
__________________
micapat is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-09-2012 , 18:22   Re: Clear a variable
Reply With Quote #6

Quote:
Originally Posted by Aooka View Post
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.
__________________
fysiks is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 09-09-2012 , 18:52   Re: Clear a variable
Reply With Quote #7

Explain what you try to do exactly , and we will give you a better answer or method maybe.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 09-12-2012 , 13:15   Re: Clear a variable
Reply With Quote #8

Oh thanks Micapat and Fysiks
__________________
Pawn ? Useless
Aooka is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:17.


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