I've tried to make an Weapon Chance plugin, i get no error's but it doesnt give out items ingame..
Srry bad english.
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <engine>
#define PLUGIN "Weapon Chance"
#define AUTHOR "FaktuM"
#define VERSION "1.0"
new gMaxPlayers;
new szName[32];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_event("HLTV", "eventRoundStart", "a", "1=0", "2=0");
gMaxPlayers = get_maxplayers();
}
public eventRoundStart()
{
set_task(5.0, "WeaponChance");
}
public WeaponChance()
{
for(new id = 1; id <= gMaxPlayers; id++)
{
if(is_user_connected(id) && is_user_alive(id))
{
switch(get_user_team(id))
{
case 1:
{
if(random_num(0, 100) <= 20)
{
give_item(id, "weapon_hegrenade");
client_print(id, print_chat, "You got a HE! (20%% chance)");
}
}
case 2:
{
if(random_num(0, 100) <= 30)
{
give_item(id, "weapon_flashbang");
client_print(id, print_chat, "You got a flashbang! (30%% chance)");
}
}
case 3:
{
if(random_num(0, 100) <= 1)
{
give_item(id, "weapon_awp");
cs_set_weapon_ammo(find_ent_by_owner(2, "weapon_awp", id), 1);
client_print(id, print_chat, "You got an awp with 2 bullets! (1%% chance)");
get_user_name(id, szName, 31);
client_print(0, print_chat, "[Weapon Chance] %s has recived an awp with two bullets, aware!", szName);
}
}
case 4:
{
if(random_num(0, 100) <= 5)
{
set_user_health(id, 150);
client_print(id, print_chat, "You recived 150 health! (5%% chance)");
}
}
case 5:
{
if(random_num(0, 100) <= 10)
{
give_item(id, "weapon_fiveseven");
cs_set_weapon_ammo(find_ent_by_owner(1, "weapon_fiveseven", id), 1);
client_print(id, print_chat, "You recived an Fiveseven with 1 bullet! (10%% chance)");
}
}
case 6:
{
if(random_num(0, 100) <= 5)
{
give_item(id, "weapon_deagle");
cs_set_weapon_ammo(find_ent_by_owner(1, "weapon_deagle", id), 1);
client_print(id, print_chat, "You recived an Deagle with 1 bullet! (5%% chance)");
}
}
case 7:
{
if(random_num(0, 100) <= 10)
{
give_item(id, "weapon_usp");
cs_set_weapon_ammo(find_ent_by_owner(1, "weapon_usp", id), 1);
client_print(id, print_chat, "You recived an Usp with 1 bullet! (10%% chance)");
}
}
case 8:
{
if(random_num(0, 100) <= 5)
{
give_item(id, "weapon_scout");
cs_set_weapon_ammo(find_ent_by_owner(1, "weapon_scout", id), 1);
client_print(id, print_chat, "You recived an Scout with 1 bullets! (5%% chance)");
}
}
case 9:
{
if(random_num(0, 100) <= 35)
{
set_user_armor(id, 100);
client_print(id, print_chat, "You recived 100 armor! (35%% chance)");
}
}
case 10:
{
if(random_num(0, 100) <= 20)
{
set_user_health(id, 115);
client_print(id, print_chat, "You recived 115 health! (20%% chance)");
}
}
}
}
}
}