Raised This Month: $ Target: $400
 0% 

Remove after specific time


Post New Thread Reply   
 
Thread Tools Display Modes
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-27-2012 , 20:07   Re: Remove after specific time
Reply With Quote #31

Quote:
Originally Posted by Pewdiepie View Post
So what if I save the current date (Timestamp[id]) in nvault. Everytime the player connects it'll check if the date has expired yet. If it did it will remove the purchase. Am I doing this correct?
Assuming the rest of you plugin is coded properly, yes
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 10-27-2012 , 20:08   Re: Remove after specific time
Reply With Quote #32

Quote:
Originally Posted by Pewdiepie View Post
So what if I save the current date (Timestamp[id]) in nvault. Everytime the player connects it'll check if the date has expired yet. If it did it will remove the purchase. Am I doing this correct?
Yes, you are right.

In addition, I think it is better to save (on Timestamp[ id ]) this:
PHP Code:
new days 5;
Timestampid ] = get_systime( ) + 86400 days
So you can create a command and pass "days" as an argument.

To check if "days" passed:
PHP Code:
if( get_systime( ) >= Timestampid ] )
    
// Your purchase has been removed 
__________________

Last edited by Neeeeeeeeeel.-; 10-27-2012 at 20:08.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Pewdiepie
Senior Member
Join Date: Oct 2012
Old 10-27-2012 , 20:08   Re: Remove after specific time
Reply With Quote #33

So what did I actually do wrong in my previous code i've posted?

EDIT: Neeeeel, nice idea. But it's not that necessary

Last edited by Pewdiepie; 10-27-2012 at 20:09.
Pewdiepie is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-27-2012 , 20:09   Re: Remove after specific time
Reply With Quote #34

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
In addition, I think it is better to save (on Timestamp[ id ]) this:
PHP Code:
new days 5;
Timestampid ] = get_systime( ) + 86400 days
So you can create a command and pass "days" as an argument.
But there are not 3600 seconds in a day. Also, if you really want to rely on variables so much, #include <time> and use SECONDS_IN_DAY
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Pewdiepie
Senior Member
Join Date: Oct 2012
Old 10-27-2012 , 20:10   Re: Remove after specific time
Reply With Quote #35

Quote:
Originally Posted by YamiKaitou View Post
But there are not 3600 seconds in a day. Also, if you really want to rely on variables so much, #include <time> and use SECONDS_IN_DAY
I think he got confused with hours
Pewdiepie is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-27-2012 , 20:11   Re: Remove after specific time
Reply With Quote #36

Quote:
Originally Posted by Pewdiepie View Post
So what did I actually do wrong in my previous code i've posted?
Nothing, just a bad example



Quote:
Originally Posted by Pewdiepie View Post
I think he got confused with hours
He fixed it already
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 10-27-2012 , 20:11   Re: Remove after specific time
Reply With Quote #37

Quote:
Originally Posted by YamiKaitou View Post
But there are not 3600 seconds in a day. Also, if you really want to rely on variables so much, #include <time> and use SECONDS_IN_DAY
I noticed that after I posted it.
__________________

Last edited by Neeeeeeeeeel.-; 10-27-2012 at 20:11.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Pewdiepie
Senior Member
Join Date: Oct 2012
Old 10-27-2012 , 20:13   Re: Remove after specific time
Reply With Quote #38

What about this, I know there's not as much difference between this one and the last.

But i'm trying to learn more about this.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>

#define PLUGIN "Auto remove"
#define VERSION "1.0"
#define AUTHOR "Pewdie"

new Timestamp[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /purchase""Cmdtest")
    
    
set_task(1.0"Cmdcheck", .flags="b")
}

public 
Cmdtest(id)
{
    new 
Days 30
    Timestamp
[id] = get_systime() + 86400 Days
    
    client_print
(idprint_chat"You purchased an item!")
}

public 
Cmdcheck()
{
    new 
players[32], num
    get_players
(playersnum"ch")
    
    for (new 
0<numi++)
    {
        new 
id players[i]
        
        if (
Timestamp[id] == get_systime())
        {
            
client_print(idprint_chat"Your purchase has been removed!")
        }
    }

Correct me if im doing anything wrong please.
Pewdiepie is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-27-2012 , 20:16   Re: Remove after specific time
Reply With Quote #39

Nothing has changed, it is still the same bad example, but a functional one.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Pewdiepie
Senior Member
Join Date: Oct 2012
Old 10-27-2012 , 20:18   Re: Remove after specific time
Reply With Quote #40

Quote:
Originally Posted by YamiKaitou View Post
Nothing has changed, it is still the same bad example, but a functional one.
Can you correct the plugin on your way?

Btw, thanks for the fast replys everyone!
Pewdiepie 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 13:10.


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