Raised This Month: $51 Target: $400
 12% 

Weapon Remover Lite


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Gdk
Member
Join Date: Oct 2014
Plugin ID:
4844
Plugin Version:
0.9
Plugin Category:
General Purpose
Plugin Game:
Counter-Strike: GO
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Removes weapons from a players inventory
    Old 10-13-2015 , 09:30   Weapon Remover Lite
    Reply With Quote #1

    Simple plugin that removes a players starting weapons as they spawn.

    Useful for surf, kz, or any server where you want a simple plugin to remove weapons from everyone.

    This will allow you to have no weapons and no crosshair.

    Why not just use mp_ct_default_secondary and mp_ct_default_melee? Simply put some maps and some plugins override these settings.

    Just place weapon_remover_lite.smx in the addons/sourcemod/plugins directory and you are good to go.

    Can be enabled/disabled with the cvar "sm_weapon_remover_lite_enabled" (def 1)
    Attached Files
    File Type: sp Get Plugin or Get Source (weapon_remover_lite.sp - 1442 views - 1.1 KB)

    Last edited by Gdk; 10-14-2015 at 17:33.
    Gdk is offline
    Drixevel
    AlliedModders Donor
    Join Date: Sep 2009
    Location: Somewhere headbangin'
    Old 10-13-2015 , 09:35   Re: Weapon Remover Lite
    Reply With Quote #2

    Few things:
    • Why are you looping through all clients everytime they spawn and remove all of their weapons when one person spawns?
    • You can remove the ' == true' part of the GetConVarBool if statement.
    • What's the point of lines 54-56?
    Drixevel is offline
    Gdk
    Member
    Join Date: Oct 2014
    Old 10-13-2015 , 10:05   Re: Weapon Remover Lite
    Reply With Quote #3

    Quote:
    Originally Posted by r3dw3r3w0lf View Post
    Few things:
    • Why are you looping through all clients everytime they spawn and remove all of their weapons when one person spawns?
    • You can remove the ' == true' part of the GetConVarBool if statement.
    • What's the point of lines 54-56?
    Fixed 2-3, but as for your first point I don't know a better way of doing it.
    Gdk is offline
    Drixevel
    AlliedModders Donor
    Join Date: Sep 2009
    Location: Somewhere headbangin'
    Old 10-13-2015 , 10:28   Re: Weapon Remover Lite
    Reply With Quote #4

    Code:
    public Action Event_HandleSpawn(Handle timer, any user_index)
    {
    	int client = GetClientOfUserId(user_index);
    	
    	if (GetConVarBool(PluginEnabled))
    	{
    		for(int j = 0; j < 4; j++)
    		{
    			int weapon = GetPlayerWeaponSlot(client, j);
    			if(weapon != -1)
    			{
    				RemovePlayerItem(client, weapon);
    				RemoveEdict(weapon);						
    			}
    		}
    	}
    }
    Drixevel is offline
    Gdk
    Member
    Join Date: Oct 2014
    Old 10-13-2015 , 13:04   Re: Weapon Remover Lite
    Reply With Quote #5

    Quote:
    Originally Posted by r3dw3r3w0lf View Post
    Code:
    public Action Event_HandleSpawn(Handle timer, any user_index)
    {
    	int client = GetClientOfUserId(user_index);
    	
    	if (GetConVarBool(PluginEnabled))
    	{
    		for(int j = 0; j < 4; j++)
    		{
    			int weapon = GetPlayerWeaponSlot(client, j);
    			if(weapon != -1)
    			{
    				RemovePlayerItem(client, weapon);
    				RemoveEdict(weapon);						
    			}
    		}
    	}
    }
    Thanks, fixed
    Gdk is offline
    St00ne
    Veteran Member
    Join Date: Jan 2011
    Location: Annecy - France
    Old 10-10-2019 , 07:12   Re: Weapon Remover Lite
    Reply With Quote #6

    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);						
    			}
    		}
    	}
    }
    __________________

    *** *** ***
    -My plugins-

    Last edited by St00ne; 10-10-2019 at 07:15.
    St00ne is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 11:00.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode