Where would i put this
#1

I have this heal code:
pawn Код:
dcmd_heal(playerid, params[])
{
    if(GetPlayerTeam(playerid) == 2)
    {
        if (strlen(params))
        {
            new id = strval(params);
            if (IsPlayerConnected(id))
            {
                new Float:x, Float:y, Float:z;
                GetPlayerPos(playerid, x, y, z);
                if(IsPlayerInRangeOfPoint(playerid, 6.0, x, y, z))
                {
                    SetPlayerHealth(id, 100.0);
                    new name[MAX_PLAYER_NAME], string[48];
                GetPlayerName(playerid, name, sizeof(name));
                format(string, sizeof(string), "Medical Member %s has healed you.", name );
                    SendClientMessage(id, 0xFF8040FF, string);
                    new name1[MAX_PLAYER_NAME];
                    GetPlayerName(id, name1, sizeof(name1));
                    format(string, sizeof(string), "You have healed %s", name1);
                    SendClientMessage(playerid, 0xFF8040FF, string);
                    }
                    else
                    {
                        SendClientMessage(playerid, 0xFF0000AA, "You're not near this player");
                    }
                    //}
                    //else
                    //{
            //SendClientMessage(playerid, 0xFF0000AA, "You cannot heal yourself");
          //}
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000AA, "Player not found");
            }
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "Usage: /heal (PlayerID/PartOfName) ");
        }
    }
    else
    {
        SendClientMessage(playerid, 0xFF0000AA, "You need to be part of the Medical Team to use this command");
    }
    return 1;
}
And i want to add:
pawn Код:
if(id == playerid)
Where abouts in that code would i put that?
Because i tried putting it in a few places,
But it heals me, Sends me the messages, But also sends that message,
I want it to check that if im trying to heal myself,
It sends me a message and dosent do anything,
If im not, it carys on...
Reply
#2

Also if im next to the player it lets me heal them,
If im far away from the player it still lets me heal them,
It shouldnt, Anyone tell me why?

FIXED: The rangeofpoint problem, But still have the other problem
Reply
#3

the "playerid" is (already) defined inside your command, now you need to search the "id", which is defined in front of the healing-part itself, it will work when you put it after the 2 variables are defined (else you will get another error "undefined symbol")...
Код:
dcmd_heal(playerid, params[])
{
	if(GetPlayerTeam(playerid) == 2)
	{
		if (strlen(params))
		{
			new id = strval(params);
			if (playerid==id)
			{
				return SendClientMessage(playerid,0xFF8040FF,"You cannot heal yourself. search for another medic who can heal you!");
			}
			if (IsPlayerConnected(id))
			{
 				new Float:x, Float:y, Float:z;
				GetPlayerPos(playerid, x, y, z);
				if(IsPlayerInRangeOfPoint(playerid, 6.0, x, y, z))
				{
					SetPlayerHealth(id, 100.0);
					new name[MAX_PLAYER_NAME], string[48];
  				GetPlayerName(playerid, name, sizeof(name));
  				format(string, sizeof(string), "Medical Member %s has healed you.", name );
					SendClientMessage(id, 0xFF8040FF, string);
					new name1[MAX_PLAYER_NAME];
					GetPlayerName(id, name1, sizeof(name1));
					format(string, sizeof(string), "You have healed %s", name1);
					SendClientMessage(playerid, 0xFF8040FF, string);
					}
					else
					{
						SendClientMessage(playerid, 0xFF0000AA, "You're not near this player");
					}
					//}
					//else
					//{
          	//SendClientMessage(playerid, 0xFF0000AA, "You cannot heal yourself");
          //}
			}
			else
			{
				SendClientMessage(playerid, 0xFF0000AA, "Player not found");
			}
		}
		else
		{
			SendClientMessage(playerid, 0xFF0000AA, "Usage: /heal (PlayerID/PartOfName) ");
		}
	}
	else
	{
		SendClientMessage(playerid, 0xFF0000AA, "You need to be part of the Medical Team to use this command");
	}
	return 1;
}
Reply
#4

Nvm i already fixed,
Nowhere near to what you posted though xd
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)