SA-MP Forums Archive
CheckPlayerHealt? - 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: CheckPlayerHealt? (/showthread.php?tid=128590)



CheckPlayerHealt? - cruising - 18.02.2010

Hello!

With this cmd you can heal players if you both are in a ambulance, you can do it over and over again even if the players health is 100.
So how can i do a player health check so you cant abuse the cmd?
i guess the check would look something like this?
Код:
CheckplayerHealth(playerid, 100);
     SetPlayerHealth(giveplayerid, 100);

Код:
	if(strcmp(cmd, "/Heal", true) == 0)
	{
	  if(Medic(playerid))
	  {
	    new tmpcar = GetPlayerVehicleID(playerid);
	    if(MedicCar(tmpcar))
	    {
	    	tmp = strtok(cmdtext, idx);
	    	if(!strlen(tmp))
	    	{
	      	SCM(playerid, COLOR_WHITE, "USAGE: /Heal <Player ID>");
	      	return 1;
				}
				new giveplayerid = ReturnUser(tmp);
				if(giveplayerid == playerid)
				{
				  SCM(playerid, COLOR_RED, "MAIN ERROR(You can't heal yourself!)");
				  return 1;
				}
				if(IsPlayerConnected(giveplayerid))
				{
			  	if(tmpcar == GetPlayerVehicleID(giveplayerid))
					{
					  GetPlayerName(playerid, UserName, sizeof(UserName));
					  GetPlayerName(giveplayerid, UserName2, sizeof(UserName2));
					  SetPlayerHealth(giveplayerid, 100);
					  format(Text, sizeof(Text), "** You got healed by medic %s! **", UserName);
					  SCM(giveplayerid, COLOR_GREEN, Text);
					  format(Text, sizeof(Text), "** You healed %s and earned $750! **", UserName2);
					  SCM(playerid, COLOR_GREEN, Text);
					  GivePlayerMoney(playerid, 750);
					}
					else{SCM(playerid, COLOR_RED, "MAIN ERROR(That person isn't in you'r ambulance!)");}
				}
				else{SCM(playerid, COLOR_RED, "MAIN ERROR(That player is offline!)");}
			}
			else{SCM(playerid, COLOR_RED, "MAIN ERROR(You are not in an ambulance!)");}
		}
		else{SCM(playerid, COLOR_RED, "MAIN ERROR(You are not a medic)");}
		return 1;
	}



Re: CheckPlayerHealt? - Cry_Wolf - 18.02.2010

GetPlayerHealth?


Re: CheckPlayerHealt? - chosen - 18.02.2010

pawn Код:
new Float:health;
GetPlayerHealth(giveplayerid,health);
if(health >= 100.0)
{
    SendClientMessage(playerid, COLOR_GREY,"That person is fully healed.");
    return 1;
}
Something like this? Or what?


Re: CheckPlayerHealt? - cruising - 18.02.2010

Quote:
Originally Posted by chosen
pawn Код:
new Float:health;
GetPlayerHealth(giveplayerid,health);
if(health >= 100.0)
{
    SendClientMessage(playerid, COLOR_GREY,"That person is fully healed.");
    return 1;
}
Something like this? Or what?
yes something like that. if the player in the ambulance have fully health the medic get that message and do not get any money and does not heal him.
but i dont know in witch line to put it to work


Re: CheckPlayerHealt? - chosen - 18.02.2010

Put it above this line
pawn Код:
SetPlayerHealth(giveplayerid, 100);



Re: CheckPlayerHealt? - cruising - 18.02.2010

Quote:
Originally Posted by chosen
Put it above this line
pawn Код:
SetPlayerHealth(giveplayerid, 100);
Yes that was what i did..just have to wait for my friend to logg on to test it