Resolved A Simple Problem

Coding Help/Re-API Supported
Post Reply
User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 391
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

A Simple Problem

#1

Post by Muhammet20 » 2 Months 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
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#2

Post by Raheem » 2 Months 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.
These users thanked the author Raheem for the post:
Muhammet20 (2 Months Ago)
You don't know? Learn and you will know.

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 391
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#3

Post by Muhammet20 » 2 Months Ago

Raheem wrote:
2 Months 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
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 391
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#4

Post by Muhammet20 » 2 Months Ago

Raheem wrote:
2 Months 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
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests