SA-MP Forums Archive
Help with /heal command - 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: Help with /heal command (/showthread.php?tid=200766)



Help with /heal command - [JnA]DukeNukem - 19.12.2010

Can you help me with my /heal cmd?
Код:
dcmd_heal(playerid, params[])
{
	if (strlen(params))
	{
		id = strval(params[0]);
		if (IsPlayerConnected(id))
		{
			if(Medic[playerid] == 1 || IsPlayerInVehicle(playerid, 416))
			{
				SetPlayerHealth(id,100);
				new pName[24];
				new string[265];
				GetPlayerName(playerid,"pName",sizeof(pName));
				format(string,sizeof(string),"MEDIC:You got healed by Medic %s",pName);
				SendClientMessage(id,0x00FF00AA,string);
			}
			else
			{
				SendClientMessage(playerid,0x00FF00AA,"SERVER:You dont have permission to this command!,or yo're ont in an Ambulance!");
			}
		}
		else
		{
			SendClientMessage(playerid, 0xFF0000AA, "Player not found");
		}
	}
	else
	{
		SendClientMessage(playerid, 0xFF0000AA, "SERVER:Usage /heal [ID]");
	}
	return 1;
I wan't it to do this, when e.x a player has 10hp and another player heals he gets 90 = equal to the hp he healed


Re: Help with /heal command - Elorreli - 19.12.2010

pawn Код:
new Float:health, Float:h = 100 - health;
GetPlayerHealth(id,health);

SetPlayerHealth(id, health+h);



Re: Help with /heal command - [JnA]DukeNukem - 19.12.2010

Thanks


Re: Help with /heal command - Elorreli - 19.12.2010

pawn Код:
if(Medic[playerid] == 1 || IsPlayerInVehicle(playerid, 416))
{
    SetPlayerHealth(id,100);
    new pName[24];
    new string[265];
    GetPlayerName(playerid,"pName",sizeof(pName));
    format(string,sizeof(string),"MEDIC:You got healed by Medic %s",pName);
    new Float:health, Float:h = 100 - health;
    GetPlayerHealth(id,health);
    SetPlayerHealth(id, health+h);
    SendClientMessage(id,0x00FF00AA,string);
}
The size of your string is also very unnecessary, like using a hangar for an RC plane.


Re: Help with /heal command - Mean - 19.12.2010

lower your string to
pawn Код:
new string[128];
128 cells is more than enough


Re: Help with /heal command - [JnA]DukeNukem - 19.12.2010

ugh 1 more thing, i didn't spell it right... i wan't the healer to get 90$ if he heals 90hp


Re: Help with /heal command - Mean - 19.12.2010

Put this below your "MEDIC:You got healed by Medic %s" message:

pawn Код:
GivePlayerMoney(playerid, 90);
You need to change the whole code if you want the ammount healer healed, just make it single ammount, like you get 100 dollars and 1 score for healing a player


Re: Help with /heal command - [JnA]DukeNukem - 19.12.2010

ok brate, ali ja ocu ovako al nema veze hvala u svakom slucaju


Re: Help with /heal command - Mean - 19.12.2010

Ok. Talk in english, because you are not allowed to talk other languages here, even tho I do understand you.


Re: Help with /heal command - [JnA]DukeNukem - 19.12.2010

Ai Ai captain