Raised This Month: $ Target: $400
 0% 

Adding ammo to weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 12-10-2011 , 14:47   Adding ammo to weapon
Reply With Quote #1

Something is wrong in this code, and I don't know what :/

PHP Code:
public PlayerKilled(victimattackershouldgib)
{
    new 
iWeapon get_user_weapon(attacker__);
    
cs_set_weapon_ammo(iWeaponcs_get_weapon_ammo(iWeapon) + 1)

Also a question, how to detect with what weapon Attacker killed victim ?

Last edited by reinert; 12-10-2011 at 14:48.
reinert is offline
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 12-10-2011 , 15:02   Re: Adding ammo to weapon
Reply With Quote #2

For your second question.
If you don't absolutely need to use Ham_Killed
Then the DeathMsg event already has that prepared for you.
PHP Code:
event_death()
new 
szWeapon[14]
read_data4szWeaponcharsmax(szWeapon) ) 
Erox902 is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 12-10-2011 , 16:05   Re: Adding ammo to weapon
Reply With Quote #3

Well, would be greater if I could do this in Ham_Killed because then I don't need to hook death event twice.
reinert is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 12-10-2011 , 17:38   Re: Adding ammo to weapon
Reply With Quote #4

Not tested.
PHP Code:
#include <engine>
#include <cstrike>

public plugin_init()
    
register_event("DeathMsg""OnDeathMsg""a");

public 
OnDeathMsg()
{
    new 
killer read_data(1);

    if (!
is_user_alive(killer))
        return;
    
    new 
weap[32] = "weapon_";
    
read_data(4weap[7], charsmax(weap[7]));
    
    if (
equal(weap"weapon_hegrenade"))
        return;
    
    new 
ent find_ent_by_owner(killer 1weapkiller);
    
    if (
ent killer)
        
cs_set_weapon_ammo(entcs_get_weapon_ammo(ent) + 1);

__________________
hleV is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 12-10-2011 , 18:06   Re: Adding ammo to weapon
Reply With Quote #5

possible to check what weapon was used in Ham_Killed ?
reinert 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 15:19.


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