AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   Dynamic Objects and Properties - v.0.0.32 - [2018.05.08] (https://forums.alliedmods.net/showthread.php?t=270519)

Muhlex 05-12-2019 10:01

Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
 
I am currently trying to implement Dynamic into a series of plugins, simply for allowing easy access to data tied to clients for each plugin. Thus I am trying to use the static player settings object. This seems to work so far, however the data is not cleared when a client disconnects.

The wiki mentions that "Player Settings members are reset during Sourcemod's OnClientDisconnect_Post forward". Contrary to that, set values persist for the clients, even after rejoining the server.

Looking at the plugin code of dynamic.sp, this seems to be due to the OnClientDisconnect_Post forward not using public, but being declared as stock instead.

PHP Code:

stock void OnClientDisconnect_Post(int client)
{
    
_Dynamic_ResetObject(client);


I am still an amateur at Sourcepawn so I might have completely missed something obvious here.

Neuro Toxin 05-12-2019 18:48

Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
 
Quote:

Originally Posted by ThatOneGuy (Post 2630742)
They PM'd me. I believe it may be an error on my end.

In Event_PlayerDeath (and round end for those still alive), I was combining stats from multiple dynamic objects held in an ArrayList, I was removing/disposing one each time they were combined. In doing so, I didnt have the .IsValid check and thought I was fine without it by tracking how many cells the array had, using the .Erase function (shifting it), and going in reverse order. Somewhere, my logic has a scenario the leads to an invalid object. My fix for now is the .IsValid check. Am waiting to hear back from the poster regarding whether or not the issue is resolved, but I dont believe the error involves dynamic.

To make it more confusing for me, I had a memory leak (now patched) in that I forgot to dispose the objects being removed from the arraylist when they were combined. I was only disposing dynamic objects on next round start. That said, it is strange that an object was already disposed if there was no disposing until after all the processing was done...Is there not multiple seconds between round end/start events (during which all processing should be complete, so all objects should have still been valid)? I suppose I should test that assumption. That said, assuming there is time between those events, I dont understand how any dynamic object being processed could be already disposed. I can send you my code if needed. The .inc file was auto-generated from your tool.

EDIT: .IsValid causes other errors. Plugin is now recoded without Dynamic and all errors are gone.

.Dispose has a parameter disposemembers which defaults to true. This disposes Dynamic member types and deletes Handle member types.

It sounds like they had been referencing the disposed object elsewhere which was being disposed by its parent.

Neuro Toxin 05-12-2019 18:50

Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
 
Quote:

Originally Posted by Muhlex (Post 2651343)
I am currently trying to implement Dynamic into a series of plugins, simply for allowing easy access to data tied to clients for each plugin. Thus I am trying to use the static player settings object. This seems to work so far, however the data is not cleared when a client disconnects.

The wiki mentions that "Player Settings members are reset during Sourcemod's OnClientDisconnect_Post forward". Contrary to that, set values persist for the clients, even after rejoining the server.

Looking at the plugin code of dynamic.sp, this seems to be due to the OnClientDisconnect_Post forward not using public, but being declared as stock instead.

PHP Code:

stock void OnClientDisconnect_Post(int client)
{
    
_Dynamic_ResetObject(client);


I am still an amateur at Sourcepawn so I might have completely missed something obvious here.

That would be the error. Thanks for letting me know. Try making the void public and recompiling.

I need to push some updates so I will try patch it up in the next few days.

Muhlex 05-12-2019 19:04

Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
 
I tried to do that but faced some errors on compile which are probably due to me having left out a file when installing. I didn't bother afterwards and can't get around to trying it again at the moment. However I did try to just include Dynamic_ResetObject(client) on Disconnect_Post in my own plugin earlier, which did fix the issue.

freak.exe_uLow 09-02-2019 17:31

Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
 
Hey, i hope the plugin still has support :D I use the plugin for an advertising plugin and wanted to have a look at the handles, can it be that these leaks has?

Code:

Plugin              Handles            Memory
dynamic.smx            240                76336 bytes


milutinke 04-10-2020 08:03

Re: Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]
 
PHP Code:

L 04/10/2020 13:54:33: [SMException reportedScript execution timed out
L 04
/10/2020 13:54:33: [SMBlamingdynamic.smx
L 04
/10/2020 13:54:33: [SMCall stack trace:
L 04/10/2020 13:54:33: [SM]   [1Line 117, ..\dynamic.sp::OnPluginEnd
L 04
/10/2020 13:54:33Error log file session closed

Does it have something with the unclosed Dynamic?
I close my Dynamic at OnPluginEnd(), and create it at OnAllPluginsLoaded().
Should I just increase the timeout time, but this maybe will freeze the server on the map change?

Edit: I have solved the error by closing the dynamic immediately after I am done with it.
But sometimes Dynamics freezes the server OnPluginEnd without any operations performed. (I tried running just the default plugins and Dynamic)


All times are GMT -4. The time now is 14:23.

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