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

[CS:GO] OnPressed func_button give weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
You9
Member
Join Date: Mar 2016
Old 05-24-2016 , 14:31   [CS:GO] OnPressed func_button give weapon
Reply With Quote #1

Hey, i'm trying to make code where clicking specific button is clicked with weapon_p250, it'll print chat error that is not allowed.
But how i detect that was weapon_p250
My code right now:
PHP Code:
public OnButtonPressed_func(const char[] outputint callerint activatorfloat delay)
{
    if(!
IsClientInGame(activator))
        return;
    
    if(
caller == 416)
        
PrintToChat(client"[ERROR] Opening jump is not allowed with p250.");

You9 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 05-24-2016 , 19:14   Re: [CS:GO] OnPressed func_button give weapon
Reply With Quote #2

caller will generally be the client index.

You then need to get the active weapon index for the caller.

Following this is a call to get the entities classname.
__________________
Neuro Toxin is offline
You9
Member
Join Date: Mar 2016
Old 05-25-2016 , 05:39   Re: [CS:GO] OnPressed func_button give weapon
Reply With Quote #3

Quote:
Originally Posted by Neuro Toxin View Post
caller will generally be the client index.

You then need to get the active weapon index for the caller.

Following this is a call to get the entities classname.
Thanks, that's working but i have 4 courses, pistol, rifle, scope and granade.
There are anyway i can get player granade too?

Last edited by You9; 05-25-2016 at 05:39.
You9 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 05-25-2016 , 06:30   Re: [CS:GO] OnPressed func_button give weapon
Reply With Quote #4

Do you need to check the active weapon being held by the player or their weapon slots for all weapons?
__________________
Neuro Toxin is offline
You9
Member
Join Date: Mar 2016
Old 05-25-2016 , 07:37   Re: [CS:GO] OnPressed func_button give weapon
Reply With Quote #5

Quote:
Originally Posted by Neuro Toxin View Post
Do you need to check the active weapon being held by the player or their weapon slots for all weapons?
Amm... i mean like, when you have weapon_smoke and you throw that excatly there where the button is, are there anyway it detects it?
You9 is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 05-25-2016 , 07:43   Re: [CS:GO] OnPressed func_button give weapon
Reply With Quote #6

Quote:
Originally Posted by You9 View Post
Amm... i mean like, when you have weapon_smoke and you throw that excatly there where the button is, are there anyway it detects it?
If the grenade would hit the button you could hook the button's SDKHook_StartTouch and check for that specific classname. Otherwise you could hook the same thing on the grenade and check its landing position, then compare how far it is from the button.

If there is an event when a smoke grenade goes off you could use this instead of hooking touches. I wouldn't bother to check as I don't really do CS:GO.


EDIT: Sorry, I didn't even read the thread...

You have a button which can be activated via touch, right?

Last edited by Phil25; 05-25-2016 at 07:45.
Phil25 is offline
You9
Member
Join Date: Mar 2016
Old 05-25-2016 , 07:48   Re: [CS:GO] OnPressed func_button give weapon
Reply With Quote #7

Yes, i have button which can be activated with touch or klick the use key (e usually).
I'll try the SDKHook_StartTouch
You9 is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 05-25-2016 , 08:37   Re: [CS:GO] OnPressed func_button give weapon
Reply With Quote #8

In this case, you should hook SDKHook_Use. Here's its callback:
Code:
Action:public(entity, activator, caller, UseType:type, Float:value)
Simply return Plugin_Handled if your conditions are not met.
Phil25 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 01:45.


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