08.03.2013, 19:48
How to do command that player can use the command only 3 times in day?
new used[MAX_PLAYERS] = 0;
YCMD:test(playerid, params[], help)
{
#pragma unused params, help//we're just making a test command, we don't need those
if(used[playerid] > 3)//we check if the variable's value is bigger then 3
{
SendClientMessage(playerid, 0xFF0000FF, "You've used this command three times!");
}
else
{
//do your code
used[playerid]++;//we will set the variable's value bigger with on number
}
return 1;
}
pawn Код:
pawn Код:
|
forward Shittimer();
public Shittimer()
{
if(strfind("/shit", "/shit", true))
{
SendClientMessageToAll(0xFFFF00AA,"3 timesa day dude!");
return 0;
}
return 1;
}
public OnPlayerText(playerid, text[])
{
if(strfind(text, "/shit", true) > 3)
{
SendClientMessage(playerid, -3, "3 times a day dude!");
SetTimer("Shittimer",86400000,0);
return 0;
}
return 1;
}
CMD:shit(playerid, params[])
{
SetPlayerHealth(playerid, 100);
return 1;
}
pawn Код:
|