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

[CSGO] Prevent picking up weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
condolent
AlliedModders Donor
Join Date: Jan 2016
Location: gc_sLocation;
Old 08-30-2017 , 12:06   [CSGO] Prevent picking up weapons
Reply With Quote #1

Hello,
So I'm trying to make it so players cannot pick up weapons, except for the weapons they dropped themselves.

I tried this code with SDKHook_WeaponDropPost and SDKHook_WeaponCanUse:
PHP Code:
public void WeaponDropPost(int clientint weapon) {
    
WeaponOwner[weapon] = client;
}

public 
Action WeaponCanUse(int clientint weapon) {
    if(
WeaponOwner[weapon] == client)
        return 
Plugin_Continue;
    
    return 
Plugin_Handled;

But that didn't seem to work. Any suggestions?
__________________
condolent is offline
yash1441
Senior Member
Join Date: Feb 2015
Location: Illuminati HQ
Old 08-30-2017 , 13:05   Re: [CSGO] Prevent picking up weapons
Reply With Quote #2

HookEvent("item_pickup", OnItemPickUp, EventHookMode_Pre);

Last time I checked this method was working.
__________________
yash1441 is offline
Send a message via Skype™ to yash1441
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-30-2017 , 18:25   Re: [CSGO] Prevent picking up weapons
Reply With Quote #3

Quote:
Originally Posted by yash1441 View Post
HookEvent("item_pickup", OnItemPickUp, EventHookMode_Pre);

Last time I checked this method was working.
Events are to late. An event fires after the action has taken place. You can't block the events trigger from processing from an event.

Edit: https://sm.alliedmods.net/new-api/sdkhooks/__raw

I believe you should be hooking SDKHook_WeaponEquip.
__________________

Last edited by Neuro Toxin; 08-30-2017 at 18:28.
Neuro Toxin is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 08-30-2017 , 20:58   Re: [CSGO] Prevent picking up weapons
Reply With Quote #4

SDKHook_WeaponCanUse should give you the desired result. Are you sure your logic is correct?

Last edited by headline; 08-30-2017 at 21:00.
headline is offline
condolent
AlliedModders Donor
Join Date: Jan 2016
Location: gc_sLocation;
Old 08-31-2017 , 02:42   Re: [CSGO] Prevent picking up weapons
Reply With Quote #5

Quote:
Originally Posted by Neuro Toxin View Post
https://sm.alliedmods.net/new-api/sdkhooks/__raw

I believe you should be hooking SDKHook_WeaponEquip.
I tried using that aswell but to no avail :/

Quote:
Originally Posted by Headline View Post
SDKHook_WeaponCanUse should give you the desired result. Are you sure your logic is correct?
I was only testing with bots so I tried picking up the bot's weapons and such. Going to test later today with other players to see if it works then!
__________________

Last edited by condolent; 08-31-2017 at 02:43.
condolent is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-31-2017 , 03:52   Re: [CSGO] Prevent picking up weapons
Reply With Quote #6

Each weapon also has an owner netprop you can use to in your hook to avoid a massive array.
__________________
Neuro Toxin is offline
milutinke
AlliedModders Donor
Join Date: Jun 2012
Location: Serbia
Old 08-31-2017 , 16:18   Re: [CSGO] Prevent picking up weapons
Reply With Quote #7

Maybe this can help.
https://forums.alliedmods.net/showpo...4&postcount=12
milutinke is offline
Send a message via Skype™ to milutinke
condolent
AlliedModders Donor
Join Date: Jan 2016
Location: gc_sLocation;
Old 09-01-2017 , 03:12   Re: [CSGO] Prevent picking up weapons
Reply With Quote #8

Quote:
Originally Posted by milutinke View Post
That was helpful! Didn't actual think of that I need to do some cleanup after round ends and such!

Can anybody tip me with how I can clear an array of its entries and such?
I saw this somewhere but don't really know what it actually fulfills:
PHP Code:
int myArray[256] = {0, ...}; 
Or maybe this, but I think this only sets the values of each entry to 0, right?
PHP Code:
for(int i 0sizeof(WeaponOwner); i++) WeaponOwner[i] = 0
__________________

Last edited by condolent; 09-01-2017 at 03:16.
condolent 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 07:57.


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