Raised This Month: $51 Target: $400
 12% 

Remove after specific time


Post New Thread Reply   
 
Thread Tools Display Modes
Pewdiepie
Senior Member
Join Date: Oct 2012
Old 10-27-2012 , 19:32   Re: Remove after specific time
Reply With Quote #21

Quote:
Originally Posted by YamiKaitou View Post
PHP Code:
if (timestamp+2592000) <= get_systime())
     
// 30 days has passed
else
    
// 30 days has not passed 
What is timestamp?
Pewdiepie is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-27-2012 , 19:33   Re: Remove after specific time
Reply With Quote #22

Quote:
Originally Posted by Pewdiepie View Post
What is timestamp?
The date that you are checking to see if 30 days has elapsed
__________________
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 , 19:39   Re: Remove after specific time
Reply With Quote #23

Quote:
Originally Posted by YamiKaitou View Post
The date that you are checking to see if 30 days has elapsed
So i have to save the date it activated in timestamp. After that i have to do
PHP Code:
if (Timestamp 2592000) <= get_systime()) 
Am i doing this correct?

Note: What does get_systime() do?
Pewdiepie is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-27-2012 , 19:44   Re: Remove after specific time
Reply With Quote #24

Quote:
Originally Posted by Pewdiepie View Post
So i have to save the date it activated in timestamp. After that i have to do
PHP Code:
if (Timestamp 2592000) <= get_systime()) 
Am i doing this correct?
If Timestamp contains a valid timestamp in seconds, then yes

EDIT: I found a typo, I missed the first (

Quote:
Note: What does get_systime() do?
It gets the current time in seconds, counting since Unix Epoch. More details: http://en.wikipedia.org/wiki/Unix_time
__________________
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).

Last edited by YamiKaitou; 10-27-2012 at 19:44.
YamiKaitou is offline
Pewdiepie
Senior Member
Join Date: Oct 2012
Old 10-27-2012 , 19:51   Re: Remove after specific time
Reply With Quote #25

So it would look like this?

Note: Without saving the timestamp or checking if user already has purchased. Just a quick example.

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)
{
    
Timestamp[id] = get_systime()
    
    
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] + 2592000 <= get_systime())
        {
            
client_print(idprint_chat"Your purchase has been removed!")
        }
    }


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

The statement will also be false in that example. But yes, you get the basic idea
__________________
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 , 19:56   Re: Remove after specific time
Reply With Quote #27

Quote:
Originally Posted by YamiKaitou View Post
The statement will also be false in that example. But yes, you get the basic idea
So what will this actually check?

PHP Code:
if (Timestamp[id] + 2592000 <= get_systime())
        {
            
client_print(idprint_chat"Your purchase has been removed!")
        } 
It will check if the current date + 2592000 = lower or equal to get_systime right?
But how will this check if 30 days passed?
Pewdiepie is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 10-27-2012 , 20:02   Re: Remove after specific time
Reply With Quote #28

Quote:
Originally Posted by Pewdiepie View Post
So what will this actually check?

PHP Code:
if (Timestamp[id] + 2592000 <= get_systime())
        {
            
client_print(idprint_chat"Your purchase has been removed!")
        } 
It will check if the current date + 2592000 = lower or equal to get_systime right?
But how will this check if 30 days passed?
If you save Timestamp[ id ] and loads it when a client connect to your server you can check it like you show.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-27-2012 , 20:02   Re: Remove after specific time
Reply With Quote #29

Quote:
Originally Posted by Pewdiepie View Post
So what will this actually check?
Exactly what you think it will. The only problem is that unless your map never changes, your server never restarts, and the client never disconnects, your example will always return false.


Quote:
It will check if the current date + 2592000 = lower or equal to get_systime right?
It will take your saved date, add 30 days to it and then compare it to the current date.
__________________
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:04   Re: Remove after specific time
Reply With Quote #30

Quote:
Originally Posted by YamiKaitou View Post
Exactly what you think it will. The only problem is that unless your map never changes, your server never restarts, and the client never disconnects, your example will always return false.



It will take your saved date, add 30 days to it and then compare it to the current date.
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?
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 11:49.


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