Raised This Month: $ Target: $400
 0% 

Events, log events, entities.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pizzahut
Senior Member
Join Date: Oct 2004
Old 05-13-2005 , 22:04   Events, log events, entities.
Reply With Quote #1

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:
[20:18:15] <pizzahut2> it says something like "bot triggered sentry_destroyed"
[20:184] <pizzahut2> when i shoot with supershotgun, or if i use knife
[20:18:46] <pizzahut2> bot being the victim
[20:18:57] <pizzahut2> so yeah, only works with nails
EDIT 2:

There was an error in "tfcevents.sma" :

Replaced
register_event("SayText", "event70", "ab")
with
register_event("SayText", "event80", "ab")
Attached Files
File Type: sma Get Plugin or Get Source (tfcevents.sma - 679 views - 7.2 KB)
File Type: sma Get Plugin or Get Source (tfclogevents.sma - 1081 views - 3.6 KB)
__________________
My AMXX plugins (content date 2007-03-29, link check 2017-04-26)

Plugins for the Royston Vasey TFC server - These are UNSUPPORTED, except those which have been published at AMX Mod X.

Last edited by pizzahut; 02-16-2013 at 09:58.
pizzahut is offline
sambro
Member
Join Date: May 2005
Old 05-13-2005 , 22:35  
Reply With Quote #2

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

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:
You can filter the results by adding conditional parameters. Examples:
"0=World triggered" "1=Game_Commencing"
"1=say"
"3=Terrorists_Win"
"1=entered the game"
"0=Server cvar"
This would seem to suggest that the additional, conditional parameters are not necessary.

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.
sambro is offline
Send a message via MSN to sambro
pizzahut
Senior Member
Join Date: Oct 2004
Old 05-14-2005 , 08:56  
Reply With Quote #3

Quote:
Originally Posted by sambro
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.
I think read_data is made for "normal" events, not log events. It crashes when trying to use read_data for log events.

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.
pizzahut is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 05-14-2005 , 09:47  
Reply With Quote #4

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:
#include <amxmodx> #include <engine> #include <tfcconst> public plugin_init() {   register_plugin("TFC Object", "0.1", "pizzahut") } public plugin_modules() {    require_module("engine")    require_module("tfcx") } public client_PreThink(id) {   new is_attack, was_attack   is_attack = entity_get_int(id, EV_INT_button) & IN_ATTACK   was_attack = entity_get_int(id, EV_INT_oldbuttons) & IN_ATTACK   if (is_attack && !was_attack)   {     new victim, bodypart     new Float:distance = get_user_aiming(id, victim, bodypart)     new clip, ammo     new weapon = get_user_weapon(id,clip,ammo)     client_print(id, print_chat, "id=%d | distance=%f victim=%d bodypart=%d | weapon=%d clip=%d ammo=%d^n", id, distance, victim, bodypart, weapon, clip, ammo)   }   return PLUGIN_CONTINUE }

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.
pizzahut is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 05-14-2005 , 10:51  
Reply With Quote #5

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:
    new player_team     new victim_team     new owner     new owner_team     player_team = entity_get_int(id, EV_INT_team)     victim_team = (victim==0) ? 0 : entity_get_int(victim, EV_INT_team)     owner = (victim==0) ? 0 : entity_get_edict(victim, EV_ENT_owner)     owner_team = (owner==0) ? 0 : entity_get_int(owner, EV_INT_team)     client_print(id, print_chat, "player team = %d, victim team = %d, owner = %d, owner_team = %d^n", player_team, victim_team, owner, owner_team)
pizzahut is offline
sambro
Member
Join Date: May 2005
Old 05-14-2005 , 11:58  
Reply With Quote #6

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.
sambro is offline
Send a message via MSN to sambro
pizzahut
Senior Member
Join Date: Oct 2004
Old 05-14-2005 , 12:20  
Reply With Quote #7

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.
pizzahut is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 05-14-2005 , 19:10  
Reply With Quote #8

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:
    new tid, vtid     new team[8],vteam[8]     tid = get_user_team(id, team, 7)     vtid = get_user_team(victim, vteam, 7)     client_print(id, print_chat, "player team = %d, victim team = %d^n", tid, vtid)     // client_print(id, print_chat, "player team name = %s, victim team name = %s^n", team, vteam)
pizzahut 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 16:44.


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