View Single Post
Author Message
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 06-29-2020 , 03:09   Detect if the weapon has a bullet
Reply With Quote #1

Hi everyone, well I'm doing something like a mini game of usp (pistol) that tries that when the round begins it gives everyone a usp with only one bullet ready to fire, every 5 seconds it gives a bullet, my question is how can I to detect if the player still has the bullet? What I want to do is that if the player still has the bullet, he will not get another bullet, so he will not accumulate bullets, but until he has no bullets and so on.

PHP Code:
#include <amxmodx>
#include <fun>
#include <cstrike>

#define PLUGIN "Battle Usp"
#define VERSION "1.0"
#define AUTHOR "khe"

new g_MaxPlayers

#define TASK_BULLET 655

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("HLTV""NewRound""a""1=0""2=0")

    
g_MaxPlayers get_maxplayers()
}

public 
NewRound() 
{    
    for (new 
id 1id <= g_MaxPlayersid++)
    {
        if (!
is_user_alive(id))
            continue

        
show_menu(id0"^n"1)        
        
strip_user_weapons(id)   
        
cs_set_weapon_ammo(give_item(id"weapon_usp"), 1)
        
set_task(5.0"Task_GiveBullet"id+TASK_BULLET__"b")
    }
}

public 
Task_GiveBullet(id)
{
    
id -= TASK_BULLET
    
    cs_set_weapon_ammo
(give_item(id"weapon_usp"), 1)

wicho is offline