SA-MP Forums Archive
Simple question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Simple question (/showthread.php?tid=606350)



Simple question - henkas - 03.05.2016

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");



Re: Simple question - thaKing - 03.05.2016

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;


Re: Simple question - henkas - 03.05.2016

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.


Re: Simple question - Dayrion - 03.05.2016

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.


Re: Simple question - kaisersouse - 03.05.2016

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;
}



Re: Simple question - henkas - 03.05.2016

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


Re: Simple question - kaisersouse - 03.05.2016

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