Raised This Month: $ Target: $400
 0% 

[SOLVED] Detect player driving vehicle - for what time?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-09-2014 , 08:53   Re: Detect player using rally car key for some time
Reply With Quote #1

Assuming that Ham_Use will be called both when the player started and stopped driving, I thought of something like this:
PHP Code:

new g_timesUsed[33]
new 
g_tempTime[33]
new 
g_secondsDriving[33]

public 
plugin_init()
{
    
RegisterHam(Ham_Use"func_vehicle""eventVehicleUsed"true)
}

public 
eventVehicleUsed(thisididactivatoruse_typeFloat:value)
{
    
g_timesUsed[id]++

    
// started driving
    
if(g_timesUsed[id] % 2)
    {
        
g_tempTime[id] = get_systime()
    }
    
// stopped driving
    
else
    {
        
g_secondsDriving += get_systime() - g_tempTime[id]
    }


Check this out:
https://forums.alliedmods.net/showpo...61&postcount=7

Last edited by mottzi; 07-09-2014 at 09:03.
mottzi is offline
Send a message via MSN to mottzi
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:17.


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