VIP on time -
RonnyCZ - 02.11.2014
Hello I would like to ask the VIP on the number of days for example.
/setvip ID 30 Days VIP expire in 30 days
![Smiley](images/smilies/smile.png)
Thanks
Re: VIP on time -
Dziugsas - 02.11.2014
What i can say is just - you need to use sscanf and timestamps.
Re: VIP on time -
HY - 02.11.2014
pawn Код:
CMD:setvip(playerid,params[])
{
if(IsPlayerAdmin(playerid))
{
new ID;
new LVL;
new Days = 30;
if(sscanf(params,"iii", ID, LVL, Days)) return SendClientMessage(playerid,-1,"{FF0000}USAGE: {15FF00}/GiveVip [ID] [Vip Level] [30 Days]");
PlayerInfo[playerid][Vip] = LVL;
SetTimer("NoVip", 2628000000, false);
}
else
{
SendClientMessage(playerid, -1, "{FF0000}ERROR: {15FF00}You are not authorized to use this command, or the Days are Invalid !");
}
return 1;
}
forward NoVip();
public NoVip()
{
new playerid;
PlayerInfo[playerid][Vip] = 0;
SendClientMessage(playerid, -1, "{FF0000}[INFO]: {15FF00}Your temporally Vip System has been finished !");
}
- I made this System in 5 minutes. Don't copy and paste, please adjust it with your Enums.
- I converted 1 month in miliseconds, and after 1 month, he won't have VIP !
- Anyway, my enums :
pawn Код:
enum pInfo
{
Vip,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
// EDIT: Look now at the code. I just made a little mistake wich will cause to you errors. I solved .
Re: VIP on time -
RonnyCZ - 02.11.2014
I prepared it just me missing those days there Thank you
Re: VIP on time -
Abagail - 02.11.2014
That won't work. Most people won't have their server running constantly for a whole month without a restart, and chances are the player won't even be connected/online by the time the timer ends.
I'd recommend keeping the expire date/time in a variable, and when they login check if the time has passed or not.
Re: VIP on time -
Dziugsas - 02.11.2014
Quote:
Originally Posted by Abagail
That won't work. Most people won't have their server running constantly for a whole month without a restart, and chances are the player won't even be connected/online by the time the timer ends.
I'd recommend keeping the expire date/time in a variable, and when they login check if the time has passed or not.
|
True , thats why i said use timestamps.
Re: VIP on time -
Abagail - 02.11.2014
Another error I've noticed, you don't even use player ID's properly, nonetheless would that code even work. @HY
Re: VIP on time -
dominik523 - 02.11.2014
Quote:
Originally Posted by HY
pawn Код:
CMD:setvip(playerid,params[]) { if(IsPlayerAdmin(playerid)) { new ID; new LVL; new Days = 30; if(sscanf(params,"iii", ID, LVL, Days)) return SendClientMessage(playerid,-1,"{FF0000}USAGE: {15FF00}/GiveVip [ID] [Vip Level] [30 Days]"); PlayerInfo[playerid][Vip] = LVL; SetTimer("NoVip", 2628000000, false); } else { SendClientMessage(playerid, -1, "{FF0000}ERROR: {15FF00}You are not authorized to use this command, or the Days are Invalid !"); } return 1; }
forward NoVip();
public NoVip() { new playerid; PlayerInfo[playerid][Vip] = 0; SendClientMessage(playerid, -1, "{FF0000}[INFO]: {15FF00}Your temporally Vip System has been finished !"); }
- I made this System in 5 minutes. Don't copy and paste, please adjust it with your Enums.
- I converted 1 month in miliseconds, and after 1 month, he won't have VIP !
- Anyway, my enums :
pawn Код:
enum pInfo { Vip, }
new PlayerInfo[MAX_PLAYERS][pInfo];
// EDIT: Look now at the code. I just made a little mistake wich will cause to you errors. I solved .
|
You made completely wrong system in 5 minutes. First of all, creating timers which have intervals in days is nonsense. What if you restart the server? Timers are killed and player's VIP time is lost.
Ronny, to make a command that you want, you will have to use unix timestamps. It looks something like this:
pawn Код:
// PlayerData[playerid][pVip] is used to store VIP time, you may set this to anything you like
CMD:makevip(playerid, parasm[])
{
new days;
if(sscanf(params, "d", days)) return SendClientMessage(playerid, -1, "Usage: /makevip [days]");
PlayerData[playerid][pVip] = gettime() + days * 86400; // you are adding number of days in seconds to the current time
return 1;
}
Re: VIP on time -
Runn3R - 02.11.2014
Save the date that you need. When a player connects to the server on the date it shows him the message Your VIP has expired.
And you sir have failed big time lmao a timer for a month..
Re: VIP on time -
[HiC]TheKiller - 02.11.2014
I would say that the easiest way is to just timestamp it with gettime then either
A: Have a timer every once in a while that checks everyones timestamps against their current ones.
B: Use OnPlayerConnect (but they wouldn't lose their VIP until they relogged).