AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Adding ammo to weapon (https://forums.alliedmods.net/showthread.php?t=173791)

reinert 12-10-2011 14:47

Adding ammo to weapon
 
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 ?

Erox902 12-10-2011 15:02

Re: Adding ammo to weapon
 
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) ) 


reinert 12-10-2011 16:05

Re: Adding ammo to weapon
 
Well, would be greater if I could do this in Ham_Killed because then I don't need to hook death event twice.

hleV 12-10-2011 17:38

Re: Adding ammo to weapon
 
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);



reinert 12-10-2011 18:06

Re: Adding ammo to weapon
 
possible to check what weapon was used in Ham_Killed ?


All times are GMT -4. The time now is 11:51.

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