new VIP[MAX_PLAYERS];
CMD:makevip(playerid, arg[]) { new tdd, tmm, tyy, dd, mm, yy, id, str[128], name[32], pname[32]; if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You are not authorized to use this command."); if(sscanf(arg, "uiii", id, dd, mm, yy)) return SendClientMessage(playerid, COLOR_WHITE, "/makevip [playerid] [day of expiry] [month of expiry] [year of expiry]"); getdate(tyy, tmm, tdd); makePlayerVip(id, dd, mm, yy); GetPlayerName(playerid, name, 32); GetPlayerName(playerid, pname, 32); format(str, 128, "%s has made you VIP until %d/%d/%d", name, dd, mm, yy); SendClientMessage(id, COLOR_WHITE, str); format(str, 128, "You have made %s VIP until %d/%d/%d", pname, dd, mm, yy); SendClientMessage(playerid, COLOR_WHITE, str); return 1; }
stock makePlayerVip(playerid, dd, mm, yy) { new fil[64], File:file, name[32], str[256]; GetPlayerName(playerid, name, 32); format(fil, 64, "%s.ini", name); if(fexist(fil)) fremove(fil); file = fopen(fil, io_write); format(str, 256, "%d|%d|%d", dd, mm, yy); VIP[playerid] = 1; fwrite(file, str); fclose(file); }
public OnPlayerConnect(playerid) { checkPlayerVip(playerid); return 1; }
stock checkPlayerVip(playerid) { new dd, mm, yy, fil[64], File:file, str[256], name[32], arr[4][32], f=0; getdate(yy, mm, dd); GetPlayerName(playerid, name, 32); format(fil, 64, "%s.ini", name); if(VIP[playerid] && !fexist(fil)) VIP[playerid] = 0; if(fexist(fil)) { file = fopen(fil, io_read); fread(file, str); fclose(file); split(str, arr, '|'); if(dd > strval(arr[0]) && mm >= strval(arr[1]) && yy >= strval(arr[2])) { SendClientMessage(playerid, COLOR_WHITE, "Your VIP has been automatically expired."); removePlayerVip(playerid); f=1; } if(!f) VIP[playerid] = 1; } }
stock removePlayerVip(playerid) { new fil[64], name[32]; GetPlayerName(playerid, name, 32); format(fil, 64, "%s.ini", name); if(fexist(fil)) fremove(fil); VIP[playerid] = 0; }
stock split(const strsrc[], strdest[][], delimiter) { new i, li; new aNum; new len; while(i <= strlen(strsrc)) { if(strsrc[i] == delimiter || i == strlen(strsrc)) { len = strmid(strdest[aNum], strsrc, li, i, 128); strdest[aNum][len] = 0; li = i+1; aNum++; } i++; } return 1; }
#include <a_samp> #include <zcmd> #include <sscanf> #define COLOR_WHITE 0xFFFFFFFF new VIP[MAX_PLAYERS]; public OnPlayerConnect(playerid) { checkPlayerVip(playerid); return 1; } public OnPlayerSpawn(playerid) { SendClientMessage(playerid, COLOR_WHITE, "You are logged in as a VIP."); return 1; } CMD:makevip(playerid, arg[]) { new tdd, tmm, tyy, dd, mm, yy, id, str[128], name[32], pname[32]; if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You are not authorized to use this command."); if(sscanf(arg, "uiii", id, dd, mm, yy)) return SendClientMessage(playerid, COLOR_WHITE, "/makevip [playerid] [day of expiry] [month of expiry] [year of expiry]"); getdate(tyy, tmm, tdd); makePlayerVip(id, dd, mm, yy); GetPlayerName(playerid, name, 32); GetPlayerName(playerid, pname, 32); format(str, 128, "%s has made you VIP until %d/%d/%d", name, dd, mm, yy); SendClientMessage(id, COLOR_WHITE, str); format(str, 128, "You have made %s VIP until %d/%d/%d", pname, dd, mm, yy); SendClientMessage(playerid, COLOR_WHITE, str); return 1; } stock makePlayerVip(playerid, dd, mm, yy) { new fil[64], File:file, name[32], str[256]; GetPlayerName(playerid, name, 32); format(fil, 64, "%s.ini", name); if(fexist(fil)) fremove(fil); file = fopen(fil, io_write); format(str, 256, "%d|%d|%d", dd, mm, yy); VIP[playerid] = 1; fwrite(file, str); fclose(file); } stock removePlayerVip(playerid) { new fil[64], name[32]; GetPlayerName(playerid, name, 32); format(fil, 64, "%s.ini", name); if(fexist(fil)) fremove(fil); VIP[playerid] = 0; } stock checkPlayerVip(playerid) { new dd, mm, yy, fil[64], File:file, str[256], name[32], arr[4][32], f=0; getdate(yy, mm, dd); GetPlayerName(playerid, name, 32); format(fil, 64, "%s.ini", name); if(VIP[playerid] && !fexist(fil)) VIP[playerid] = 0; if(fexist(fil)) { file = fopen(fil, io_read); fread(file, str); fclose(file); split(str, arr, '|'); if(dd > strval(arr[0]) && mm >= strval(arr[1]) && yy >= strval(arr[2])) { SendClientMessage(playerid, COLOR_WHITE, "Your VIP has been automatically expired."); removePlayerVip(playerid); f=1; } if(!f) VIP[playerid] = 1; } } stock split(const strsrc[], strdest[][], delimiter) { new i, li; new aNum; new len; while(i <= strlen(strsrc)) { if(strsrc[i] == delimiter || i == strlen(strsrc)) { len = strmid(strdest[aNum], strsrc, li, i, 128); strdest[aNum][len] = 0; li = i+1; aNum++; } i++; } return 1; }
i want this cmd like this /freevip when everyone login than he will type /freevip and than he will get 1 month vip after 1 month it will expire if u help me in it than thankyou i will give you repution i already have /makevip cmd
help me in this topic https://sampforum.blast.hk/showthread.php?tid=597329 |
CMD:setvip(playerid,params[]) {
new sPlayer,Time;
if(sscanf(params,"ui",sPlayer,Time)) return Msg(playerid,COLOR_RED,"Usage: /setvip [playerid] [days]");
if(Time <= 0) return Msg(playerid,COLOR_RED,"Time cannot be equal to 0 or go bellow it");
if(sPlayer == INVALID_PLAYER_ID) return Msg(playerid,COLOR_RED,"Invalid player");
new finalcalc = (Time*3600)+gettime(); /* 3600 seconds per day + currenttime, it will give us until when they have to be VIP*/
PlayerInfo[playerid][VIPTime] = finalcalc; //store the variable
PlayerInfo[playerid][VIPLevel] = 1; //optional, set player VIP level or something
return true;
}
public OnPlayerConnect(playerid) {
//load the PlayerInfo[playerid][VIPTime]
new currentTime = gettime();
if(currentTime >= PlayerInfo[playerid][VIPTime]) { //if current time is bigger than the time they should be VIP for.
Msg(playerid,COLOR_RED,"Your VIP has expired. Please consider purchasing more");
PlayerInfo[playerid][VIPLevel] = 0;
}
return true;
}