Solved A Simple Problem

Coding Help/Re-API Supported
Post Reply
Muhammet20
Veteran Member
Veteran Member
Posts: 408
Joined: 5 years ago
Contact:

A Simple Problem

#1

Post by Muhammet20 » 4 years ago

hi all,
i have a simple problem with that plugin

i need the happy hour be from: 20 P.M. to: 8 A.M.
the original is this:

Code: Select all

cvar_init = register_cvar("ze_happyinit", "16")
cvar_end = register_cvar("ze_happyend", "20")
i change it to this:

Code: Select all

cvar_init = register_cvar("ze_happyinit", "20")
cvar_end = register_cvar("ze_happyend", "8")
but it's not working cause of some problems with this:

Code: Select all

new data[3]
get_time("%H", data, 2)

if(get_pcvar_num(cvar_end) > str_to_num(data) >= get_pcvar_num(cvar_init))
i don't know what i should make this:

Code: Select all

get_pcvar_num(cvar_end) > str_to_num(data) >= get_pcvar_num(cvar_init)
i hope someone can help
thanks for read

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#2

Post by Raheem » 4 years ago

Try this:
    1. new szCurrentTime[3]
    2. get_time("%H", szCurrentTime, charsmax(szCurrentTime))
    3.  
    4. new iCurrentTime = str_to_num(szCurrentTime)
    5.  
    6. if (IsTimeInTwoDays())
    7. {
    8.     if ((iCurrentTime >= get_pcvar_num(cvar_init)) || (iCurrentTime < get_pcvar_num(cvar_end)))
    9.     {
    10.         // Happy hours
    11.     }
    12.     else
    13.     {
    14.         // Not happy hours
    15.     }
    16. }
    17. else
    18. {
    19.     if(get_pcvar_num(cvar_end) > iCurrentTime >= get_pcvar_num(cvar_init))
    20.     {
    21.         // Happy hours
    22.     }
    23.     else
    24.     {
    25.         // Not happy hours
    26.     }
    27. }
    28.  
    29. stock IsTimeInTwoDays()
    30. {
    31.     if (get_pcvar_num(cvar_end) < get_pcvar_num(cvar_init))
    32.     {
    33.         return true
    34.     }
    35.    
    36.     return false
    37. }
You must detect that the time is set in two days, then as i did.
He who fails to plan is planning to fail

Muhammet20
Veteran Member
Veteran Member
Posts: 408
Joined: 5 years ago
Contact:

#3

Post by Muhammet20 » 4 years ago

Raheem wrote: 4 years ago Try this:
    1. new szCurrentTime[3]
    2. get_time("%H", szCurrentTime, charsmax(szCurrentTime))
    3.  
    4. new iCurrentTime = str_to_num(szCurrentTime)
    5.  
    6. if (IsTimeInTwoDays())
    7. {
    8.     if ((iCurrentTime >= get_pcvar_num(cvar_init)) || (iCurrentTime < get_pcvar_num(cvar_end)))
    9.     {
    10.         // Happy hours
    11.     }
    12.     else
    13.     {
    14.         // Not happy hours
    15.     }
    16. }
    17. else
    18. {
    19.     if(get_pcvar_num(cvar_end) > iCurrentTime >= get_pcvar_num(cvar_init))
    20.     {
    21.         // Happy hours
    22.     }
    23.     else
    24.     {
    25.         // Not happy hours
    26.     }
    27. }
    28.  
    29. stock IsTimeInTwoDays()
    30. {
    31.     if (get_pcvar_num(cvar_end) < get_pcvar_num(cvar_init))
    32.     {
    33.         return true
    34.     }
    35.    
    36.     return false
    37. }
You must detect that the time is set in two days, then as i did.
ok thanks i will test it on 20 and enter again in 1 in night and enter again in 7 am and enter again in 12 pm

Muhammet20
Veteran Member
Veteran Member
Posts: 408
Joined: 5 years ago
Contact:

#4

Post by Muhammet20 » 4 years ago

Raheem wrote: 4 years ago Try this:
    1. new szCurrentTime[3]
    2. get_time("%H", szCurrentTime, charsmax(szCurrentTime))
    3.  
    4. new iCurrentTime = str_to_num(szCurrentTime)
    5.  
    6. if (IsTimeInTwoDays())
    7. {
    8.     if ((iCurrentTime >= get_pcvar_num(cvar_init)) || (iCurrentTime < get_pcvar_num(cvar_end)))
    9.     {
    10.         // Happy hours
    11.     }
    12.     else
    13.     {
    14.         // Not happy hours
    15.     }
    16. }
    17. else
    18. {
    19.     if(get_pcvar_num(cvar_end) > iCurrentTime >= get_pcvar_num(cvar_init))
    20.     {
    21.         // Happy hours
    22.     }
    23.     else
    24.     {
    25.         // Not happy hours
    26.     }
    27. }
    28.  
    29. stock IsTimeInTwoDays()
    30. {
    31.     if (get_pcvar_num(cvar_end) < get_pcvar_num(cvar_init))
    32.     {
    33.         return true
    34.     }
    35.    
    36.     return false
    37. }
You must detect that the time is set in two days, then as i did.
i changed my computer time and i tested it and it's working success , thanks , +Like

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 2 guests