Raised This Month: $ Target: $400
 0% 

Solved How to trigger function on item use in TF2?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kazdaniarz
Junior Member
Join Date: Oct 2016
Old 05-02-2018 , 16:11   How to trigger function on item use in TF2?
Reply With Quote #1

Hello!
Well i have a little problem.
I want to do plugin that enables using spells in TF2, but it's not all cuz i m creating hud to it.
One part of hud is name of spell with number of uses left. (ex. Fireball x5)
The problem is i don't know how to lower this number. I mean i have some ideas but i don't know the event or method to trigger function on spell use in tf2 (yes this plugin adds charges to the book so i m really using this spells, not just spawning their effects) or eventually just on use of use item. (cuz the book is needed to use spells and we got 1 use slot anyway)

I m really thankfull for any help!
(Also sorry for my english. If anything isn't understandable just ask me i will try answer more simple.)

EDIT:
Well nvm. I just did it. If anyone looking for solve: Like i said i just needed the amount of spell's uses left so i used entity: GetEntProp(ent, Prop_Send, "m_iSpellCharges") and chained it to loop.

For Example:
Code:
public Action: PrintCharges(Handle:timer, any:hoge) {
	for(int i = 1; i <= MaxClients; i++) 
	{
		if(IsClientInGame(i)) 
		{
			new ent = -1;
			ent = FindEntityByClassname(ent, "tf_weapon_spellbook");
			sCharges = GetEntProp(ent, Prop_Send, "m_iSpellCharges");
			SetHudTextParams(0.5, 0.5, 1.0, 255, 255, 255, 255);
			ShowHudText(i, -1, "%s x%d", sSpell, sCharges);
		}
	}
	if(sCharges <= 0) 
	{
		cTimer2 = null;
		return Plugin_Stop;
	}
	else
	{
		return Plugin_Continue;
	}
}
Propably i will have more questions about my script in the future, hope i will get some answers ;)

Last edited by Kazdaniarz; 05-02-2018 at 19:09.
Kazdaniarz 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 07:25.


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