Raised This Month: $51 Target: $400
 12% 

Order of events?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JabLuszko
Junior Member
Join Date: Aug 2011
Old 08-14-2011 , 22:12   Order of events?
Reply With Quote #1

Hello,

Is there any way to change the order of events or to make one event wait a little bit for another?

I need simple plugin - showing on the HUD name of player which user is currently spectating. I found the "SpecHealth2" event which looks like a thing that I need - code using the event (everything works):
PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Test"
#define VERSION "1.0"
#define AUTHOR "Test"

new SyncHudObj;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
SyncHudObj CreateHudSyncObj();
    
register_event("SpecHealth2","event_showNick","bd");
}

    
public 
event_showNick(id) {
    new 
target=read_data(2);
    new 
targetName[32];
    
get_user_name(targettargetName31);
    
set_hudmessage(2552552550.020.2100.010.00.00.0);
    
ShowSyncHudMsg(idSyncHudObj"You are watching: %s"targetName);

Now it's time for 'tricky' part - I would like to show that info only if user/watcher/specator is in FirstPersonView. Google'd a little bit, found a code of Admin ESP plugin and:
PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Test"
#define VERSION "1.0"
#define AUTHOR "Test"

new SyncHudObj;
new 
first_person[33];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
SyncHudObj CreateHudSyncObj();
    
register_event("SpecHealth2","event_showNick","bd");
    
register_event("TextMsg","isFirstPersonSpec","bd","2&#Spec_Mode");
}

    
public 
event_showNick(id) {
    if (!
first_person[id]) {
        
ClearSyncHud(idSyncHudObj);
        return 
PLUGIN_CONTINUE;
    }
        
    new 
target=read_data(2);
    new 
targetName[32];
    
get_user_name(targettargetName31);
    
set_hudmessage(2552552550.020.2100.010.00.00.0);
    
ShowSyncHudMsg(idSyncHudObj"You are watching: %s"targetName);
    
    return 
PLUGIN_CONTINUE;
}


public 
isFirstPersonSpec(id) {
    
    new 
specMode[12];
    
read_data(2,specMode,11);
    
    if(
equal(specMode,"#Spec_Mode4")) {
        
first_person[id]=true;
    } else {
        
first_person[id]=false;
    }
    
    return 
PLUGIN_CONTINUE;

If the first_person[id] value is not set to true we are clearing the HUD (sometimes we are not in the FirstPersonView anymore).
Looks good, sounds good, works almost good - it do not work for the first player which we switch to within FirstPersonView. Looks like the events are in 'wrong' order for me. First goes "SpecHealth2" which check value of first_person and finds there false - so it is not rendering anything on HUD. Then goes "TextMsg" setting the first_person[id] to true. I would like to change the order of events - first "TextMsg", then "SpecHealth2" - it is even possible? I've tried switching places with the register_event functions in plugin_init() and the public functions() but it do not help.

If it is not possible do you know any solution to my problem (like other event containing Spec_Mode, SpecatorID and SpectatedID/target)? I would rather not use set_task - events are better :-)
JabLuszko is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 08-14-2011 , 23:06   Re: Order of events?
Reply With Quote #2

try pev_iuser1
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang 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 03:20.


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