Need Help with a Command
#1

Hey, I have a command for medic */cure* which heals team mates. The problem that it don't heal the other player it heals the medic him self. and i want to add that the medic can't heal him self. +rep for who will help me

Код:
CMD:cure(playerid, params[])
{
    new gid;

    if(sscanf(params, "u", gid))
    {
        SendClientMessage(playerid, -1, "usage: /cure <playerid/name>");
        return true;
    }

    if(gid == INVALID_PLAYER_ID)
        return SendClientMessage(playerid, -1, "Invalid playerid!");

	new Float:x, Float:y, Float:z;
    GetPlayerPos(gid, x, y, z);
	new rangepoint = IsPlayerInRangeOfPoint(playerid, 5,x,y,z);
	if(!rangepoint)
	{
        return SendClientMessage(playerid, -1, "The player is not near you!");
    }
	
	if(rangepoint)
	{
	    if(gTeam[gid] == gTeam[playerid])
	    {
	    	if(gClass[playerid] == MEDIC)
	    	{
				SetTimerEx("cure", 7000, false, "i", playerid);
				SendClientMessage(playerid, 0x1DE6F5FF, "Player is being cured!");
				SendClientMessage(gid, 0x1DE6F5FF, "Curing..");
				ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 0, 1, 1, 1, 1, 1);
			}
			if(gClass[playerid] != MEDIC)
			{
		    	SendClientMessage(playerid, red, "Only Medic Class can cure!");
			}
		}
		if(gTeam[gid] != gTeam[playerid])
		{
		    SendClientMessage(playerid, red, "You can only cure team mates!");
		}
	}
    return true;
}
//==============================================================================
forward cure(playerid);
public cure(playerid)
{
        new gid;
        SetPlayerHealth(gid, 1000);
 	new str[128];
    format(str, sizeof(str),"Medic: {FF00FF}%s {00FF00}has cured his team mate and earned {FFFF00}+2 Score , +500$", pName(playerid), GetTeamName(playerid));
    SendClientMessageToAll(0x11ED48FF, str);
	GivePlayerScore(playerid, 2);
	GivePlayerMoney(playerid, 500);
    return 1;
}
Reply
#2

Код:
SetTimerEx("cure", 7000, false, "i", gid);
Reply
#3

it now gives score and money for who got cured not the medic
Reply
#4

pawn Код:
forward cure(playerid, cureid);
public cure(playerid, cureid)
{
    new str[128];
    format(str, sizeof(str),"Medic: {FF00FF}%s {00FF00}has cured his team mate and earned {FFFF00}+2 Score , +500$", pName(playerid), GetTeamName(playerid));
    SendClientMessageToAll(0x11ED4800, str);
    GivePlayerScore(playerid, 2);
    GivePlayerMoney(playerid, 500);
    SetPlayerHealth(cureid, 100.0);
    return 1;
}

CMD:cure(playerid, params[])
{
    new gid;
    if(gClass[playerid] != MEDIC) SendClientMessage(playerid, red, "Only Medic Class can cure!");
    else if(sscanf(params, "u", gid)) SendClientMessage(playerid, -1, "usage: /cure <playerid/name>");
    else if(gid == INVALID_PLAYER_ID) SendClientMessage(playerid, -1, "Invalid playerid!");
    else if(gTeam[gid] != gTeam[playerid]) SendClientMessage(playerid, red, "You can only cure team mates!");
    else{
        new Float:x, Float:y, Float:z;
        GetPlayerPos(gid, x, y, z);
        if(!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) SendClientMessage(playerid, -1, "The player is not near you!");
        else{
            SetTimerEx("cure", 7000, false, "ii", playerid, gid); // medic and cured
            SendClientMessage(playerid, 0x1DE6F5FF, "Player is being cured!");
            SendClientMessage(gid, 0x1DE6F5FF, "Curing..");
            ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 0, 1, 1, 1, 1, 1);
        }
    }
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)