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

[TF2] Annotations


Post New Thread Reply   
 
Thread Tools Display Modes
ltgenkd
AlliedModders Donor
Join Date: Sep 2008
Old 10-30-2010 , 11:55   Re: [TF2] Annotations
Reply With Quote #41

How do I make the annotations stationary? I've been changing the view distance but can't seem to get them to stay stationary.
Using sql version.

Thanks
__________________
ltgenkd is offline
Holek
Junior Member
Join Date: Aug 2009
Old 10-30-2010 , 17:37   Re: [TF2] Annotations
Reply With Quote #42

Geit, I found two little bugs in the SQL version (didn't check the non-sql version).
First is a typo in plugin info:
Code:
public Plugin:myinfo = 
{
	name = "Annoatations SQL",
Second is db table that this plugin creates. You enforce engine and auto-increment value upon creation of the table.
Code:
CREATE TABLE IF NOT EXISTS `annotations` (`id` int(16) unsigned NOT NULL AUTO_INCREMENT, `creator` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, `creator_steam_id` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL, `text` varchar(256) COLLATE utf8_unicode_ci DEFAULT NULL, `file` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, `time` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `deleted` int(1) DEFAULT '0', `position_x` int(5) DEFAULT NULL, `position_y` int(5) DEFAULT NULL, `position_z` int(5) DEFAULT NULL, PRIMARY KEY (`id`), KEY `creator_community_id` (`creator_steam_id`), KEY `file` (`file`));
As you can see I've added new index `file` for the map name; that way the annotations' query will be processed faster during Event_RestartRound. Might want to change to that query.

Otherwise it's a great mod, thanks a bunch!

Oh, also, I attach .sp file with these changes.
Attached Files
File Type: sp Get Plugin or Get Source (annotations_sql.sp - 254 views - 10.3 KB)
__________________
Holek is offline
Kilandor
Member
Join Date: Sep 2009
Old 11-01-2010 , 08:58   Re: [TF2] Annotations
Reply With Quote #43

Omg why didn't you tell me this finaly got working. I gave up hope on it ever working. I've been waiting since training came out and I tried everything possible to get it to work
__________________
Kilandor is offline
Kilandor
Member
Join Date: Sep 2009
Old 11-01-2010 , 11:56   Re: [TF2] Annotations
Reply With Quote #44

Quote:
Originally Posted by msleeper View Post
Someone is reporting getting lag from this plugin.



The blip is light blue "events", whenever the plugin fires to refresh the annotations. Not sure if there is anything you can do about this.
With 5 annotations on the ground refreshing every 0.1 and a "rate" of 10k I recive lag/choke. With rate of 25k there is no lag/choke
In short firing the events to often, or in this case all of them updating at once, is causing a large chunk of data to be sent. More than the client can handle causing lag/stutter.
And default TF2 rate is 10k. You could force a minimum, but I wouldn't recommend this.

Update Again: Removed last update text as I was mistakenly creating a 1second timer in a 0.1 timer, that lead to a crapload of timers being made sending lots of events

Even at 1s tough to many can cause lag for lower users, however changing the distance to a much lower value can largely help
__________________

Last edited by Kilandor; 11-01-2010 at 14:37.
Kilandor is offline
FoxMulder
Senior Member
Join Date: Jan 2009
Location: Orlando, FL
Old 11-06-2010 , 22:55   Re: [TF2] Annotations
Reply With Quote #45

Look's like the event is not closing itself because the handles aren't being freed. I tried spawning a bunch of annotations then waited for them to disappear and did a sm_dump_handles and it still showed them in memory. This would eventually make Sourcemod unload this plugin to free some handles :/

Code:
0x08360673    annotations.smx         GameEvent               -1        
0x07db0674    annotations.smx         GameEvent               -1        
0x07dc0675    annotations.smx         GameEvent               -1        
0x08160676    annotations.smx         GameEvent               -1        
0x07e10677    annotations.smx         GameEvent               -1        
0x07e20678    annotations.smx         GameEvent               -1        
0x07e40679    annotations.smx         GameEvent               -1        
0x07e5067a    annotations.smx         GameEvent               -1        
0x07e6067b    annotations.smx         GameEvent               -1        
0x07e9067c    annotations.smx         GameEvent               -1        
0x081e067d    annotations.smx         GameEvent               -1        
0x07f1067e    annotations.smx         GameEvent               -1        
0x07f2067f    annotations.smx         GameEvent               -1        
0x07f90680    annotations.smx         GameEvent               -1        
0x07fa0681    annotations.smx         GameEvent               -1        
0x082e0682    annotations.smx         GameEvent               -1        
0x08050683    annotations.smx         GameEvent               -1        
0x08060684    annotations.smx         GameEvent               -1        
0x08120686    annotations.smx         GameEvent               -1
__________________
FoxMulder is offline
BrianGriffin
Senior Member
Join Date: Oct 2008
Old 11-07-2010 , 00:27   Re: [TF2] Annotations
Reply With Quote #46

Would it be possible to attach an annotation to a player? For example have a annotation saying "ADMIN" following a player around?
BrianGriffin is offline
FoxMulder
Senior Member
Join Date: Jan 2009
Location: Orlando, FL
Old 11-07-2010 , 01:06   Re: [TF2] Annotations
Reply With Quote #47

Code:
"show_annotation"
    {
        "worldPosX" "float"
        "worldPosY" "float"
        "worldPosZ" "float"
        "id" "long"
        "text"        "string"    // name (unlocalized)
        "lifetime"    "float"
        "visibilityBitfield"    "long" // bitfield of the players that can see this
    }
The annotations can't be parented through this plugin. You can make a really fast timer so it appears to be parented but like I posted before it'll end up crashing.
__________________
FoxMulder is offline
Geit
Senior Member
Join Date: Oct 2009
Location: Home
Old 11-07-2010 , 09:06   Re: [TF2] Annotations
Reply With Quote #48

Quote:
Originally Posted by FoxMulder View Post
Code:
"show_annotation"
    {
        "worldPosX" "float"
        "worldPosY" "float"
        "worldPosZ" "float"
        "id" "long"
        "text"        "string"    // name (unlocalized)
        "lifetime"    "float"
        "visibilityBitfield"    "long" // bitfield of the players that can see this
    }
The annotations can't be parented through this plugin. You can make a really fast timer so it appears to be parented but like I posted before it'll end up crashing.
Fixed the handle leak (Fixed it in a private plugin, forgot to update it here >.>), version 1.41 is up
Geit is offline
Kilandor
Member
Join Date: Sep 2009
Old 11-07-2010 , 13:27   Re: [TF2] Annotations
Reply With Quote #49

Code:
public SpawnAnnotation(id)
{
    new bitstring = BuildBitString(g_AnnotationPosition[id]);
    if (bitstring > 1 || g_AnnotationCanBeSeen[id])
    {
        if (bitstring > 1)
        {
            g_AnnotationCanBeSeen[id] = true;
        }
        else
        {
            g_AnnotationCanBeSeen[id] = false;
        }
        
        new Handle:event = CreateEvent("show_annotation");
        if (event != INVALID_HANDLE)
        {
            SetEventFloat(event, "worldPosX", g_AnnotationPosition[id][0]);
            SetEventFloat(event, "worldPosY", g_AnnotationPosition[id][1]);
            SetEventFloat(event, "worldPosZ", g_AnnotationPosition[id][2]);
            SetEventFloat(event, "lifetime", 10.0);
            SetEventInt(event, "id", id);
            SetEventString(event, "text", g_AnnotationText[id]);
            SetEventInt(event, "visibilityBitfield", bitstring);
            FireEvent(event);
        }
    }
}
This is slightly flawed, this prevents the leak but is improper

if (bitstring > 1 || g_AnnotationCanBeSeen[id])

g_AnnotationCanBeSeen[id] is only set INSIDE of this Call, meaning Lets say if bitstring is 1 it will go in and set this to true, the problem is, lets say bitstring isn't 1, but the previous call it was. This causes it to go into that section anyways the reason it doesn't leak, is because FireEvent ALWAYS gets called unlike before bitstring had to be 1 to fire event. So its still a bit wasteful


So this would be a better solution
Code:
public SpawnAnnotation(id)
{
    new bitstring = BuildBitString(g_AnnotationPosition[id]);
    if (bitstring > 1)
    {
        new Handle:event = CreateEvent("show_annotation");
        if (event != INVALID_HANDLE)
        {
            SetEventFloat(event, "worldPosX", g_AnnotationPosition[id][0]);
            SetEventFloat(event, "worldPosY", g_AnnotationPosition[id][1]);
            SetEventFloat(event, "worldPosZ", g_AnnotationPosition[id][2]);
            SetEventFloat(event, "lifetime", 5.0);
            SetEventInt(event, "id", id);
            SetEventString(event, "text", g_AnnotationText[id]);
            SetEventInt(event, "visibilityBitfield", bitstring);
            FireEvent(event);
        }
    }
}
Alternatively but still wasteful as it still creates an event, this could be done
Code:
public SpawnAnnotation(id)
{
    new Handle:event = CreateEvent("show_annotation");
    if (event != INVALID_HANDLE)
    {
        new bitstring = BuildBitString(g_AnnotationPosition[id]);
        if (bitstring > 1)
        {
            SetEventFloat(event, "worldPosX", g_AnnotationPosition[id][0]);
            SetEventFloat(event, "worldPosY", g_AnnotationPosition[id][1]);
            SetEventFloat(event, "worldPosZ", g_AnnotationPosition[id][2]);
            SetEventFloat(event, "lifetime", 5.0);
            SetEventInt(event, "id", id);
            SetEventString(event, "text", g_AnnotationText[id]);
            SetEventInt(event, "visibilityBitfield", bitstring);
            FireEvent(event);
        }
         else
            CancelCreatedEvent(event);
    }
}
__________________
Kilandor is offline
Geit
Senior Member
Join Date: Oct 2009
Location: Home
Old 11-08-2010 , 17:07   Re: [TF2] Annotations
Reply With Quote #50

Quote:
Originally Posted by Kilandor View Post
This is slightly flawed, this prevents the leak but is improper

if (bitstring > 1 || g_AnnotationCanBeSeen[id])

g_AnnotationCanBeSeen[id] is only set INSIDE of this Call, meaning Lets say if bitstring is 1 it will go in and set this to true, the problem is, lets say bitstring isn't 1, but the previous call it was. This causes it to go into that section anyways the reason it doesn't leak, is because FireEvent ALWAYS gets called unlike before bitstring had to be 1 to fire event. So its still a bit wasteful
This is intended - If a player moves into an area with an annotation visible and has the event sent to them, then moves out of it (and there are no other players in the area), the event will refire and hide the annotation rather than it taking up to 10 seconds to fade out normally.

Also: I Have another series of improvements that I could merge into the SQL version of this plugin, may do it over the weekend or whenever I get some time to do it.

Last edited by Geit; 11-08-2010 at 17:15.
Geit 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 15:22.


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