SA-MP Forums Archive
/heal command - Only for medics, how? - 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: /heal command - Only for medics, how? (/showthread.php?tid=79696)



/heal command - Only for medics, how? - Puzi - 30.05.2009

Код:
new
		index,
		cmd[20];
	cmd = strtok(cmdtext, index);
	if (strcmp(cmd, "/heal", true) == 0)
	{
		new
			tmp[20],
			id;
		tmp = strtok(cmdtext, index);
		if (strlen(tmp))
		{
			id = strval(tmp);
			if (IsPlayerConnected(id))
			{
				SetPlayerHealth(id, 100.0);
				SendClientMessage(id, 0x00FF00AA, "You have been healed! / Zostałeś uzdrowiony/a!");
				SendClientMessage(playerid, 0x00FF00AA, "Player healed / Osoba uzdrowiona!");
			}
			else
			{
				SendClientMessage(playerid, 0xFF0000AA, "Player not found / Gracz nieznaleziony");
			}
		}
		else
		{
			SendClientMessage(playerid, 0xFF0000AA, "USAGE/UŻYCIE: /heal <playerid/idgracza>");
		}
		return 1;
	}
This command works perfectly but the only thing is I want to limit it only for a TEAM_MEDYK. How can I do that? I tried editing it a bit but i messed it up, so I left the right command which i posted above. Help would be appreciated.

Thanks and Regards
Puzi


Re: /heal command - Only for medics, how? - member - 30.05.2009

how do u define a player that is a medic, what variable do u use for this?


Re: /heal command - Only for medics, how? - Puzi - 30.05.2009

Quote:
Originally Posted by [B2K
Hustler ]
how do u define a player that is a medic, what variable do u use for this?
Код:
	gTeam[playerid] = TEAM_MEDYK;

	} else if(classid == 4) {
Did you mean that? Sorry, i'm a noob at those things

Erm, this is also what I have in my script...
Код:
else if(classid == 51){
gTeam[playerid] = TEAM_MEDYK;
GameTextForPlayer(playerid, "~w~Medyk / Medic", 2000, 3);}
and...

Код:
#define TEAM_MEDYK 2
Hope it helps


Re: /heal command - Only for medics, how? - member - 30.05.2009

Thats exactly what you need , it is your identifier of whether the player is a "TEAM_MEDYK". Only 1 line added.

pawn Код:
if (strcmp(cmd, "/heal", true) == 0)
    {
        new tmp[20],id;
        tmp = strtok(cmdtext, index);
        if(gTeam[playerid] != TEAM_MEDYK) return SendClientMessage(playerid, 0xFF0000AA, "You need to be a medic to do that!");
        if (strlen(tmp))
        {
            id = strval(tmp);
            if (IsPlayerConnected(id))
            {
                SetPlayerHealth(id, 100.0);
                SendClientMessage(id, 0x00FF00AA, "You have been healed! / Zosta?es' uzdrowiony/a!");
                SendClientMessage(playerid, 0x00FF00AA, "Player healed / Osoba uzdrowiona!");
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000AA, "Player not found / Gracz nieznaleziony");
            }
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "USAGE/UZ.YCIE: /heal <playerid/idgracza>");
        }
        return 1;
    }



Re: /heal command - Only for medics, how? - Puzi - 30.05.2009

Great. Thank You Very Much