/heal once
#1

Hi, how can i make /heal only work one time in one player life.

So when u die and respawn again you can use it only one time again.

Thanks.
Reply
#2

Use a global variable:
pawn Код:
new Available[MAX_PLAYERS]; // 0 if it is and 1 if it is not available
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmdtext, "/heal", true) == 0)
  {
    if(Available[playerid] == 0) // we check if the commad is available
    {
      // this is the command effect (if the command is available)
      Available[playerid] = 1; // this is one of the most important lines (we set the command unavailable)
    }
    else
    {
      SendClientMessage(playerid, COLOR, "You'll have to wait to use this command"); // this is what happen if it is not available
    }
    return 1;
  }
  return 0;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
  Available[playerid] = 0; // we reset the variable, setting it back to available or "0"
  return 1;
}
Reply
#3

Thanks Bud
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)