#include <amxmodx>
#include <fakemeta>
#include <fun>
#define MAX_WEAPONS 39
// Define weapons pool (所有武器)
const String:weapons[MAX_WEAPONS] = {
"weapon_ak47", "weapon_awp", "weapon_deagle", "weapon_famas", "weapon_m4a1",
"weapon_p90", "weapon_usp", "weapon_knife", "weapon_scout", "weapon_xm1014",
"weapon_mac10", "weapon_ump45", "weapon_glock18", "weapon_fiveseven", "weapon_p250",
"weapon_tec9", "weapon_m3", "weapon_m249", "weapon_aug", "weapon_elite",
"weapon_sg550", "weapon_sg552", "weapon_galil", "weapon_flamer", "weapon_c4",
"weapon_shield", "weapon_nova", "weapon_scout", "weapon_m249", "weapon_m3",
"weapon_flamer", "weapon_mach", "weapon_hkp2000", "weapon_ump45", "weapon_knife",
"weapon_mp5navy", "weapon_g3sg1", "weapon_sg552", "weapon_cz75auto"
};
public plugin_init() {
register_plugin("Random Weapon on Round Start", "1.0", "kakke");
// Register the event for round start
register_event("HLTV", "round_start", "a", "1=0", "2=1");
// Check if the plugin is enabled through the cvar
if (get_cvar_num("sv_random_weapon_enabled") == 0) {
return; // If the plugin is disabled in the config, exit the plugin initialization
}
}
public round_start() {
// Check if the plugin is enabled through the cvar
if (get_cvar_num("sv_random_weapon_enabled") == 0) {
return; // If the plugin is disabled in the config, don't execute the weapon assignment
}
// Loop through all players to assign them a random weapon
for (new i = 1; i <= get_maxplayers(); i++) {
if (is_user_connected(i)) {
// Pick a random weapon
new random_weapon = get_random_int(0, MAX_WEAPONS - 1);
give_player_weapon(i, random_weapon);
}
}
}
public give_player_weapon(player, random_weapon) {
// Get the weapon name from the array
new weapon[32];
strcopy(weapon, sizeof(weapon), weapons[random_weapon]);
// Give the player the weapon
client_cmd(player, "use %s", weapon);
}
sv_random_weapon_enabled 1 // 启用插件,设置为 0 禁用插件