Raised This Month: $ Target: $400
 0% 

in_array(); => pawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sn!ff3r
Veteran Member
Join Date: Aug 2007
Location: Poland
Old 05-25-2009 , 19:01   in_array(); => pawn
Reply With Quote #1

As title, I need replacment for in_array(); function from PHP. Anybody know ?
__________________
Join US - custom Zombie Server - Custom Addons:



Sn!ff3r is offline
Send a message via Skype™ to Sn!ff3r
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-25-2009 , 19:02   Re: in_array(); => pawn
Reply With Quote #2

What does the function do, what are its arguments, and what does it return?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-25-2009 , 21:25   Re: in_array(); => pawn
Reply With Quote #3

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "bugsy"

new iArray[] = { 23 55 56 122 }
new 
szArray[] = { "hello" "world" "amxmodx" }

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    if ( 
InArray23 iArray sizeof iArray ) )
        
server_print("found it integer" )
    else
        
server_print("not found integer" );
        
    if ( 
InArrayString"world" szArray ) )
        
server_print("found it string" )
    else
        
server_print("not found string" );
}

//Integer
public InArray( const iValue , const iArray[] , const iArraySize )
{
    for ( new 
<  iArraySize i++ )
        if ( 
iValue == iArray[i] )
            return 
1;

    return 
0;
}

//String
public InArrayString( const szValue[] , const szArray[] , const iArraySize )
{
    for ( new 
iArraySize i++ )
        if ( 
equaliszValue szArray[i] ) )
            return 
1;
    
    return 
0;

__________________

Last edited by Bugsy; 05-25-2009 at 21:30.
Bugsy is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 05-25-2009 , 21:29   Re: in_array(); => pawn
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "bugsy" new iArray[] = { 1 , 23 , 55 , 56 , 122 } new szArray[][] = { "hello" , "world" , "amxmodx" } public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         if ( InArray( 23 , iArray , sizeof iArray ) )         server_print("found it integer" )     else         server_print("not found integer" );             if ( InArrayString( "world" , szArray , sizeof szArray[] ) )         server_print("found it string" )     else         server_print("not found string" ); } //Integer public InArray( const iValue , const iArray[] , const iArraySize ) {     for ( new i = 0 ; i <  iArraySize ; i++ )         if ( iValue == iArray[i] )             return 1;     return 0; } //String public InArrayString( const szValue[] , const szArray[][] , const iArraySize ) {     for ( new i = 0 ; i < iArraySize ; i++ )         if ( equali( szValue , szArray[i] ) )             return 1;         return 0; }
__________________
stupok is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-25-2009 , 21:41   Re: in_array(); => pawn
Reply With Quote #5

Quote:
Originally Posted by stupok View Post
Quote:
Originally Posted by Bugsy View Post
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "bugsy" new iArray[] = { 1 , 23 , 55 , 56 , 122 } new szArray[][] = { "hello" , "world" , "amxmodx" } public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         if ( InArray( 23 , iArray , sizeof iArray ) )         server_print("found it integer" )     else         server_print("not found integer" );             if ( InArrayString( "world" , szArray , sizeof szArray ) )         server_print("found it string" )     else         server_print("not found string" ); } //Integer public InArray( const iValue , const iArray[] , const iArraySize ) {     for ( new i = 0 ; i <  iArraySize ; i++ )         if ( iValue == iArray[i] )             return 1;     return 0; } //String public InArrayString( const szValue[] , const szArray[][] , const iArraySize ) {     for ( new i = 0 ; i < iArraySize ; i++ )         if ( equali( szValue , szArray[i] ) )             return 1;         return 0; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-25-2009 , 21:53   Re: in_array(); => pawn
Reply With Quote #6

Thanks Exolent, pardon my typo, I just got in from playing horse-shoes and drinking beer.

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "bugsy"

new iArray[] = { 23 55 56 122 }
new 
szArray[][] = { "hello" "world" "amxmodx" }

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    if ( 
InArray23 iArray sizeof iArray ) )
        
server_print("found it integer" )
    else
        
server_print("not found integer" );
        
    if ( 
InArrayString"world" szArray sizeof szArray ) )
        
server_print("found it string" )
    else
        
server_print("not found string" );
}

//Integer
public InArray( const iValue , const iArray[] , const iArraySize )
{
    for ( new 
<  iArraySize i++ )
        if ( 
iValue == iArray[i] )
            return 
1;

    return 
0;
}

//String
public InArrayString( const szValue[] , const szArray[][] , const iArraySize )
{
    for ( new 
iArraySize i++ )
        if ( 
equaliszValue szArray[i] ) )
            return 
1;
    
    return 
0;

@stupok



Code:
Warning: Indeterminate array size in "sizeof" expression (symbol "") on line 19

found it integer
not found string
__________________

Last edited by Bugsy; 05-25-2009 at 21:56.
Bugsy 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 01:29.


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