Raised This Month: $ Target: $400
 0% 

Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MotherFuckerQwerty
New Member
Join Date: Sep 2013
Old 09-16-2013 , 15:04   Help
Reply With Quote #1

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

Help please?

Last edited by MotherFuckerQwerty; 09-16-2013 at 15:19.
MotherFuckerQwerty is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-16-2013 , 15:27   Re: Help
Reply With Quote #2

Reason?
This is more of a request than scripting help.
__________________
Black Rose is offline
@.SizNeR
Member
Join Date: Jun 2013
Old 09-16-2013 , 15:36   Re: Help
Reply With Quote #3

Quote:
Originally Posted by Black Rose View Post
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.

Last edited by @.SizNeR; 09-16-2013 at 16:04.
@.SizNeR is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-16-2013 , 15:48   Re: Help
Reply With Quote #4

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
__________________

Last edited by Black Rose; 09-16-2013 at 15:49.
Black Rose is offline
@.SizNeR
Member
Join Date: Jun 2013
Old 09-16-2013 , 15:52   Re: Help
Reply With Quote #5

Quote:
Originally Posted by Black Rose View Post
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.

Last edited by @.SizNeR; 09-16-2013 at 16:02.
@.SizNeR is offline
MotherFuckerQwerty
New Member
Join Date: Sep 2013
Old 09-16-2013 , 16:02   Re: Help
Reply With Quote #6

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?
MotherFuckerQwerty is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-16-2013 , 16:21   Re: Help
Reply With Quote #7

Quote:
Originally Posted by @.SizNeR View Post
Your way is not good.
I know...

Quote:
Originally Posted by MotherFuckerQwerty View Post
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.
__________________
Black Rose is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 09-16-2013 , 16:34   Re: Help
Reply With Quote #8

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);
}
__________________

Last edited by simanovich; 09-17-2013 at 06:26. Reason: Fixing something
simanovich is offline
Reply


Thread Tools
Display Modes

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 19:02.


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