SA-MP Forums Archive
A /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)
+--- Thread: A /heal command. (/showthread.php?tid=393013)



A /heal command. - Sting. - 16.11.2012

I was wondering whether any of you guys could give me a medic code that is easy to use, like if the player IsInRangeOfPoint. To heal the player and the medic gets some cash in return and the injured guy gets money reduced. How? +Rep!


Re: A /heal command. - Lean - 16.11.2012

You Need it As PickUp ?


Re: A /heal command. - Konstantinos - 16.11.2012

Do you mean like a function?
pawn Код:
stock HealPlayer( playerid )
{
    SetPlayerHealth( playerid, 100.0 );
    GivePlayerMoney( playerid, -3000 );
    return 1;
}
pawn Код:
CMD:heal( playerid, params[ ] )
{
    HealPlayer( playerid );
    return 1;
}



Re: A /heal command. - Lean - 16.11.2012

pawn Код:
CMD:heal( playerid, params[ ] )
{
     SetPlayerHealth(playerid, 100.0);
     GivePlayerMoney(playerid, -500);
     return 1;
}



Re: A /heal command. - Abreezy - 16.11.2012

pawn Код:
CMD:heal(playerid, params[])
{
    new pID;
    if(sscanf(params, "u", pID)) return SendClientMessage(playerid, -1, "Usage: /heal playerid");
    if(IsPlayerInRangeOfPlayer(playerid, pID, 5))
    {
        if(playerid != pID)
        {
            SetPlayerHealth(pID, 100);
            GivePlayerMoney(playerid, 150);
            GivePlayerMoney(pID, -150);
            SendClientMessage(pID, -1, "You have been healed.");
            SendClientMessage(playerid, -1, "You have healed the player.");
        }
        else
        {
            SendClientMessage(playerid, -1, "You can't heal yourself.");
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "You aren't close enough to the player.");
    }
    return 1;
}
Theres the command, heres the function:

pawn Код:
stock IsPlayerInRangeOfPlayer(playerid, targetid, distance)
{
    new
        Float:X, Float:Y, Float:Z, Float:tX, Float:tY, Float:tZ;
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerPos(targetid, tX, tY, tZ);
    if(IsPlayerInRangeOfPoint(playerid, distance, tX, tY, tZ)) return 1;
    return 0;
}



Re: A /heal command. - Anthony © - 16.11.2012

Код:
CMD:heal(playerid, params[])
{
	new pID, money, Float:x, Float:y, Float:z, name[MAX_PLAYER_NAME], string[86];
	GetPlayerName(playerid, name, sizeof(name));
	{
		if(sscanf(params, "ui", pID, money)) return SendClientMessage(playerid, 0x83827AFF, "USAGE: /heal [playerid] [charge($)]");
		{
		GetPlayerPos(playerid, x, y, z);
		if(IsPlayerInRangeOfPoint(pID, 15, x, y, z))
		{
		SetPlayerHealth(pID, 100);
		GivePlayerMoney(pID, -money);
                GiverPlayerMoney(playerid, money);
		format(string, sizeof(string), "NOTE: You've been charged $%i for a heal by: %s.", money, name);
		SendClientMessage(pID, 0xFC2203FF, string);
		}
		else SendClientMessage(playerid, 0xFC2203FF, "ERROR: You're not in-range of the specified playerid.");
		}
	
	}
	return 1;
}
Untested, should work.


Re : Re: A /heal command. - Konstantinos - 16.11.2012

Quote:
Originally Posted by Anthony ©
Посмотреть сообщение
Untested, should work.
It won't. You've got extra bracket "{".


Re: A /heal command. - MatZZPL - 16.11.2012

Ok now how could you set the price? so /heal playerid pirce and the other person has to accept it? Could you create something like that?


Re: Re : Re: A /heal command. - Anthony © - 16.11.2012

Quote:
Originally Posted by Dwane
Посмотреть сообщение
It won't. You've got extra bracket "{".
Well I tested it and it worked, so...


Re: A /heal command. - Sting. - 17.11.2012

Guys I can't do it with the CMD:Heal I want it in Strcmp, cmdtext "/heal" . That way. I will still Rep you guys for help. Trying to create a medic system. I tried that code but doesn't seem to work.