Use command only after 15 mins? -
MiGu3X - 03.05.2013
Here s my command ( /vskin <skinid> that will change player skin according its vip level )
I dont want people to abuse this command (use it only after 15 mins)
pawn Код:
CMD:vskin(playerid, params[])
{
if(PlayerInfo[playerid][pVip] >= 1)
{
new skinid, string[128];
if(sscanf(params, "i", skinid))
return SendClientMessage(playerid, DEEPPINK, "USAGE: /vskin <id>");
if(skinid < 0 || skinid > 299)
return SendClientMessage(playerid, DEEPPINK, "ERROR: Available skins from 0 to 299");
if(skinid == GetPlayerSkin(playerid))
return SendClientMessage(playerid, DEEPPINK, "ERROR: You are already using this skin");
{
SetPlayerSkin(playerid, skinid);
format(string, sizeof(string), "[VIP SKINS] You just set your skin to %i", skinid);
SendClientMessage(playerid, GREEN, string);
}
}
else return SendClientMessage(playerid, DEEPPINK, "ERROR: You must be vip level 1 to use this command!");
return 1;
}
Re: Use command only after 15 mins? -
RevolutionaryGaming - 03.05.2013
You'll want to use a timer set to 15 minutes.
https://sampwiki.blast.hk/wiki/SetTimer
Respuesta: Use command only after 15 mins? -
MiGu3X - 03.05.2013
How do i add it please help
Re: Use command only after 15 mins? -
RevolutionaryGaming - 03.05.2013
I would recommend adding a new bool which is PlayerCanChangeSkin. Set this to true by default. When the player uses the command /vskin, change this value to false and start a 15 minute timer. When that timer hits zero, set this bool to true. This is the concept behind it.
Re: Use command only after 15 mins? -
RajatPawar - 03.05.2013
This may help you, if you read it very carefully.
Re: Use command only after 15 mins? -
Pottus - 03.05.2013
Don't use a timer that is a donkey way to do it consider this....
pawn Код:
#define CommandDelay 900000
new CommandUseTime[MAX_PLAYERS];
CMD:mycommand(playerid, arg[])
{
if(GetTickCount() - CommandUseTime[playerid] > CommandDelay)
{
CommandUseTime[playerid] = GetTickCount();
}
return 1;
}
Make sure you zero it in OnPlayerDisconnect()
CommandUseTime[playerid] = 0;
You can also save it to file if you want to restore it later....
Save.... GetTickCount() - CommandUseTime[playerid]
To restore the time use this
CommandUseTime[playerid] = GetTickCount() - SavedTime;
Whatever you do don't use a timer that is a silly suggestion.
@Rajat_Pawar - We think a like
Respuesta: Use command only after 15 mins? -
MiGu3X - 03.05.2013
thanks guys
Re: Use command only after 15 mins? -
MiGu3X - 06.05.2013
Can simeone put how the cmd will be plrase??
Re: Use command only after 15 mins? -
[KHK]Khalid - 06.05.2013
This is the final code, use it only if you understand what they said. If you don't, then go read it again carefully or question.
pawn Код:
// Top of your script
new LastVSkinUse_Tick[MAX_PLAYERS];
// Command
CMD:vskin(playerid, params[])
{
if(PlayerInfo[playerid][pVip] >= 1)
{
new skinid, string[128];
if(sscanf(params, "i", skinid))
return SendClientMessage(playerid, DEEPPINK, "USAGE: /vskin <id>");
if(skinid < 0 || skinid > 299)
return SendClientMessage(playerid, DEEPPINK, "ERROR: Available skins from 0 to 299");
if(skinid == GetPlayerSkin(playerid))
return SendClientMessage(playerid, DEEPPINK, "ERROR: You are already using this skin");
new CurTick = GetTickCount();
if((CurTick - LastVSkinUse_Tick[playerid]) < 900000)
return SendClientMessage(playerid, DEEPPINK, "ERROR: You have to wait 15 minutes before using this again");
{
SetPlayerSkin(playerid, skinid);
format(string, sizeof(string), "[VIP SKINS] You just set your skin to %i", skinid);
SendClientMessage(playerid, GREEN, string);
LastVSkinUse_Tick[playerid] = CurTick;
}
}
else return SendClientMessage(playerid, DEEPPINK, "ERROR: You must be vip level 1 to use this command!");
return 1;
}
Re: Use command only after 15 mins? -
RajatPawar - 06.05.2013
This is okay. But I would suggest actually, using gettime() instead of GetTickCount. Just replace all GetTickCounts with gettime, because after 24 days, GetTickCount over runs the maximum integer available.