Raised This Month: $ Target: $400
 0% 

Equal and sizeof.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 08-10-2011 , 03:36   Re: Equal and sizeof.
Reply With Quote #1

Ight so here is the edited one... DK why you had the sizeof there... but here ya go

When player types m4a1 he recieves one (tested scout, m4a1, p90)
PHP Code:
#include <amxmodx>
#include <fun>

//WPN
new weapon_list[9][] = {
    
"scout",
    
"sg550",
    
"famas",
    
"usp",
    
"awp",
    
"m249",
    
"m4a1",
    
"deagle",
    
"p90"
};

public 
plugin_init() {
    
register_plugin("WPN""0.01""Ex3cuTioN");
    
register_clcmd("say","cmdWPN");
}

public 
cmdWPN(id) {
    static 
s_Args[32];
    
read_args(s_Argscharsmax(s_Args));
    
    if(!
s_Args[0])
        return 
PLUGIN_CONTINUE;
        
    
remove_quotes(s_Args);
    
    for(new 
09i++) 
    {
        if(
equal(s_Args weapon_list[i]))
        {
            
//Dont need to replace beacsue you use Equal.. It wont take /m4a1

            
new weaponName[32];
            
format(weaponNamecharsmax(weaponName), "weapon_%s"s_Args);
            
            
give_item(idweaponName);
            
client_print(idprint_chat"You received %s"weaponName);
        }
    }
    
    return 
PLUGIN_CONTINUE;


Last edited by Doc-Holiday; 08-10-2011 at 03:44.
Doc-Holiday is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-10-2011 , 09:22   Re: Equal and sizeof.
Reply With Quote #2

Another way without looping for string matches:
PHP Code:
#include <amxmodx>
#include <fun>

//WPN
new weapon_list 
    (
1<<CSW_SCOUT) |
    (
1<<CSW_SG550) |
    (
1<<CSW_FAMAS) |
    (
1<<CSW_USP) |
    (
1<<CSW_AWP) |
    (
1<<CSW_M249) |
    (
1<<CSW_M4A1) |
    (
1<<CSW_DEAGLE) |
    (
1<<CSW_P90)
;

public 
plugin_init() {
    
register_plugin("WPN""0.01""Ex3cuTioN");
    
register_clcmd("say","cmdWPN");
}

public 
cmdWPN(id) {
    static 
s_Args[32];
    
read_args(s_Argscharsmax(s_Args));
    
    if(!
s_Args[0])
        return 
PLUGIN_CONTINUE;
        
    
remove_quotes(s_Args);
    
strtolower(s_Args);
    
format(s_Argscharsmax(s_Args), "weapon_%s"s_Args);
    
    new 
weaponID get_weaponid(s_Args);
    
    if(
weaponID && (weapon_list & (1<<weaponID)))
    {
        
give_item(ids_Args);
        
client_print(idprint_chat"You received %s"s_Args);
    }
    
    return 
PLUGIN_CONTINUE;

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 03:31.


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