Raised This Month: $51 Target: $400
 12% 

Get Time


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 06-19-2018 , 05:35   Get Time
Reply With Quote #1

I made a plugin who works according to time. Is there any mistake here or how can I optimize it?

Spoiler
PurposeLessx is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-19-2018 , 05:50   Re: Get Time
Reply With Quote #2

Use time() so you don't have to work with strings. I don't know why people keep doing that, I've seen it many times over the years.
__________________
klippy is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-19-2018 , 05:51   Re: Get Time
Reply With Quote #3

You are hardcoding and writing repetitive and inefficient code.

It could work, but the code you sent, In my opinion, is one big bad practice.
__________________
stuff
maqi is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 06-19-2018 , 05:52   Re: Get Time
Reply With Quote #4

How I will use it?

PHP Code:
//static ctime[3], btime[3];
new ctimebtime;
time(ctimebtime);

if(
ctime == 11//if hours are 11

if(btime == 0// if minute(s) is 0 
PurposeLessx is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-19-2018 , 05:53   Re: Get Time
Reply With Quote #5

time() returns a unix timestamp, other than that, aarguments can be found here https://www.amxmodx.org/api/core/time
__________________
stuff

Last edited by maqi; 06-19-2018 at 05:54.
maqi is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 06-19-2018 , 05:55   Re: Get Time
Reply With Quote #6

I don't understand in amxmodx.org. It's for not new codders I guess.

is it wrong?

PHP Code:
if(time(11)) // hours are 11? 

Last edited by PurposeLessx; 06-19-2018 at 05:55.
PurposeLessx is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-19-2018 , 05:57   Re: Get Time
Reply With Quote #7

Yes its wrong, you were kinda fine the first time, arguments are variables to store info to.
__________________
stuff
maqi is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 06-19-2018 , 05:58   Re: Get Time
Reply With Quote #8

So it's more optimized the first time?
PurposeLessx is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-19-2018 , 05:59   Re: Get Time
Reply With Quote #9

Of course
__________________
stuff
maqi is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-19-2018 , 06:03   Re: Get Time
Reply With Quote #10

Quote:
Originally Posted by PurposeLessx View Post
How I will use it?

PHP Code:
//static ctime[3], btime[3];
new ctimebtime;
time(ctimebtime);

if(
ctime == 11//if hours are 11

if(btime == 0// if minute(s) is 0 
Yes, that is correct and is probably the best way to retrieve the current time in h/m/s as integers.
__________________

Last edited by klippy; 06-19-2018 at 06:04.
klippy is offline
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 09:26.


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