AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need plugin resupply ammo when I choose a player (https://forums.alliedmods.net/showthread.php?t=132525)

CrazyChickenTest 07-15-2010 17:42

Need plugin resupply ammo when I choose a player
 
Hi!
Need plugin to resupply ammo when I choose a player and press +USE. Something like this http://forums.alliedmods.net/showthread.php?t=62756 but I need to resupply ammo. Sorry for my not good english. Thx for help

DarkGod 07-15-2010 17:44

Re: Need plugin resupply ammo when I choose a player
 
Choose as in aim on? Or what?

Sylwester 07-15-2010 18:05

Re: Need plugin resupply ammo when I choose a player
 
short and simple:
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fakemeta>

new pcvar_interval
new pcvar_range
new g_max_bpammo[33] = {0,52,0,90,1,32,1,100,90,1,120,100,100,90,90,90,100,120,30,120,200,32,90,120,90,2,35,90,90,0,100,0,0}

public 
plugin_init(){
    
register_plugin("ResupplyTargetAmmo""1.0""Sylwester")
    
pcvar_interval register_cvar("resupply_interval""0.5")
    
pcvar_range register_cvar("resupply_range""100.0")
    
register_forward(FM_PlayerPreThink"player_PreThink")
}


public 
player_PreThink(id){
    static 
Float:last_time[33]
    if(!
is_user_alive(id))
        return
    new 
Float:time get_gametime()
    if(
time last_time[id] < get_pcvar_float(pcvar_interval))
        return
    if(!(
pev(idpev_button) & IN_USE))
        return
    new 
targetbody
    
new Float:distance get_user_aiming(idtargetbody)
    if(!
is_user_alive(target)
    || 
distance get_pcvar_float(pcvar_range)
    || 
cs_get_user_team(target)!=cs_get_user_team(id))
        return

    new 
clipbpweapon
    weapon 
get_user_weapon(targetclipbp)
    if(
bp g_max_bpammo[weapon])
        
cs_set_user_bpammo(targetweaponbp+1)
    
last_time[id] = time



DarkGod 07-15-2010 18:10

Re: Need plugin resupply ammo when I choose a player
 
Wouldn't it be better to just use CmdStart?

Sylwester 07-15-2010 18:19

Re: Need plugin resupply ammo when I choose a player
 
Maybe, but if you talk about cases where prethink is called more often, then on the other hand there will be little longer delay before giving ammo. There are many things that would be better (starting with caching most of the stuff), but I don't have time to make perfect version and besides this is scripting help, not suggestions/requests.

CrazyChickenTest 07-16-2010 03:40

Re: Need plugin resupply ammo when I choose a player
 
Sylwester thx it working ;)
Topic is ready for close

SpeeDeeR 07-16-2010 19:54

Re: Need plugin resupply ammo when I choose a player
 
I think this was for Suggestions/Requests.


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

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