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

Strange issue with timer


Post New Thread Reply   
 
Thread Tools Display Modes
tommie113
AlliedModders Donor
Join Date: Oct 2013
Old 11-17-2015 , 16:48   Re: Strange issue with timer
Reply With Quote #11

Put your timer in a handle and make it equal to INVALID_HANDLE.
Check at players spawn to only create the timer if that handle equals to invalid handle.
This should prevent the timer from being created twice.
Don't forget to CloseHandle on your timer handle and set it's value back to invalid_handle or you get problems next spawn.
__________________
No longer taking requests due to lack of time and interrest.
Only helping out with minor things through forum.
tommie113 is offline
Blowst
Senior Member
Join Date: Feb 2011
Location: Korea, Republic of
Old 11-17-2015 , 19:55   Re: Strange issue with timer
Reply With Quote #12

PHP Code:
Handle g_hSpawnTimer[MAXPLAYERS+1];

public 
Event_OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
ClearHandle(g_hSpawnTimer);
    
g_hSpawnTimer CreateTimer(1.0Stuffclient);
}


public 
Action Stuff(Handle timerany client
{
    if (
client && IsPlayerAlive(client) && IsClientConnected(client))
    {
        if (
IsPlayerGenericAdmin(client))
        {
            
SetEntProp(clientProp_Send"m_ArmorValue"1001); //armor
            
SetEntProp(clientProp_Send"m_bHasHelmet"1); //helmet
            
GivePlayerItem(client"weapon_hegrenade"); //grenade
            
GivePlayerItem(client"weapon_flashbang"); //flash
            
CPrintToChatAll("{red}%N {orange} jest graczem {purple}Premium{orange}!"client);

        }else
        {
            
SetEntProp(clientProp_Send"m_ArmorValue"1001); //armor
            
SetEntProp(clientProp_Send"m_bHasHelmet"0); //helmet
        
}
    }
}

stock void ClearHandle(Handlehndl)
{
    if(
hndl != null)
    {
        
delete hndl;
        
hndl null;
    }

__________________
Sorry about my poor English

Blowst 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 21:52.


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