#include <a_samp>
#include <zcmd>
#include <sscanf2>
main() {
}
public OnGameModeInit() {
return 1;
}
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;
}
CMD:infernus(playerid, params[]) {
if(!IsPlayerAdmin(playerid) && GetPVarInt(playerid, "vipTime") == 0) // Example VIP command
return SendClientMessage(playerid, 0, "Only VIPs and admins can spawn infernuses!");
new
Float: fVehPos[3];
GetPlayerPos(playerid, fVehPos[0], fVehPos[1], fVehPos[2]);
PutPlayerInVehicle(playerid, CreateVehicle(411, fVehPos[0], fVehPos[1], fVehPos[2], 2, -1, -1, 2000), 0);
return 1;
}