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

[TF2] Problem with closehandle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 07-12-2015 , 08:00   [TF2] Problem with closehandle
Reply With Quote #1

I have problem closing a handle that errors out
Log:
Code:
L 07/12/2015 - 13:55:42: [SM] Native "CloseHandle" reported: Handle 6b113027 is invalid (error 3)
L 07/12/2015 - 13:55:42: [SM] Displaying call stack trace for plugin "bwr2.smx":
L 07/12/2015 - 13:55:42: [SM]   [0]  Line 6504, D:\TF2Server\server\tf\addons\sourcemod\scripting\bwr2.sp::OnEntityDestroyed()
Closing code:

PHP Code:
        if(ObjTimer[obj] != INVALID_HANDLE)
        {
            
CloseHandle(ObjTimer[obj]);
            
ObjTimer[obj] = INVALID_HANDLE;  
        } 
Handle's timer:
PHP Code:
ObjTimer[obj] = CreateTimer(0.1,NewGlow,obj,TIMER_REPEAT); 
Anyone know how I can solve this problem?

PS I can't use return Plugin_Stop in OnEntityDestroyed() cos it disallow me to write to it Action:
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player
Michalplyoutube is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 07-12-2015 , 17:19   Re: [TF2] Problem with closehandle
Reply With Quote #2

Your timer has already expired, so its handle is invalid. Set the handle to invalid handle inside of the timer so that when it is called/terminates your variable is set properly.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-12-2015 , 18:31   Re: [TF2] Problem with closehandle
Reply With Quote #3

Quote:
Originally Posted by friagram View Post
Your timer has already expired, so its handle is invalid. Set the handle to invalid handle inside of the timer so that when it is called/terminates your variable is set properly.
It's a repeating timer not marked as expiring on map change, so it won't expire until you return Plugin_Stop in its handler.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
arthurdead
Senior Member
Join Date: Jul 2013
Old 07-12-2015 , 19:26   Re: [TF2] Problem with closehandle
Reply With Quote #4

you need KillTimer on repeated timers
arthurdead is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 07-13-2015 , 01:14   Re: [TF2] Problem with closehandle
Reply With Quote #5

I thought the only difference between killtimer and closehandle, is that with killtimer you can have the handle of the datapack that is passed along with it closed too.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
VoiDeD
AlliedModders Donor
Join Date: Mar 2009
Location: Illinois, USA
Old 07-13-2015 , 07:39   Re: [TF2] Problem with closehandle
Reply With Quote #6

Quote:
Originally Posted by friagram View Post
I thought the only difference between killtimer and closehandle, is that with killtimer you can have the handle of the datapack that is passed along with it closed too.
CloseHandle calls the same KillTimer logic internally. So yes, that's correct.
__________________
VoiDeD is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 07-13-2015 , 10:26   Re: [TF2] Problem with closehandle
Reply With Quote #7

Quote:
Originally Posted by arthurdead View Post
you need KillTimer on repeated timers
It won't me let do that still errors out

I also can't call return Plugin_Stop; on OnEntityDestroyed cos void

When i put the invalid_handle; in timer tag mismatch...
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player

Last edited by Michalplyoutube; 07-13-2015 at 10:28.
Michalplyoutube is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-13-2015 , 10:50   Re: [TF2] Problem with closehandle
Reply With Quote #8

What is the code for NewGlow?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 07-13-2015 , 11:41   Re: [TF2] Problem with closehandle
Reply With Quote #9

Quote:
Originally Posted by Powerlord View Post
What is the code for NewGlow?
Here's

PHP Code:
public Action:NewGlow(Handle:timer,any:obj)
{
    if(!
IsValidEntity(obj)) return Plugin_Stop;
    
decl String:sBuffer[PLATFORM_MAX_PATH];
    
GetEntPropString(objProp_Data"m_ModelName"sBuffersizeof(sBuffer));
    if(
StrContains(sBuffer"sentry") != -1)
    {
        if(
StrContains(sBuffer"heavy") == -1)
        {
            
CreateTimer(0.1,Glow,obj);
            if(
IsValidEntity(ObjGlow[obj]))
                
RemoveEdict(ObjGlow[obj]);        
            
//AcceptEntityInput(ObjGlow[obj],"Kill");
            
ObjGlow[obj] = -1;
            return 
Plugin_Stop;
        }
    }
    else
    {
        if(
StrContains(sBuffer"light") != -1)
        {
            
CreateTimer(0.1,Glow,obj);
            if(
IsValidEntity(ObjGlow[obj]))
                
RemoveEdict(ObjGlow[obj]);    
            
//AcceptEntityInput(ObjGlow[obj],"Kill");
            
ObjGlow[obj] = -1;
            return 
Plugin_Stop;
        }
    }
    return 
Plugin_Continue;

__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player
Michalplyoutube is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-13-2015 , 13:19   Re: [TF2] Problem with closehandle
Reply With Quote #10

In the two spots you have
Code:
return Plugin_Stop;
you also need a
Code:
ObjTimer[obj] = INVALID_HANDLE;
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 14:40.


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