AlliedModders

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

MotherFuckerQwerty 09-16-2013 15:04

Help
 
I wanna do a plugin that after 24 hours, it will add a line on a file.

Help please?

Black Rose 09-16-2013 15:27

Re: Help
 
Reason?
This is more of a request than scripting help.

@.SizNeR 09-16-2013 15:36

Re: Help
 
Quote:

Originally Posted by Black Rose (Post 2035891)
Reason?
This is more of a request than scripting help.

He want to make a plugin working on time.

He Just need a little example that after specific time, it will for example write a line in the file.

Black Rose 09-16-2013 15:48

Re: Help
 
Code:
set_task(float(24*60*60), "function"); public function() {     server_print("I'm called 24 hours after set_task()"); }
This will reset the counter every time you change map or restart server since plugins are reloaded then.
If you want something done at a specific time instead of after an amount of time this would be better:
https://forums.alliedmods.net/showpo...0&postcount=10

@.SizNeR 09-16-2013 15:52

Re: Help
 
Quote:

Originally Posted by Black Rose (Post 2035904)
Code:
set_task(float(24*60*60), "function"); public function() {     server_print("I'm called 24 hours after set_task()"); }
This will reset the counter every time you change map or restart server since plugins are reloaded then.
If you want something done at a specific time instead of after an ammount of time this would be better:
https://forums.alliedmods.net/showpo...0&postcount=10

Your way is not good.

MotherFuckerQwerty 09-16-2013 16:02

Re: Help
 
I want that if the map is changed/server shutdown/server restart it will save the time in a file, and if 24 hours has been past from the time in the file, it will write a line in an other file.

Can you help me please?

Black Rose 09-16-2013 16:21

Re: Help
 
Quote:

Originally Posted by @.SizNeR (Post 2035907)
Your way is not good.

I know...

Quote:

Originally Posted by MotherFuckerQwerty (Post 2035920)
I want that if the map is changed/server shutdown/server restart it will save the time in a file, and if 24 hours has been past from the time in the file, it will write a line in an other file.

Can you help me please?

So if the map is changed within these 24 hours should it restart the timer?
I still want a reason. I'm not gonna spend time on something that you may not need just because you didn't explain what you really wanted.

simanovich 09-16-2013 16:34

Re: Help
 
You mean like this?
Code:

#include <amxmodx>
#include <amxmisc>

new const g_szFile[] = "MyFileName.txt";

public plugin_init(){
    new file[128],emp[16];
    get_configsdir(file,charsmax(file));

    format(file,charsmax(file),"%s/%s",file,g_szFile);

    new f = fopen(file);

    if (!f)
    {
        server_print("Error opening file ^"%s^"",file);
        return;
    }

    fgets(f,temp,charsmax(temp));

    new systime = srt_to_num(temp);
   
    if (systime == 0)
        server_print("File ^"%s^" is empty!",file);

    else if ((systime + (60 * 60 * 24)) >= get_systime())
    {
        // Do something...
    }   

    fclose(f);
   
}

public plugin_end(){
    new file[128];
    get_configsdir(file,charsmax(file));

    format(file,charsmax(file),"%s/%s",file,g_szFile);   
   
    new f = fopen(file);

    if (!f)
    {
        server_print("Error opening file ^"%s^"",file);
        return;
    }

    fprintf(f,"%d",get_systime());

    fclose(f);
}



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

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