Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 10-03-2014 , 04:44   [Solved] CS16: A new method for Unlimited@Infinity Clip.
Reply With Quote #1

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.
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019

Last edited by yokomo; 10-04-2014 at 15:06. Reason: Problem solved. See https://forums.alliedmods.net/showpost.php?p=2207080&postcount=7
yokomo is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 10-03-2014 , 05:08   Re: [Help] CS16: A new method for Unlimited@Infinity Clip.
Reply With Quote #2

Ham_Item_AddToPlayer?
RateX is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-03-2014 , 11:59   Re: [Help] CS16: A new method for Unlimited@Infinity Clip.
Reply With Quote #3

Ham_AddPlayerItem and then check for the weaponid( new iId = cs_get_weapon_id( iWeaponEnt ) )
__________________
HamletEagle is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 10-03-2014 , 14:56   Re: [Help] CS16: A new method for Unlimited@Infinity Clip.
Reply With Quote #4

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
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019
yokomo is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-04-2014 , 09:53   Re: [Help] CS16: A new method for Unlimited@Infinity Clip.
Reply With Quote #5

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
__________________

Last edited by HamletEagle; 10-04-2014 at 09:56.
HamletEagle is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 10-04-2014 , 12:52   Re: [Help] CS16: A new method for Unlimited@Infinity Clip.
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
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".
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019
yokomo is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 10-04-2014 , 15:04   Re: [Solved] CS16: A new method for Unlimited@Infinity Clip.
Reply With Quote #7

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.
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019
yokomo is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-04-2014 , 15:33   Re: [Solved] CS16: A new method for Unlimited@Infinity Clip.
Reply With Quote #8

To solve your problem you can edit weaponbox props.
__________________
HamletEagle is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 06-01-2016 , 14:34   Re: [Solved] CS16: A new method for Unlimited@Infinity Clip.
Reply With Quote #9

Sorry to revive, Hamlet could you give an example about the weaponbox props pls..

Last edited by wicho; 06-01-2016 at 14:53.
wicho is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 06-02-2016 , 04:12   Re: [Solved] CS16: A new method for Unlimited@Infinity Clip.
Reply With Quote #10

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.
__________________

Last edited by Napoleon_be; 06-02-2016 at 04:27.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Reply


Thread Tools
Display Modes

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 17:29.


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