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

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 01-20-2018 , 23:40   Re: New API and Syntax
Reply With Quote #911

Quote:
Originally Posted by Headline View Post
I believe a 0.0 second timer will fire on the next frame
The timer resolution of ~0.1s still applies to a 0s timer. A 0s timer will fire anywhere from the next frame to ~0.1s later.
Fyren is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 01-21-2018 , 04:07   Re: New API and Syntax
Reply With Quote #912

Quote:
Originally Posted by Fyren View Post
The timer resolution of ~0.1s still applies to a 0s timer. A 0s timer will fire anywhere from the next frame to ~0.1s later.

Ok. I think this should work together with RequestFrame then.

Code:
bool mapChange;

public void OnMapStart{ mapChange = true; CreateTimer(15.0, resetBool); }

void NextFrame(int client)
{
	if (mapChange || !IsValidClient(client)) return;  // mapchange check. During a mapchange clients are connected but not in game (I think).
}

Last edited by Visual77; 01-21-2018 at 04:11.
Visual77 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 01-21-2018 , 04:33   Re: New API and Syntax
Reply With Quote #913

Quote:
Originally Posted by Visual77 View Post
Ok. I think this should work together with RequestFrame then.

Code:
bool mapChange;

public void OnMapStart{ mapChange = true; CreateTimer(15.0, resetBool); }

void NextFrame(int client)
{
	if (mapChange || !IsValidClient(client)) return;  // mapchange check. During a mapchange clients are connected but not in game (I think).
}
If you want to replicate TIMER_FLAG_NO_MAPCHANGE, you should set the bool in OnMapEnd and clear it in OnMapStart.
__________________
asherkin is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 01-21-2018 , 04:43   Re: New API and Syntax
Reply With Quote #914

Quote:
Originally Posted by asherkin View Post
If you want to replicate TIMER_FLAG_NO_MAPCHANGE, you should set the bool in OnMapEnd and clear it in OnMapStart.
Ok, I'll use that instead. Thanks
Visual77 is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 03-04-2018 , 06:56   Re: New API and Syntax
Reply With Quote #915

Hi. So I want to close a datapack with the new syntax, but different plugins use different ways to free the datapack. Normally I would go for delete datapack until I saw plugins using DataPack.Close
(which I can't find as a valid method in https://sm.alliedmods.net/new-api/datapack/DataPack)

Can anyone confirm if I'm thinking right on this:

Code:
public void CvarClientQuery(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue, DataPack cvarData)
{
	cvarData.Reset();
	char cAction[32];
	cvarData.ReadString(cAction, sizeof(cAction));
	int value = cvarData.ReadCell();
	delete cvarData; I assume this is valid
	cvarData.Close();  I assume this is invalid?
	CloseHandle(cvarData); I assume this is valid?
}

Last edited by Visual77; 03-04-2018 at 06:56.
Visual77 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 03-04-2018 , 07:06   Re: New API and Syntax
Reply With Quote #916

delete is preferred, all 3 are valid (Handle.Close is a built-in on the Handle methodmap).
__________________
asherkin is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 03-04-2018 , 07:14   Re: New API and Syntax
Reply With Quote #917

Ok, thanks. It's better to be consistent so I'll continue with "delete" in all cases.
Visual77 is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 03-04-2018 , 18:05   Re: New API and Syntax
Reply With Quote #918

Quote:
Originally Posted by asherkin View Post
delete is preferred, all 3 are valid (Handle.Close is a built-in on the Handle methodmap).
Sorry for the double post but I have a memory leakage problem here. A repeated timer (5.0 sec) runs a loop on all connected players and creates 62 datapacks together with 62 QueryClientConvars. One datapack is sent to each QueryClientConVar, where it's read and destroyed. 20 players means a maximum possibility of 1240 datapacks being read and immediately destroyed. I've done it like I showed you in the code above.

At the first 10-15 minutes of plugin load, there is no memory leakage. Everything works as expected on a full server. sm_dump_handles handles.txt shows a slight increase in datapacks during the loop request and when doing the dump request again, those handles have freed themselves.

However, after letting the plugin run for some time, sm_dump_handle reports as to having 3100 open datapacks which must be a memory leakage. And when I keep refreshing the handle dump, it's either still 3100 or higher than 3100. It doesn't make sense to me.

Search "l4d2_clienthack_dete DataPack" (3100 hits in 1 file)
C:\Desktop\handles.txt (3100 hits)
Line 43: 0x3a4c0059 l4d2_clienthack_dete DataPack 84
Line 44: 0x1e09005a l4d2_clienthack_dete DataPack 84
Line 263: 0x1a180180 l4d2_clienthack_dete DataPack 84

Last edited by Visual77; 03-04-2018 at 18:17.
Visual77 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 03-04-2018 , 18:25   Re: New API and Syntax
Reply With Quote #919

Can’t really help you without seeing the full code. You should probably add some logging to your plugin to ensure it is behaving as you expect (and post a thread of your own in this handy thread-based forum system we have).
__________________

Last edited by asherkin; 03-04-2018 at 18:26.
asherkin is offline
Pyc
Senior Member
Join Date: Jan 2014
Old 07-23-2018 , 11:03   Re: New API and Syntax
Reply With Quote #920

hey there
someone can help translate colors.inc v1.2.3 to new syntax?
https://forums.alliedmods.net/showpo...&postcount=407
Pyc is offline
Reply


Thread Tools
Display Modes

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 08:41.


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