AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Client throws a grenade > call function (https://forums.alliedmods.net/showthread.php?t=49024)

bloodypizza 12-25-2006 23:20

Client throws a grenade > call function
 
Read the title!

I'm scripting for a Half-Life (1) mod youv'e never heard of (Half-Life 2: Jakin' Bacon Source).
In that mod you can use normal Half-Life grenades.
I want to play a sound everytime a player throws a grenade (by executing the "spk" command in that players console).
So I want to call a function when a player releases a grenade.
Is there a way to do this?
Please help me.

The Specialist 12-25-2006 23:27

Re: Client throws a grenade > call function
 
Use a current weapon event like this
Code:
register_event("CurWeapon","fucntion_called","be","1=1","2=4");

It says that the weapon has to be a he grenade(4). :wink: The first paramter is the event , the 2nd is the funtion that your hooking to, whatever fucntion youll be calling your code in , then the 3rd paramter is the weapon is active , then the conditions

jim_yang 12-26-2006 00:30

Re: Client throws a grenade > call function
 
grenade_throw

The Specialist 12-26-2006 00:58

Re: Client throws a grenade > call function
 
Yes If you wanna use CSX you can use that .

jim_yang 12-26-2006 01:53

Re: Client throws a grenade > call function
 
Quote:

Originally Posted by The Specialist (Post 419869)
Yes If you wanna use CSX you can use that .

actually the way you did can't catch a grenade throw event, it only catch a player switch his weapon to a hegrenade.

XxAvalanchexX 12-26-2006 16:57

Re: Client throws a grenade > call function
 
The grenade_throw forwards are only for Counter-Strike and Day of Defeat.

I'd hook FM_SetModel, look for the world grenade model, and then check its owner (make sure it even has one, if not it must not be a thrown grenade).

The Specialist 12-26-2006 23:48

Re: Client throws a grenade > call function
 
Quote:

Originally Posted by XxAvalanchexX (Post 420150)
The grenade_throw forwards are only for Counter-Strike and Day of Defeat.

I'd hook FM_SetModel, look for the world grenade model, and then check its owner (make sure it even has one, if not it must not be a thrown grenade).

Except the problem with this is that the entire plugin can be thrown off by a server with model changing plugins. And model changning pugins are on almost every server out there . So its not a very good way to do it .

XxAvalanchexX 12-27-2006 01:47

Re: Client throws a grenade > call function
 
Simply instruct the server operators to place this plugin higher on the list than model changing plugins. Since almost every single model changing plugin changes world models with a FM_SetModel hook, this one will be called first.

If you don't want to do it by model, still hook FM_SetModel, but check classname.

The Specialist 12-27-2006 01:55

Re: Client throws a grenade > call function
 
Quote:

Originally Posted by XxAvalanchexX (Post 420360)
Simply instruct the server operators to place this plugin higher on the list than model changing plugins. Since almost every single model changing plugin changes world models with a FM_SetModel hook, this one will be called first.

If you don't want to do it by model, still hook FM_SetModel, but check classname.

What model would you specify for the FM_SetModel if you didnt know what the model would be . And if the model is wrong in the paramaters will the function still be called ?

XxAvalanchexX 12-27-2006 01:57

Re: Client throws a grenade > call function
 
Why don't you know what the model will be?


All times are GMT -4. The time now is 03:13.

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