Raised This Month: $ Target: $400
 0% 

change variable depending of time hours minutes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
simple_user
Member
Join Date: Apr 2012
Location: Latvia, the cube
Old 05-06-2012 , 17:43   Re: array must be indexed <variable "hour">
Reply With Quote #1

naah... basically what I'm trying to do is to change cvar value depending on time. so I have for example weapon_lights "1" and it changes 0/1 depending of conditions.

PHP Code:
public itstime()
{

    new 
hourString[12]         
    
get_time("%H"hourString11)
    new 
hour str_to_num(hourString

    if ( 
hour && hour 22 )
    
    {
     
set_cvar_num (weapon_lights0)
    }
    
    else 
    if ( 
hour >= 22 || hour <= && task_exists (id) )
    {
    
set_cvar_num (weapon_lights1)
    }

    return 
PLUGIN_HANDLED

__________________
You learn with time. Just gotta push yourself.

Last edited by simple_user; 05-06-2012 at 22:45.
simple_user is offline
Send a message via Skype™ to simple_user
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 05-06-2012 , 18:17   Re: array must be indexed <variable "hour">
Reply With Quote #2

Quote:
Originally Posted by simple_user View Post
naah... basically what I'm trying to do is to change cvar value depending on time. ideal would be to change them directly in amxx.cfg. so I have for example weapon_lights "1" and it changes 0/1 depending of conditions.

PHP Code:
public itstime()
{

    new 
hourString[12]         
    
get_time("%H"hourString11)
    new 
hour str_to_num(hourString

    if ( 
hour && hour 22 )
    
    {
     
//.....set cvars = 0
    
}
    
    else 
    if ( 
hour >= 22 || hour <= && task_exists (id) )
    {
    
//.... set cvars = 1
    
}

    return 
PLUGIN_HANDLED

Your code it is ok.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
simple_user
Member
Join Date: Apr 2012
Location: Latvia, the cube
Old 05-06-2012 , 18:40   Re: array must be indexed <variable "hour">
Reply With Quote #3

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
Your code it is ok.
it's ok so far. I have no idea, how to look for cvar in amxx.cfg, how to change it
__________________
You learn with time. Just gotta push yourself.
simple_user is offline
Send a message via Skype™ to simple_user
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-06-2012 , 21:58   Re: array must be indexed <variable "hour">
Reply With Quote #4

Quote:
Originally Posted by simple_user View Post
it's ok so far. I have no idea, how to look for cvar in amxx.cfg, how to change it
There is no good reason to change it in amxx.cfg dynamically. It would require file operations. It would be better just to check the hour every map start or new round and set the cvar accordingly.
__________________
fysiks is offline
simple_user
Member
Join Date: Apr 2012
Location: Latvia, the cube
Old 05-06-2012 , 22:48   Re: array must be indexed <variable "hour">
Reply With Quote #5

Quote:
Originally Posted by simple_user View Post
naah... basically what I'm trying to do is to change cvar value depending on time. so I have for example weapon_lights "1" and it changes 0/1 depending of conditions.

PHP Code:
public itstime()
{

    new 
hourString[12]         
    
get_time("%H"hourString11)
    new 
hour str_to_num(hourString

    if ( 
hour && hour 22 )
    
    {
     
set_cvar_num (weapon_lights0)
    }
    
    else 
    if ( 
hour >= 22 || hour <= && task_exists (id) )
    {
    
set_cvar_num (weapon_lights1)
    }

    return 
PLUGIN_HANDLED


well, now I need to define something (compiler says so).
__________________
You learn with time. Just gotta push yourself.
simple_user is offline
Send a message via Skype™ to simple_user
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 00:25.


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