Simple question
#1

Hello how need let for player just heal him one time per round?
Код:
if (pInfo[playerid][pCoins] < 1){SendClientMessage(playerid, 0xFF0000AA, "* You dont have that!"); return 1;}
new Float:pHealth; new id;
GetPlayerHealth(id, pHealth);
if(pHealth >= 90) return SendClientMessage(playerid, 0xFF22EE00, "You have ounght HP");
SendClientMessage(playerid,0xFF000090,"* You got HP -1 Coins ");
pInfo[playerid][pCoins]-=1;
SetPlayerHealth(playerid,100);
SendClientMessage(playerid, 0xFFFF00FF, "You healed");
Reply
#2

make a variable e.g.new bool: roundHeal[MAX_PLAYERS];
on round start set roundHeal[playerid] = true;
when player heals make roundHeal[playerid] = false;
on round ends make roundHeal[playerid] = false;
Reply
#3

Ok i made this, bat i can still make this command how much time i wont -.- its doesnt work. I need just do one time per round.
Reply
#4

Make an another var? Like:
new bool:roundHealed[MAX_PLAYERS] = false;

When a player heal him self, set the var on true.
Make a condition like : if(roundHealed[playerid] == true) return ANERROMESSAGE;

I'm probably wrong but I hope you get the idea. Good luck.
Reply
#5

Quote:
Originally Posted by henkas
Посмотреть сообщение
Ok i made this, bat i can still make this command how much time i wont -.- its doesnt work. I need just do one time per round.
The code provided is set to do that. Example /heal command:


Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/heal", true))
    {
        if(roundHeal[playerid] == true) return SendClientMessage(playerid,color,"You have already healed this round. Please wait for the next round to use 'heal' again");
        else
        { 
              SetPlayerHealth(playerid,100.0);
              roundHeal[playerid] = true;
        }
    }
    return 0;
    // Returning 0 informs the server that the command hasn't been processed by this script.
    // OnPlayerCommandText will be called in other scripts until one returns 1.
    // If no scripts return 1, the 'SERVER: Unknown Command' message will be shown to the player.
}

When the round ends, use a loop to set everyone back to being able to heal. I prefer foreach

Код:
foreach(Player,i)
{
     roundHeal[i] == false;
}
Reply
#6

Thank for kaisersouse everything work perfect just needed to change if(roundHeal[playerid] == true) to if(roundHeal[playerid] == false) and now everything work perfect thanks a lot
Reply
#7

Quote:
Originally Posted by henkas
Посмотреть сообщение
Thank for kaisersouse everything work perfect just needed to change if(roundHeal[playerid] == true) to if(roundHeal[playerid] == false) and now everything work perfect thanks a lot
My mistake, I was interpreting roundHeal as in "has the player healed", not "can the player heal" haha. Glad its working
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)