AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Events, log events, entities. (https://forums.alliedmods.net/showthread.php?t=13358)

pizzahut 05-13-2005 22:04

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:

[20:18:15] <pizzahut2> it says something like "bot triggered sentry_destroyed"
[20:18:34] <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")

sambro 05-13-2005 22:35

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:

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.

pizzahut 05-14-2005 08:56

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 05-14-2005 09:47

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 05-14-2005 10:51

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)

sambro 05-14-2005 11:58

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.

pizzahut 05-14-2005 12:20

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 05-14-2005 19:10

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)


All times are GMT -4. The time now is 16:44.

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