Raised This Month: $ Target: $400
 0% 

Repeating Text Event_PlayerTeam


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cooltad
Veteran Member
Join Date: Apr 2008
Old 03-03-2010 , 19:48   Repeating Text Event_PlayerTeam
Reply With Quote #1

On player_team event, when I use PrintToChat(i, "Lalala");
It appears twice, though It should only show once obviously. Interestingly enough, the sound that I use to play along with that, does not happen twice but only once.
Any ideas?

I also have tidychat installed, here is the relavent code in it that -might- conflict:
Code:
    if(GetConVarInt(g_hEnabled) && GetConVarInt(g_hChangeClass))
    {
        if(!dontBroadcast)
        {
            new iUserId = GetEventInt(event, "userid");
            new iClass = GetEventInt(event, "class");            
            
            new Handle:hEvent = CreateEvent("player_changeclass");
            SetEventInt(hEvent, "userid", iUserId);
            SetEventInt(hEvent, "class", iClass);
            
            FireEvent(hEvent, true);
            
            return Plugin_Handled;
        }
    }
    
    return Plugin_Continue;
}
__________________
Please, give me some rep if you found what I posted useful. :]
Cooltad is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 03-04-2010 , 04:21   Re: Repeating Text Event_PlayerTeam
Reply With Quote #2

Do you have ES_Tools installed?
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
Cooltad
Veteran Member
Join Date: Apr 2008
Old 03-04-2010 , 06:25   Re: Repeating Text Event_PlayerTeam
Reply With Quote #3

No. Besides, I was silly to wonder what the issue was. The event was firing twice because it refires the event, modified, to block text and then handles the current event.
__________________
Please, give me some rep if you found what I posted useful. :]
Cooltad is offline
lake393
AlliedModders Donor
Join Date: Oct 2008
Old 03-04-2010 , 10:05   Re: Repeating Text Event_PlayerTeam
Reply With Quote #4

I have a similar thing happen in my plugin and the OnClientSettingsChanged event.

I am using the OnClientSettingsChanged event so that whenever the client changes his name, it will do something.

Unfortunately, it fires two times in a row when they change their name. More in some cases. I have logging turned on and I use LogMessage() to confirm this.

I was under the impression that this was normal for SourceMod, so what I did was create a string to contain the UserId of the person who triggered the event last. If the same userId is seen again, it aborts by returning.

I'm new to sourcepawn so I was going to experiment with return PLUGIN_STOP and return PLUGIN_HANDLED and see if they do anything to prevent the re-firing.

Last edited by lake393; 03-04-2010 at 10:07.
lake393 is offline
Cooltad
Veteran Member
Join Date: Apr 2008
Old 03-04-2010 , 22:14   Re: Repeating Text Event_PlayerTeam
Reply With Quote #5

Quote:
Originally Posted by lake393 View Post
I have a similar thing happen in my plugin and the OnClientSettingsChanged event.

I am using the OnClientSettingsChanged event so that whenever the client changes his name, it will do something.

Unfortunately, it fires two times in a row when they change their name. More in some cases. I have logging turned on and I use LogMessage() to confirm this.

I was under the impression that this was normal for SourceMod, so what I did was create a string to contain the UserId of the person who triggered the event last. If the same userId is seen again, it aborts by returning.

I'm new to sourcepawn so I was going to experiment with return PLUGIN_STOP and return PLUGIN_HANDLED and see if they do anything to prevent the re-firing.
Just add a bool at the end of the thing that refires the event, then in said event, make a condition thats dependant on that bool being on.

This will make it so even if the event fires twice, your script will fire once.

And those two returns are useless in anything aside from a pre hook.
__________________
Please, give me some rep if you found what I posted useful. :]
Cooltad is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 03-05-2010 , 00:10   Re: Repeating Text Event_PlayerTeam
Reply With Quote #6

As far as I remember those plugins which use events re-firing method are not welcome and won't be approved anymore. This was discussed somewhere but I couldn't find a link.
In most cases you need re-firing events method when don't want the client to see some action that caused by this event client-side (like connecting, disconnecting, etc.). For this just use SetEventBroadcast native. It won't block the event on the server (and for other plugins) but will stop it from sending to the client.
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
Cooltad
Veteran Member
Join Date: Apr 2008
Old 03-05-2010 , 00:38   Re: Repeating Text Event_PlayerTeam
Reply With Quote #7

The person who made tidychat should redo his plugin using that easier method, then.
__________________
Please, give me some rep if you found what I posted useful. :]
Cooltad 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 20:06.


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