Events, log events, entities.
3 Attachment(s)
1) Is there a method to catch *all* events without having to register 60 events and writing 60 functions? I only want to know when an event occurs, and print out event id and name (possibly data, too).
2) Atm I'm using log events to catch attacking of TFC specific objects (e.g. sentry gun). However, this doesn't work for melee weapons. Any ideas? EDIT: The log events turn out to be pretty useless for this purpose. Quote:
There was an error in "tfcevents.sma" : Replaced register_event("SayText", "event70", "ab") with register_event("SayText", "event80", "ab") |
If you're using register_event, no. That function hooks a specific message, for instance BombDrop, or CurWeapon. Such events obviously aren;'t very general :wink:
If TFC does, in fact, use log messages for what you're looking for, then you may be in luck. As far as I can see, you can use register_logevent to have all generic log messages sent straight to a function. From there I'm not sure if you can even find out what message you're handling, but it's worth a try! Straight from the documentation.. Quote:
Inside the logevent function, you use read_data to get a parameter. Try using read_data(0), it may give you the name of the logevent. |
Quote:
I've got an idea for the other problem though (melee attack on objects). Using client_PreThink, entity_get_int and get_user_weapon I could find out an attacker's ID and weapon. The problem is then to find out if the player is attacking an object, and if this object belongs to his own team or not. :? |
Alright the part if it's an object is probably solved. I get victim IDs of 300+, so basically if victim id is higher than 32 it should be an object.
This script prints info if you press attack button while aiming at something. (You can also use a melee weapon from far away to get the info without damaging the target.) Code:
So what is left, is to find out if the object belongs to the own team. And ideally, find out if the attack destroys the object. |
I've tried this, but it's not returning the info I need?
If I aim at a player, I *will* get the team number. If I aim at an object (SG, disp etc), team number is 0. :( The owner of such an object is also 0. :( Code:
|
Unsure of how to get such information in TFC. In CS it's cs_get_user_team(id)...
Try looking at the TFC mod code, maybe you can find out how they're storing such information from there. |
There's a function get_user_team which probably works for all mods. I'd be surprised though if it would return the team id of objects.
|
I get a team ID of -1 for objects. I've also noticed that a sentry actually has two IDs, because it consists of socket and mounted gun. A team name is not returned.
Code:
|
| All times are GMT -4. The time now is 16:44. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.