Help . - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help . (
/showthread.php?tid=634353)
Help . -
ongnung147 - 17.05.2017
I WANT DO SET VIP TIME IS 30DAYS , BUT ME DON'T KNOW TIME.
i use .ini
Code:
Код:
CMD:setvip(playerid,params[])
{
if(pInfo[playerid][pAdminLevel] >= 5)
{
new targetid,level,string[256],months;
if(sscanf(params, "ud", targetid, level,months))
{
SendClientMessage(playerid,-1,"USAGE: /setvip [player] [level] [months]");
SendClientMessage(playerid,-1,"Available Levels: |1| Bronze |2| Silver |3| Gold ");
return 1;
}
format(string, sizeof(string), "%s %s da cho vip %s.",GetAdminName(playerid),PlayerName(playerid),PlayerName(targetid));
SendClientMessageToAll(-1,string);
}
else {
SendClientMessage(playerid,COLOR_RED,"{FF0000}Ban khong phai admin.!");
}
return 1;
}
Re: Help . -
zedshadowzw - 18.05.2017
It is really simple,
All you do is a command, I see nothing wrong with the codes
/setvip [playerid] [viplevel] 1 <----- 1 = 30 days
Re: Help . -
ongnung147 - 18.05.2017
time vip can't end . and save.
Re: Help . -
DobbysGamertag - 18.05.2017
Use
timestamps .
Also, please fix the string length on that format();. There's no way a client message is going to be above 144!
Re: Help . -
RxErT - 18.05.2017
Try this:
PHP код:
stock GetCharacterStuff(szName[], szItem[]) {
new
szItem2[64 + MAX_PLAYER_NAME];
format(szItem2, sizeof(szItem2), "Crumpets, %s and %s", szName, szItem);
return strval(szItem2);
}
public OnPlayerConnect(playerid) {
new
szName[MAX_PLAYER_NAME];
GetPlayerName(playerid, szName, MAX_PLAYER_NAME);
// I'm using a pseudo-function here as an example of loading a player variable from a file. This function probably hasn't ever been created and it won't work - it's just an example!
SetPVarInt(playerid, "vipTime", GetCharacterStuff(szName, "vipTime"));
if(gettime() > GetPVarInt(playerid, "vipTime")) {
// Their VIP expired.
SendClientMessage(playerid, 0, "Your VIP subscription has expired. You're now a commoner!");
DeletePVar(playerid, "vipTime"); // Because we won't need it again.
// They aren't a VIP. We'll say that if 'vipTime' is 0 they're not a VIP, that's okay.
}
return 1;
}
CMD:givevip(playerid, params[]) {
new
iPerson,
iDays;
if(!IsPlayerAdmin(playerid)) // Just for the sake of it.
return SendClientMessage(playerid, 0, "Only admins can make players VIP!");
if(sscanf(params, "ui", iPerson, iDays)) // We'll use sscanf with our zcmd command for this.
return SendClientMessage(playerid, 0, "Usage: /givevip [playerid/name] [days]");
// 'iPerson' contains the playerid of the person who should be getting VIP, let's confirm they're connected
if(iPerson == INVALID_PLAYER_ID) // sscanf returns 'INVALID_PLAYER_ID' if nobody is online with an ID or name similar or matching what you entered
return SendClientMessage(playerid, 0, "The person you're trying to give VIP isn't online.");
// 'iDays' contains the amount of days we should be giving the person VIP for.
if(iDays > 365) // We'll set a limit so a person can't have longer than a year's worth of VIP for the sake of it too.
return SendClientMessage(playerid, 0, "You can't give a player VIP for longer than a year. A year consists of 365 days (if it's not a leap year).");
// There are 86400 seconds in a day. We'll do some simple math here, multiple the amount of days by 86400 seconds, because Unix timestamps are essentially seconds
// ...we're going to be needing to work with seconds. So, here we go. We'll set it to that players' VIP time so they get VIP now too.
SetPVarInt(iPerson, "vipTime", gettime()+(iDays*86400));
return 1;
}
Re: Help . -
PhamHoang - 18.05.2017
PlayerInfo[playerid][pVipDate]+=gettime()+(30*86400);