Thx for this plugin.
Was having log errors:
Quote:
L 10/02/2019 - 18:09:03: SourceMod error session started
L 10/02/2019 - 18:09:03: Info (map "mg_jacs_multigame_rfix") (file "errors_20191002.log")
L 10/02/2019 - 18:09:03: [SM] Exception reported: Client 1 is not in game
L 10/02/2019 - 18:09:03: [SM] Blaming: weapon_remover_lite2.smx
L 10/02/2019 - 18:09:03: [SM] Call stack trace:
L 10/02/2019 - 18:09:03: [SM] [0] GetPlayerWeaponSlot
L 10/02/2019 - 18:09:03: [SM] [1] Line 42, C:\Users\---\Downloads\last dls\csgos-windows\csgos\server\csgo\addons\sourcemod\sc ripting\weapon_remover_lite.sp::Event_HandleS pawn
L 10/02/2019 - 18:54:26: Error log file session closed.
|
We need to add:
if (client > 0 && IsClientInGame(client))
It is also better to check if plugin is enabled BEFORE creating the timer.
Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
// Plugin definitions
#define PLUGIN_VERSION "0.9"
public Plugin:myinfo =
{
name = "Weapon Remover Lite",
author = "Gdk",
version = PLUGIN_VERSION,
description = "Removes players weapons",
url = "https://topsecretgaming.net"
};
new Handle:PluginEnabled = INVALID_HANDLE;
public OnPluginStart()
{
HookEvent("player_spawn", Event_PlayerSpawn);
PluginEnabled = CreateConVar("sm_weapon_remover_lite_enabled", "1", "Whether the plugin is enabled");
/** Create/Execute cvars **/
AutoExecConfig(true, "weapon_remover_lite");
}
public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
if (GetConVarBool(PluginEnabled))
CreateTimer(0.1, Event_HandleSpawn, GetEventInt(event, "userid"));
}
public Action Event_HandleSpawn(Handle timer, any user_index)
{
int client = GetClientOfUserId(user_index);
if (client > 0 && IsClientInGame(client))
{
for(int j = 0; j < 4; j++)
{
int weapon = GetPlayerWeaponSlot(client, j);
if(weapon != -1)
{
RemovePlayerItem(client, weapon);
RemoveEdict(weapon);
}
}
}
}
__________________