AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] CS16: A new method for Unlimited@Infinity Clip. (https://forums.alliedmods.net/showthread.php?t=249244)

yokomo 10-03-2014 04:44

[Solved] CS16: A new method for Unlimited@Infinity Clip.
 
Hi coders,

Now i want to use this method:
PHP Code:

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

public plugin_init()
{
    
register_plugin("UC Other Method""0.0.1""wbyokomo")
    
    
register_clcmd("say /uc""CmdUC")
}

public 
CmdUC(id)
{
    if(!
is_user_alive(id)) return;
    
    
strip_user_weapons(id)
    
give_item(id"weapon_knife")
    new 
wpn give_item(id"weapon_mp5navy")
    if(
wpn != -1)
    {
        
cs_set_weapon_ammo(wpn32767//set infinity clip
        
cs_set_user_bpammo(idCSW_MP5NAVY0//prevent reloading
    
}
}

//But the problem is when someone get a new weapon, i need to check all current weapon enyity and set infinity clip like method above.
//So what kind of forward that suitable to hook when player get a new weapons?
//I don't want to use CurWeapon message, it's called to often.
//Is "Ham_Item_AttachToPlayer" good to use? 

So what kind of forward that suitable to hook when player get a new weapons?

Thanks.

RateX 10-03-2014 05:08

Re: [Help] CS16: A new method for Unlimited@Infinity Clip.
 
Ham_Item_AddToPlayer?

HamletEagle 10-03-2014 11:59

Re: [Help] CS16: A new method for Unlimited@Infinity Clip.
 
Ham_AddPlayerItem and then check for the weaponid( new iId = cs_get_weapon_id( iWeaponEnt ) )

yokomo 10-03-2014 14:56

Re: [Help] CS16: A new method for Unlimited@Infinity Clip.
 
Ok rewrite the code, but why the bpammo not set properly when 1st time i pickup the new weapon?
I need to drop then re-pickup it and then the bpammo set correctly.

Code

HamletEagle 10-04-2014 09:53

Re: [Help] CS16: A new method for Unlimited@Infinity Clip.
 
PHP Code:

 if(bInfinityClip[id])
    {
        
bInfinityClip[id] = false
        client_print
(idprint_chat"CmdSetInfinityClip(%d) DISABLED!"id)
    }
    else
    {
        
bInfinityClip[id] = true
        client_print
(idprint_chat"CmdSetInfinityClip(%d) ENABLED!"id)
    } 

->

PHP Code:

bInfinityClip[id] = !bInfinityClip[id
client_print(idprint_chat"CmdSetInfinityClip(%d) %s!"idbInfinityClip[id] ? "ENABLED" "DISABLED"

More simple way. You may try to hook Ham_Item_AttachToPlayer instead of Ham_AddPlayerItem

yokomo 10-04-2014 12:52

Re: [Help] CS16: A new method for Unlimited@Infinity Clip.
 
Quote:

Originally Posted by HamletEagle (Post 2206956)
PHP Code:

 if(bInfinityClip[id])
    {
        
bInfinityClip[id] = false
        client_print
(idprint_chat"CmdSetInfinityClip(%d) DISABLED!"id)
    }
    else
    {
        
bInfinityClip[id] = true
        client_print
(idprint_chat"CmdSetInfinityClip(%d) ENABLED!"id)
    } 

->

PHP Code:

bInfinityClip[id] = !bInfinityClip[id
client_print(idprint_chat"CmdSetInfinityClip(%d) %s!"idbInfinityClip[id] ? "ENABLED" "DISABLED"

More simple way. You may try to hook Ham_Item_AttachToPlayer instead of Ham_AddPlayerItem

That was just example, Ok i'll try to use "Ham_Item_AttachToPlayer".

yokomo 10-04-2014 15:04

Re: [Solved] CS16: A new method for Unlimited@Infinity Clip.
 
Problem solved, it was HL1 engine issue, it need task to set bpammo.

Code


This method only suitable to use on server that has no weapon drop feature. Because when you drop your weapon and someone pickup it he will get the infinity clip in weaponbox too. But that ammo will be reset if he reload the weapon.

HamletEagle 10-04-2014 15:33

Re: [Solved] CS16: A new method for Unlimited@Infinity Clip.
 
To solve your problem you can edit weaponbox props.

wicho 06-01-2016 14:34

Re: [Solved] CS16: A new method for Unlimited@Infinity Clip.
 
Sorry to revive, Hamlet could you give an example about the weaponbox props pls..

Napoleon_be 06-02-2016 04:12

Re: [Solved] CS16: A new method for Unlimited@Infinity Clip.
 
Not that it is required, but you could store all your weapons into a constant and then loop trough it in your plugin_init function to optimize your code & make it look better.

something like this?
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

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

new const szWeapons[][] = {
    
"weapon_glock18",
    
"weapon_usp",
    
"weapon_deagle",
    
"weapon_p228",
    
"weapon_elite",
    
"weapon_fiveseven",
    
"weapon_m3",
    
"weapon_xm1014",
    
"weapon_mp5navy",
    
"weapon_mac10",
    
"weapon_tmp",
    
"weapon_p90",
    
"weapon_ump45",
    
"weapon_galil",
    
"weapon_famas",
    
"weapon_ak47",
    
"weapon_m4a1",
    
"weapon_sg552",
    
"weapon_aug",
    
"weapon_g3sg1",
    
"weapon_sg550",
    
"weapon_scout",
    
"weapon_awp",
    
"weapon_m249"
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    new 
szTemp[555 char]
    for(new 
isizeof(szWeapons); i++) {
        
formatex(szTempcharsmax(szTemp), "%s"szWeapons[i])
        
RegisterHam(Ham_Item_DeployszTemp"OnItemDeployPost"1)
    }


EDIT: NVM, didn't notice date of topic.


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

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