Code:
#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <cstrike>
#define Plugin "Weapon Chance"
#define Version "1.0"
#define Author "Doombringer"
#define TIME_TO_WAIT 5.0
public plugin_init() {
register_plugin(Plugin, Version, Author)
register_logevent("round_start", 2, "1=Round_Start")
}
public main_func() {
new players[32], num
get_players(players, num)
new player
for ( new i = 0 ; i < num ; i++ ) {
player = players[i]
if(random_num(1, 100) <= 5)
{
give_weapon(player, CSW_AWP, 1, 0)
client_print(player, print_chat, "You were lucky, you got a AWP with 1 bullet (5 percent chance)")
}
if(random_num(1, 100) <= 1)
{
give_weapon(player, CSW_FIVESEVEN, 20, 0)
client_print(player, print_chat, "You were lucky, you got a five seven with 20 bullets (1 percent chance)")
}
if(random_num(1, 100) <= 10)
{
give_weapon(player, CSW_DEAGLE, 1, 0)
client_print(player, print_chat, "You were lucky, you got a deagle with 1 bullet (10 percent chance)")
}
if(random_num(1, 100) <= 15)
{
give_item(player, "weapon_hegrenade")
client_print(player, print_chat, "You were lucky, you got a hegrenade (15 percent chance)")
}
if(random_num(1, 100) <= 15)
{
give_item(player, "weapon_smokegrenade")
client_print(player, print_chat, "You were lucky, you got a smokegrenade (15 percent chance)")
}
if(random_num(1, 100) <= 20)
{
give_item(player, "weapon_shield")
client_print(player, print_chat, "You were lucky, you got a shield (20 percent chance)")
}
if(random_num(1, 100) <= 25)
{
give_weapon(player, CSW_GLOCK18, 2, 0)
client_print(player, print_chat, "You were lucky, you got a glock with 2 bullets (25 percent chance)")
}
if(random_num(1, 100) <= 25)
{
give_weapon(player, CSW_USP, 2, 0)
client_print(player, print_chat, "You were lucky, you got a usp with 2 bullets (25 percent chance)")
}
}
}
public round_start()
{
set_task(TIME_TO_WAIT, "main_func")
}
stock fm_get_weapon_id(index, const weapon[]) {
new ent = -1;
while ( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", weapon) ) != 0 ) {
if(index == pev(ent, pev_owner))
return ent;
}
return 1;
}
stock give_weapon(id, wpnID, ammo, bpammo) {
new weapon[32]
get_weaponname(wpnID, weapon, 31)
give_item(id, weapon)
cs_set_weapon_ammo(fm_get_weapon_id(id, weapon), ammo);
cs_set_user_bpammo(id, wpnID, cs_get_user_bpammo(id, wpnID) + bpammo)
}