Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <multicolors>
#include <geoip>
#define PLUGIN_VERSION "1.0"
public Plugin:myinfo = {
name = "Random",
author = "",
description = "Random weapons and stripping",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net/"
};
//LIST OF WEAPONS
#define MAX_WEAPONS 30
int LastWeaponNumber;
new const String:all_weapons[MAX_WEAPONS][] = {
"weapon_m4a1", "weapon_m4a1_silencer", "weapon_ak47", "weapon_aug", "weapon_awp", "weapon_bizon", "weapon_deagle", "weapon_elite", "weapon_famas",
"weapon_fiveseven", "weapon_G3SG1", "weapon_galilar", "weapon_glock", "weapon_hkp2000", "weapon_usp_silencer", "weapon_m249", "weapon_mac10",
"weapon_mp7", "weapon_mp9", "weapon_negev", "weapon_p90", "weapon_p250", "weapon_cz75a", "weapon_scar20",
"weapon_sg556", "weapon_ssg08", "weapon_taser", "weapon_tec9", "weapon_ump45", "weapon_revolver"
};
//On plugin start
public OnPluginStart () {
HookEvent("round_start", RoundStart);
RegAdminCmd("sm_forcechange", Command_forcechange, ADMFLAG_KICK, "[OG] Admin - don't like this weapon! :( ");
CreateConVar("sm_game_player_equip_version", PLUGIN_VERSION, "Game_Player_Equip Fix", FCVAR_NOTIFY|FCVAR_DONTRECORD);
}
public OnMapStart() {
ServerCommand("ammo_grenade_limit_total 0");
ServerCommand("ammo_grenade_limit_flashbang 0");
ServerCommand("mp_buytime 0");
ServerCommand("mp_maxmoney 0");
ServerCommand("mp_t_default_secondary none");
ServerCommand("mp_ct_default_secondary none");
ServerCommand("mp_maxrounds 0");
ServerCommand("mp_warmup_end");
ServerCommand("log off");
ServerCommand("sm_barrearmas_interval 0.01");
ServerCommand("mp_ct_default_melee weapon_knife");
ServerCommand("mp_t_default_melee weapon_knife");
LastWeaponNumber = 0;
}
// !FORCECHANGE
public Action:Command_forcechange(client, args) {
RandomWeapons();
}
// ROUND START DO RANDOMWEAPONS FUNCTION
public Action:RoundStart(Handle:event , const String: name[] , bool: dontBroadcast) {
ServerCommand("mp_ct_default_melee weapon_knife");
ServerCommand("mp_t_default_melee weapon_knife");
RandomWeapons();
}
//GIVE RANDOM WEAPON FUNCTION
public RandomWeapons() {
new Random;
Random = GetRandomInt(0, 29);
if (LastWeaponNumber != Random) {
CPrintToChatAll("{blue}[Original-Gamers]{default} Current Weapon:{olive} %s", all_weapons[Random]);
for (int i = 1; i < GetMaxClients(); ++i) {
if (IsClientInGame(i) && IsPlayerAlive(i)) {
new ent = GetPlayerWeaponSlot(i, 0);
new ent1 = GetPlayerWeaponSlot(i, 1);
new nadeslot = GetPlayerWeaponSlot(i, 3);
if (ent > 0) {
RemovePlayerItem(i, ent);
RemoveEdict(ent);
}
if (ent1 > 0) {
RemovePlayerItem(i, ent1);
RemoveEdict(ent1);
}
if (nadeslot < 0) {
GivePlayerItem(i, "weapon_hegrenade");
GivePlayerItem(i, "weapon_flashbang");
}
if (Random == 15) {
LastWeaponNumber = Random;
return;
}
GivePlayerItem(i, all_weapons[Random]);
}
}
LastWeaponNumber = Random;
} else {
RandomWeapons();
}
return;
}
Okay so I found some code that was outdated and started to edit it to fit how I want it to be on my server. Everything works good, but for some reason every round that I get a m249, I actually ONLY get a knife. Every other gun works. The CPrintToChatAll shows i should have spawned with an m249. For some reason this is the only gun that doesnt work and I only spawn with a knife. Anyone know what could be causing that?