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

CurWeapon help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Crackhead69
Member
Join Date: Feb 2021
Old 03-08-2021 , 03:43   CurWeapon help
Reply With Quote #1

I am using CurWeapon, haven't used it before, so im not exactly sure if it's suppose to work that way, nor i am sure if it's still a relevant event (if there's something more 'modern' let me know please)

I am trying to set different effects for different id's, for example

PHP Code:
public CurWeapon_event(id){
    switch(
g_currentid[id]){
        case 
0:set_user_gravity(id0:5)
        case 
1:set_user_speed(idfloat(600))
        case 
2:b_RandomBool[id] = true
    
}

Client has an option to choose between 3 g_currenid[id] items, when he pickes one of them, the effects that they're suppose to give him when he chooses are given Only when he switch weapons.

If say it is used in a Knife only situation, where players cannot Switch to resume the effects from CurWeapon, what could i do besides a PreThink?

Last edited by Crackhead69; 03-08-2021 at 03:44.
Crackhead69 is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 03-08-2021 , 05:05   Re: CurWeapon help
Reply With Quote #2

if you want player to gain that effect on specific weapon, you can set in WeaponDeploy and when player select that effect from the menu.
However, iirc,
- set_user_gravity will stay the same once set (so you only need to set it when player select it from menu and when PlayerSpawn if it reset)
- set_user_weapon will reset everytime player switch weapon (you can set in WeaponDeploy)
- the last one idk

CurWeapon only use in some niche situation when it needed since it called many time which will reduce server performant if used too much.
__________________
My plugin:

Last edited by Celena Luna; 03-08-2021 at 05:08.
Celena Luna is offline
Crackhead69
Member
Join Date: Feb 2021
Old 03-08-2021 , 06:18   Re: CurWeapon help
Reply With Quote #3

Quote:
Originally Posted by Celena Luna View Post
if you want player to gain that effect on specific weapon, you can set in WeaponDeploy and when player select that effect from the menu.
However, iirc,
- set_user_gravity will stay the same once set (so you only need to set it when player select it from menu and when PlayerSpawn if it reset)
- set_user_weapon will reset everytime player switch weapon (you can set in WeaponDeploy)
- the last one idk

CurWeapon only use in some niche situation when it needed since it called many time which will reduce server performant if used too much.
Ye tho, if it's only Knives i don't see how catching Deploying a knife when you already have one makes sense

I am awere that i can set user gravity when They choose the item ID, but i don't want those effects to be constant, but only active while they have the current item id.
I could simply just add lots of checks/tasks thruout the code, but it doesn't seem practical.

Last edited by Crackhead69; 03-08-2021 at 06:19.
Crackhead69 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-08-2021 , 07:10   Re: CurWeapon help
Reply With Quote #4

Probably the best approach would be hooking Ham_Item_Deploy for all weapons and inside the function check if the weapon is knife, else remove the effects.

CurWeapon is called each time your ammo count changes, while Ham_Item_Deploy only when you change weapons.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 03-08-2021 , 14:12   Re: CurWeapon help
Reply With Quote #5

Use Ham_Player_Jump for jump features
Use Ham_Player_ResetMaxSpeed for speed features
Use Ham_Item_Deploy for weapon features
And for gravity idk, probably it's possibile setting gravity using ham module.
And for bools use different event/ham forward/fm forward depending on your dependencies.
__________________
LondoN is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-08-2021 , 15:02   Re: CurWeapon help
Reply With Quote #6

register_event("CurWeapon", "Event_Cur_Weapon", "b", "1=1", "2=29", "3=-1");

this will be called only when the player deploys the knife, i don't see any reason also to not use the curweapon event.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-08-2021 , 15:07   Re: CurWeapon help
Reply With Quote #7

Quote:
Originally Posted by Natsheh View Post
register_event("CurWeapon", "Event_Cur_Weapon", "b", "1=1", "2=29", "3=-1");

this will be called only when the player deploys the knife, i don't see any reason also to not use the curweapon event.
Because he wants to disable the effects when he deploys another weapon. And hooking other weapons with this event will lead to many function calls.
The knife is called only once because it has no ammo.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-08-2021 , 15:10   Re: CurWeapon help
Reply With Quote #8

Quote:
Originally Posted by OciXCrom View Post
Because he wants to disable the effects when he deploys another weapon. And hooking other weapons with this event will lead to many function calls.
The knife is called only once because it has no ammo.
its actually easily possible using curweapon event also to hook when the player deploy another weapon when he was holding a knife by checking if the first argument (active) is equal to 0.

Code:
register_event("CurWeapon", "Event_Cur_Weapon_tookoff_knife", "b", "1=0", "2=29", "3=-1");

its actually better than using ham_deploy since you need to hook all weapons classnames while using curweapon you need only 1 or 2 hooks.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 03-08-2021 at 15:15.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 03-08-2021 , 21:39   Re: CurWeapon help
Reply With Quote #9

iirc, you can also detect switching to other weapon by using Ham_Item_Holster
PHP Code:
RegisterHam(Ham_Item_Holster"weapon_knife""fw_Knife_Holster"//Only trigger when switch from knife to other weapon 
so you don't actually need to hook every Ham_Item_Deploy of every weapon.
or at least, that how I tested in CS 1.6

Edit: Also, I didn't find much infomation on how CurWeapon work online rather actual test in-game
__________________
My plugin:

Last edited by Celena Luna; 03-08-2021 at 23:02.
Celena Luna is offline
Crackhead69
Member
Join Date: Feb 2021
Old 03-11-2021 , 04:03   Re: CurWeapon help
Reply With Quote #10

Thanks everybody for all the answers, i made due with what you gave me.
Cheers.
Crackhead69 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 04:11.


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