AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get Time (https://forums.alliedmods.net/showthread.php?t=308404)

PurposeLessx 06-19-2018 05:35

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

Spoiler

klippy 06-19-2018 05:50

Re: Get Time
 
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.

maqi 06-19-2018 05:51

Re: Get Time
 
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.

PurposeLessx 06-19-2018 05:52

Re: Get Time
 
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 


maqi 06-19-2018 05:53

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

PurposeLessx 06-19-2018 05:55

Re: Get Time
 
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? 


maqi 06-19-2018 05:57

Re: Get Time
 
Yes its wrong, you were kinda fine the first time, arguments are variables to store info to.

PurposeLessx 06-19-2018 05:58

Re: Get Time
 
So it's more optimized the first time?

maqi 06-19-2018 05:59

Re: Get Time
 
Of course

klippy 06-19-2018 06:03

Re: Get Time
 
Quote:

Originally Posted by PurposeLessx (Post 2597904)
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.


All times are GMT -4. The time now is 12:29.

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