Coding Help/Re-API Supported
-
Muhammet20
- Veteran Member
- Posts: 408
- Joined: 5 years ago
-
Contact:
-
Quote
-
0
login to like this post
#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
-
Raheem
- Mod Developer
- Posts: 2214
- Joined: 7 years ago
-
Contact:
-
Quote
-
0
login to like this post
#2
Post
by Raheem » 4 years ago
Try this:
new szCurrentTime[3]
get_time("%H", szCurrentTime, charsmax(szCurrentTime))
new iCurrentTime = str_to_num(szCurrentTime)
if (IsTimeInTwoDays())
{
if ((iCurrentTime >= get_pcvar_num(cvar_init)) || (iCurrentTime < get_pcvar_num(cvar_end)))
{
// Happy hours
}
else
{
// Not happy hours
}
}
else
{
if(get_pcvar_num(cvar_end) > iCurrentTime >= get_pcvar_num(cvar_init))
{
// Happy hours
}
else
{
// Not happy hours
}
}
stock IsTimeInTwoDays()
{
if (get_pcvar_num(cvar_end) < get_pcvar_num(cvar_init))
{
return true
}
return false
}
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
- Posts: 408
- Joined: 5 years ago
-
Contact:
-
Quote
-
0
login to like this post
#3
Post
by Muhammet20 » 4 years ago
Raheem wrote: ↑4 years ago
Try this:
new szCurrentTime[3]
get_time("%H", szCurrentTime, charsmax(szCurrentTime))
new iCurrentTime = str_to_num(szCurrentTime)
if (IsTimeInTwoDays())
{
if ((iCurrentTime >= get_pcvar_num(cvar_init)) || (iCurrentTime < get_pcvar_num(cvar_end)))
{
// Happy hours
}
else
{
// Not happy hours
}
}
else
{
if(get_pcvar_num(cvar_end) > iCurrentTime >= get_pcvar_num(cvar_init))
{
// Happy hours
}
else
{
// Not happy hours
}
}
stock IsTimeInTwoDays()
{
if (get_pcvar_num(cvar_end) < get_pcvar_num(cvar_init))
{
return true
}
return false
}
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
- Posts: 408
- Joined: 5 years ago
-
Contact:
-
Quote
-
0
login to like this post
#4
Post
by Muhammet20 » 4 years ago
Raheem wrote: ↑4 years ago
Try this:
new szCurrentTime[3]
get_time("%H", szCurrentTime, charsmax(szCurrentTime))
new iCurrentTime = str_to_num(szCurrentTime)
if (IsTimeInTwoDays())
{
if ((iCurrentTime >= get_pcvar_num(cvar_init)) || (iCurrentTime < get_pcvar_num(cvar_end)))
{
// Happy hours
}
else
{
// Not happy hours
}
}
else
{
if(get_pcvar_num(cvar_end) > iCurrentTime >= get_pcvar_num(cvar_init))
{
// Happy hours
}
else
{
// Not happy hours
}
}
stock IsTimeInTwoDays()
{
if (get_pcvar_num(cvar_end) < get_pcvar_num(cvar_init))
{
return true
}
return false
}
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
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
Users browsing this forum: No registered users and 2 guests