AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Using code (https://forums.alliedmods.net/showthread.php?t=184718)

Randomize 05-08-2012 06:46

Using code
 
is this code give bots a weapon, isn't it?

Quote:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

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


public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_concmd("amx_giveweapon", "buyhelmet")
}
new const g_Weapons[33][] = {
"", "p228", "shield", "scout", "hegrenade",
"xm1014","c4", "mac10", "aug", "smokegrenade",
"elite", "fiveseven", "ump45", "sg550", "galil",
"famas", "usp", "glock18", "awp", "mp5",
"m249", "m3", "m4a1", "tmp", "g3sg1",
"flashbang", "deagle", "sg552", "ak47", "knife",
"p90", "kevlar", "assault"
}

new g_MaxBPAmmo[33] = {0,52,0,90,0,32,0,100,90,0,120,100,100,90,90, 90,100,120,30,120,200,21,90,120,90,0,35,90,90 ,0,100,0,0}

public cmd_giveweapon(id) {
if ( ! ( get_user_flags(id) & ADMIN_KICK ) )
return PLUGIN_CONTINUE

new arg1[32], arg2[32]

read_argv(1, arg1, 31)
read_argv(2, arg2, 31)

new target = cmd_target(id, arg1, 0)

if ( ! target )
return PLUGIN_CONTINUE

new weap[40] = "weapon_"

for ( new i = 1; i < 33; i++ ) {

if( equali(arg2, g_Weapons[i]) ) {

copy(weap[7], 32, g_Weapons[i])

give_item(target , weap)

if ( i != 2 && i != 4 && i != 6 && i != 9 && i != 25 && i != 29 && i != 31 && i != 32 )
cs_set_user_bpammo(id, i, g_MaxBPAmmo[i])

return PLUGIN_CONTINUE
}
}

client_print(id, print_console, "Weapon ^"%s^" was not found", arg2)

return PLUGIN_CONTINUE
}

Diegorkable 05-08-2012 09:04

Re: Using code
 
There is something wrong in your code:
(Its your paste not a new one I've editted)

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

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


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_concmd("amx_giveweapon""buyhelmet")
}
new const 
g_Weapons[33][] = {
    
"""p228""shield""scout""hegrenade",
    
"xm1014","c4""mac10""aug""smokegrenade",
    
"elite""fiveseven""ump45""sg550""galil",
    
"famas""usp""glock18""awp""mp5",
    
"m249""m3""m4a1""tmp""g3sg1",
    
"flashbang""deagle""sg552""ak47""knife",
    
"p90""kevlar""assault"
}

new 
g_MaxBPAmmo[33] = {0,52,0,90,0,32,0,100,90,0,120,100,100,90,9090,100,120,30,120,200,21,90,120,90,0,35,90,90 ,0,100,0,0}

public 
cmd_giveweapon(id) {
    if ( ! ( 
get_user_flags(id) & ADMIN_KICK ) )
        return 
PLUGIN_CONTINUE
    
    
new arg1[32], arg2[32]
    
    
read_argv(1arg131)
    
read_argv(2arg231
    
    new 
target cmd_target(idarg10)
    
    if ( ! 
target )
        return 
PLUGIN_CONTINUE
    
    
new weap[40] = "weapon_"
    
    
for ( new 133i++ ) {
        
        if( 
equali(arg2g_Weapons[i]) ) {
            
            
copy(weap[7], 32g_Weapons[i])
            
            
give_item(target weap)
            
            if ( 
!= && != && != && != && != 25 && != 29 && != 31 && != 32 )
                
cs_set_user_bpammo(idig_MaxBPAmmo[i])
            
            return 
PLUGIN_CONTINUE
        
}
    }
    
    
client_print(idprint_console"Weapon ^"%s^" was not found"arg2)
    
    return 
PLUGIN_CONTINUE


*There is a register_clcmd at plugin_init, which registers a command for a non-existing function: 'buyhelmet:

*The function 'cmd_giveweapon' is not being used.

But if you meant that the register_clcmd would be for the cmd_giveweapon function. Then the code is indeed giving a weapon to whoever you choose to give to, not specifically bots, could be players aswell.

So if you want the register_clcmd to be related to the cmd_giveweapon, then the code should look like this:

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

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


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_concmd("amx_giveweapon""cmd_giveweapon")
}
new const 
g_Weapons[33][] = {
    
"""p228""shield""scout""hegrenade",
    
"xm1014","c4""mac10""aug""smokegrenade",
    
"elite""fiveseven""ump45""sg550""galil",
    
"famas""usp""glock18""awp""mp5",
    
"m249""m3""m4a1""tmp""g3sg1",
    
"flashbang""deagle""sg552""ak47""knife",
    
"p90""kevlar""assault"
}

new 
g_MaxBPAmmo[33] = {0,52,0,90,0,32,0,100,90,0,120,100,100,90,9090,100,120,30,120,200,21,90,120,90,0,35,90,90 ,0,100,0,0}

public 
cmd_giveweapon(id) {
    if ( ! ( 
get_user_flags(id) & ADMIN_KICK ) )
        return 
PLUGIN_CONTINUE
    
    
new arg1[32], arg2[32]
    
    
read_argv(1arg131)
    
read_argv(2arg231
    
    new 
target cmd_target(idarg10)
    
    if ( ! 
target )
        return 
PLUGIN_CONTINUE
    
    
new weap[40] = "weapon_"
    
    
for ( new 133i++ ) {
        
        if( 
equali(arg2g_Weapons[i]) ) {
            
            
copy(weap[7], 32g_Weapons[i])
            
            
give_item(target weap)
            
            if ( 
!= && != && != && != && != 25 && != 29 && != 31 && != 32 )
                
cs_set_user_bpammo(idig_MaxBPAmmo[i])
            
            return 
PLUGIN_CONTINUE
        
}
    }
    
    
client_print(idprint_console"Weapon ^"%s^" was not found"arg2)
    
    return 
PLUGIN_CONTINUE


Try it now.

Usage (in console): amx_giveweapon <Player Name/#UserID/AuthID> <Weapon name from g_Weapons variable>

Randomize 05-08-2012 20:27

Re: Using code
 
wew.. thank you so much :)


All times are GMT -4. The time now is 00:27.

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