AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Doing something on specific date-time (https://forums.alliedmods.net/showthread.php?t=167790)

reinert 09-20-2011 08:15

Doing something on specific date-time
 
Hey, how to grab the specific time like I want to do some action every day on 3:00 PM.

tuty 09-20-2011 08:49

Re: Doing something on specific date-time
 
i made an entity wich thinks every minute to check time :) then a stock to return your specified 12 hour day time..


PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define MINUTE_IN_SEC        60

new const gEntityClassname[ ] = "_Thinker.";
new const 
gSpecifiedTime[ ] = "3:00 PM";

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
    
UTIL_CreateThinker( );
    
register_thinkgEntityClassname"forward_Thinker" );
}

public 
forward_ThinkeriEnt )
{
    if( 
pev_validiEnt ) )
    {
        
set_peviEntpev_nextthinkget_gametime( ) + MINUTE_IN_SEC );
        
        if( 
UTIL_GetSpecifiedTime( ) )
        {
            
// it's your time do your thing
        
}
    }
}

stock UTIL_CreateThinker( )
{
    new 
iEnt create_entity"info_target" );
        
    if( !
pev_validiEnt ) )
    {
        return 
PLUGIN_HANDLED;
    }
    
    
set_peviEntpev_classnamegEntityClassname );
    
set_peviEntpev_nextthinkget_gametime( ) + MINUTE_IN_SEC );
    
    return 
PLUGIN_HANDLED;
}

stock UTIL_GetSpecifiedTime( )
{
    new 
iTime30 ];
    
get_time"%I:%M %p"iTimecharsmaxiTime ) );
    
    if( 
strcmpiTimegSpecifiedTime ) == )
    {
        return 
1;
    }
    
    else
    {
        return 
0;
    }
    
    return 
0;



Hunter-Digital 09-20-2011 23:34

Re: Doing something on specific date-time
 
I think it would be more efficient to just get time when the map starts and then calculate how many seconds are until the target time, then just set a task, if the map lasts until that time, it'll trigger, if not, the next map will set a new task and so on.

tuty 09-21-2011 06:10

Re: Doing something on specific date-time
 
i just shown my type of idea, if you have a better one share it xD

fysiks 09-21-2011 18:10

Re: Doing something on specific date-time
 
Quote:

Originally Posted by tuty (Post 1559933)
if you have a better one share it xD

He just did!

tuty 09-22-2011 06:35

Re: Doing something on specific date-time
 
lol i mean the code not theory

Erox902 09-22-2011 07:44

Re: Doing something on specific date-time
 
Quote:

Originally Posted by tuty (Post 1560663)
lol i mean the code not theory

He just gave you an example, this is scripting help so imo it would'nt even be nice of him if he just gave out the code.
Then that dude who asked for it doesn't even need to understand the code he could just come here and ask for everything he needs and copy paste until he have a full plugin.

That stuff I think should rather be in requests section.

tuty 09-22-2011 14:13

Re: Doing something on specific date-time
 
are you fucking retarded? i know how to do it and i dont want this fricking code...i didnt requested this just read my fucking posts. if my code can help you i'm glad, if not gtfo :/ im too lazy to create his code for someone who need this...

Erox902 09-22-2011 14:19

Re: Doing something on specific date-time
 
Quote:

Originally Posted by tuty (Post 1560924)
are you fucking retarded? i know how to do it and i dont want this fricking code...i didnt requested this just read my fucking posts. if my code can help you i'm glad, if not gtfo :/ im too lazy to create his code for someone who need this...

Yeah exactly!
I did'nt want you to post a code!
Read your own post again and then mine and try to understand.
You told him to post his code not just explain how he does it.
I'm saying he should not!

hleV 09-22-2011 14:37

Re: Doing something on specific date-time
 
Quote:

Originally Posted by tuty (Post 1560924)
are you fucking retarded? i know how to do it and i dont want this fricking code...i didnt requested this just read my fucking posts. if my code can help you i'm glad, if not gtfo :/ im too lazy to create his code for someone who need this...

Hunter-Digital's way (even if not displayed in a code) is obviously better than yours. Instead of saying "use whatever you like" you should advise the guy to use the better way, and instead of requesting the guy with better idea to create a code, do it yourself if you feel like it's needed (and as it turns out, it's not). Unless, of couse, you don't realize which way is better, in which case you probably shouldn't be helping people at all, since in this case it's pretty obvious.

Not trying to sound rude here, but if you intend to help, then help.


All times are GMT -4. The time now is 19:40.

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