A /heal command.
#1

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!
Reply
#2

You Need it As PickUp ?
Reply
#3

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;
}
Reply
#4

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

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;
}
Reply
#6

Код:
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.
Reply
#7

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

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?
Reply
#9

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

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)