Raised This Month: $32 Target: $400
 8% 

[CSGO] Prevent weapon pickup by walking over weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tank_in_Pink
Member
Join Date: Feb 2016
Old 04-19-2018 , 16:11   [CSGO] Prevent weapon pickup by walking over weapons
Reply With Quote #1

Hey guys,


I'm searching for a plugin for my CSGO server to force all players to pick up weapons by pressing their use-key and to prevent picking up weapons by walking over them. Does not have to work for bots.

I've already searched for some time but couldn't find anything.

If you know a plugin like this it would be awesome if you could link it. If there's no plugin like this I'd like to suggest it.

Thanks already,
hazetank
Tank_in_Pink is offline
OSWO
Senior Member
Join Date: Jul 2015
Location: United Kingdom, London
Old 04-20-2018 , 06:38   Re: [CSGO] Prevent weapon pickup by walking over weapons
Reply With Quote #2

Hook the SDK hook event "OnWeaponUse", and check buttons if & IN_USE, if not return Plugin_Handled, otherwise return Plugin_Continue;


You may want to go a step further and raytrace their eyes and see if it's in the general position of the weapon relative to the world.
__________________
SourceTimer | WeaponSkins++ | BasePlugins++ https://github.com/OSCAR-WOS

Last edited by OSWO; 04-20-2018 at 06:40.
OSWO is offline
Tank_in_Pink
Member
Join Date: Feb 2016
Old 04-23-2018 , 16:43   Re: [CSGO] Prevent weapon pickup by walking over weapons
Reply With Quote #3

Thanks for your answer!


I have no idea of SP but I tried to write a framework by using my knowledge of Java and C# and by looking at another SP script. Pretty sure I can't do much with it but I didn't know what to do instead.

I commented some questions next to the code, would be nice if somebody could answer them!


Thanks already,
hazetank


Code:
#include <sourcemod>

public OnPluginStart()
{
	HookEvent("weapon_use", Event_OnWeaponUse);					// how do you call this event?
}

public Event_OnWeaponUse(Handle:event, const String:name[], bool:dontBroadcast)		// what to put as parameters?
{
    if(usebutton_pressed != true)							// how to detect button press?
		return Plugin_Handled;

	return Plugin_Continue;
}
Tank_in_Pink is offline
OSWO
Senior Member
Join Date: Jul 2015
Location: United Kingdom, London
Old 04-24-2018 , 10:00   Re: [CSGO] Prevent weapon pickup by walking over weapons
Reply With Quote #4

untested.

PHP Code:
#include <sourcemod>
#include <sdkhooks>

public void OnPluginStart() {
    for (
int i 0<= MaxClientsi++) {
        
TryWeaponHook(i);
    }
}

public 
void OnClientPostAdminCheck(int iClient) {
    
TryWeaponHook(iClient);
}

void TryWeaponHook(int iIndex) {
    if (
IsValidClient(iIndex)) {
        
SDKHook(iIndex"SDKHook_WeaponCanUse"Hook_WeaponCanUse);
    }
}

public 
Action Hook_WeaponCanUse(int iClientint iWeapon) {
    if (
GetClientButtons(iClient) & IN_USE) return Plugin_Handled;
    
    return 
Plugin_Continue;
}

bool IsValidClient(int iIndex) {
    if (!
IsFakeClient(iIndex) && IsClientConnected(iIndex) && iIndex && iIndex <= MaxClients) return true;

    return 
false;

__________________
SourceTimer | WeaponSkins++ | BasePlugins++ https://github.com/OSCAR-WOS

Last edited by OSWO; 04-24-2018 at 10:02.
OSWO is offline
Reply


Thread Tools
Display Modes

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 19:17.


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