/heal command - Only for medics, how?
#1

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

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

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

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

Great. Thank You Very Much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)