SA-MP Forums Archive
Set somebody elses health? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Set somebody elses health? (/showthread.php?tid=83160)



Set somebody elses health? - Abernethy - 23.06.2009

How do I set somebody elses health, SetPlayerHealth(playerid, giverid, 100); ? Meh, I have no idea.

Instead of making a new thread, it's simpler to edit.


Re: GetPlayerTeam on spawn .. ? - Grim_ - 23.06.2009

GetPlayerTeam sometimes returns the incorrect value.
You should create a variable, and OnPlayerRequest class, if classid == gTeam[playerid] = RUSSIA, or w/e.
Then use it to check in OnPlayerSpawn
pawn Код:
if(gTeam[playerid] == RUSSIA) { //code here }



Re: GetPlayerTeam on spawn .. ? - Abernethy - 23.06.2009

The menu displays what they want to be, eg. Russia gets a menu for like, Infantry, Medic etc ... I also have other shit how would I do more than a single line?

EDIT: Works, thanks mate.


Re: GetPlayerTeam on spawn .. ? - Grim_ - 23.06.2009

Add more things to the menu? or what?
Please explain more.


Re: Set somebody elses health? - Abernethy - 23.06.2009

Bump, new question!


Re: Set somebody elses health? - Grim_ - 23.06.2009

pawn Код:
SetPlayerHealth(playerid, Float:health);



Re: Set somebody elses health? - Abernethy - 23.06.2009

Doesn't help, sorry to say. I know how to set your own health, my script includes Medics that SHOULD be able to /heal [playerid] .. thats the question I'm asking.


Re: Set somebody elses health? - Grim_ - 23.06.2009

pawn Код:
new cmd[256], tmp[256], idx;
if(strcmp(cmd, "/heal", true) == 0)
{
  if(IsPlayerMedic(playerid)) //check
  {
   tmp = strtok(cmdtext, idx);
   if(!strlen(tmp)) return SendClientMessage(playerid, color, "Usage: /heal <id>");  
   new pid = strval(tmp);
   if(IsPlayerConnected(pid))
   {
     if(GetPlayerHealth(pid < 100)
     {
      SetPlayerHealth(pid, 100);
      return 1;
     }
     else return SendClientMessage(playerid, color, "Player health is full!");
   }
   else return SendClientMessage(playerid, color, "Invalid ID");
  }
  else return SendClientMessage(playerid, color, "Must be a medic!");
}



Re: Set somebody elses health? - borisblat - 23.06.2009

well if you don't have medic script on your server do like this:

new cmd[256], tmp[256], idx;
if(strcmp(cmd, "/heal", true) == 0)
{
tmp = strtok(cmdtext, idx);
new otherplayer = strval(tmp);
if (!IsPlayerConnected(otherplayer)) return SendClientMessage(playerid, COLOR_WHITE, "Player isn't connected.");
if (otherplayer == playerid) return SendClientMessage(playerid, COLOR_WHITE, "You can't heal your self");
SetPlayerHealth(otherplayer, 100);
SendClientMessage(playerid, COLOR_WHITE, "You have filled the health");
return 1;

}


Re: Set somebody elses health? - Grim_ - 23.06.2009

He does, that's why I specifically made it that way