AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   setting ammo when reloading (https://forums.alliedmods.net/showthread.php?t=10506)

Cheap_Suit 02-21-2005 12:58

setting ammo when reloading
 
Code:

#include<amxmodx>
#include<cstrike>
#include<engine>

public plugin_init(){
        register_plugin("Test","1.0","cheap_suit")
}

public reload(){
        if(get_user_button(id)&IN_RELOAD){
        cs_set_weapon_ammo ( id,0)
        }
}

cant you tell me whats wrong?

xeroblood 02-21-2005 13:39

ya, your public reload() function never gets called..

what are you trying to do?

Cheap_Suit 02-21-2005 14:38

trying to set ammo to 0 when they press reload

knekter 02-21-2005 14:56

easy
 
I would use client_PreThink, like this:

Code:
public client_PreThink(id) {     if(get_user_button(id) & IN_RELOAD) {         new clip, ammo         new weapon = get_user_weapon(id, clip, ammo)         cs_set_user_bpammo(id, weapon, 0)     }     return PLUGIN_HANDLED }

Cheap_Suit 02-21-2005 18:01

Code:

#include<amxmodx>
#include<cstrike>
#include<engine>

public plugin_init(){
  register_plugin("fullclipreload","1.0","cheap_suit")
}

public client_PreThink(id) {

    if(get_user_button(id) & IN_RELOAD) {

        new clip = cs_get_weapon_ammo(id)

        cs_set_weapon_ammo(clip, 0)
    }

    return PLUGIN_HANDLED
}

please tell me whats wrong with it?

hellraser 03-05-2005 07:59

you never call the function,thats why it doesn't work...

xeroblood 03-05-2005 09:07

client_PreThink() is an AMXX forward, so it gets called by AMXX..

But, that's not the problem, the problem is:

cs_set_weapon_ammo(clip, 0)

The first parameter should not be the clip, but the user index..

from cstrike.inc:

native cs_set_weapon_ammo(index, newammo);

Cheap_Suit 03-12-2005 19:18

so will work?
Code:


#include<amxmodx>
#include<cstrike>
#include<engine>

public plugin_init(){
  register_plugin("fullclipreload","1.0","cheap_suit")
}

public client_PreThink(id) {

    if(get_user_button(id) & IN_RELOAD) {

      cs_set_weapon_ammo(id, 0)
    }

    return PLUGIN_HANDLED
}


larnk 03-12-2005 21:14

Wrong...
cs_set_weapon_ammo(id,ammo)

this id is not user id, this the weapon's id
below is an example

Code:
public cs_set_user_ammo(id,ammount)     new iWPNidx = -1,wpn[32],clip,ammo      new weaponid=get_user_weapon(id, clip, ammo)     get_weaponname(weaponid,wpn,31)     while ((iWPNidx = find_ent_by_class(iWPNidx, wpn)) != 0){         if (id == entity_get_edict(iWPNidx, EV_ENT_owner)) {             cs_set_weapon_ammo(iWPNidx,ammount)        }    } }
[/small]

XxAvalanchexX 03-13-2005 13:57

Yes, cheap_suit, the most recent code you posted should work. Larnk's will give you a plethora of warnings and errors.


All times are GMT -4. The time now is 14:07.

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