Medic Command
#1

When the player do /heal and his ID he can heal himself how to disable that?

pawn Код:
new index;
    cmd = strtok(cmdtext, index);
    if (strcmp(cmd, "/heal", true) == 0)
    {
        if( gPlayerClass[playerid] != MEDIC ) return SendClientMessage(playerid, COLOR_RED, "You are not a Medic!");
        new id;
        tmp = strtok(cmdtext, index);
        if (strlen(tmp))
        {
            id = strval(tmp);
            if (IsPlayerConnected(id))
            {
                if(healedrec[playerid] != 1)
                {
                    new Float:gX, Float:gY, Float:gZ;
                    GetPlayerPos(id, gX, gY, gZ);
                    if( IsPlayerInRangeOfPoint(playerid, 5.0, gX, gY, gZ) )
                    {
                        SetPlayerHealth(id, 99.0);
                        SendClientMessage(id, 0x00FF00AA, "You've been healed by a medic!");
                        SendClientMessage(playerid, 0x00FF00AA, "Player healed.");
                        SendClientMessage(playerid, COLOR_RED, "You may heal again in 15 seconds.");
                        healedrec[playerid] = 1;
                        SetTimerEx("HealAgain", 15000, 0, "i", playerid);
                    }else SendClientMessage(playerid, COLOR_RED, "You need to be near the player to heal him !");
                }
                else
                {
                    SendClientMessage(playerid, 0xFF0000AA, "You have healed a player recently!");
                }
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000AA, "Player not found");
            }
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "USAGE: /heal <id>");
        }
        return 1;
    }
Reply
#2

pawn Код:
if(id == playerid) return SendClientMessage(playerid, -1, "{FFFFFF}You cannot heal yourself!");
Reply
#3

Код:
If(playerid == id){
Return 1;
}
Sorry for this small reply, but iam on my mobile :P
Reply
#4

pawn Код:
C:\Users\Alex\Desktop\Otros\CodSamp\codsamp_aw\gamemodes\COD5.pwn(7274) : error 017: undefined symbol "id"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Reply
#5

pawn Код:
if( IsPlayerInRangeOfPoint(playerid, 5.0, gX, gY, gZ) )
                    {
                        if(id == playerid) return SendClientMessage(playerid, -1, "{FFFFFF}You cannot heal yourself!");
                        SetPlayerHealth(id, 99.0);
                        SendClientMessage(id, 0x00FF00AA, "You've been healed by a medic!");
                        SendClientMessage(playerid, 0x00FF00AA, "Player healed.");
                        SendClientMessage(playerid, COLOR_RED, "You may heal again in 15 seconds.");
                        healedrec[playerid] = 1;
                        SetTimerEx("HealAgain", 15000, 0, "i", playerid);
                    }
Are you putting it like that?
Reply
#6

You have it after

* * * * * * if (IsPlayerConnected(id))
?
Reply
#7

pawn Код:
new index;
    cmd = strtok(cmdtext, index);
    if (strcmp(cmd, "/heal", true) == 0)
    {
        if( gPlayerClass[playerid] != MEDIC ) return SendClientMessage(playerid, COLOR_RED, "You are not a Medic!");
        new id;
        tmp = strtok(cmdtext, index);
        if (strlen(tmp))
        {
            id = strval(tmp);
            if (IsPlayerConnected(id))
            {
                if(playerid != id)
                {
                    if(healedrec[playerid] != 1)
                    {
                        new Float:gX, Float:gY, Float:gZ;
                        GetPlayerPos(id, gX, gY, gZ);
                        if( IsPlayerInRangeOfPoint(playerid, 5.0, gX, gY, gZ) )
                        {
                            SetPlayerHealth(id, 99.0);
                            SendClientMessage(id, 0x00FF00AA, "You've been healed by a medic!");
                            SendClientMessage(playerid, 0x00FF00AA, "Player healed.");
                            SendClientMessage(playerid, COLOR_RED, "You may heal again in 15 seconds.");
                            healedrec[playerid] = 1;
                            SetTimerEx("HealAgain", 15000, 0, "i", playerid);
                        }else SendClientMessage(playerid, COLOR_RED, "You need to be near the player to heal him !");
                    }
                    else
                    {
                        SendClientMessage(playerid, 0xFF0000AA, "You have healed a player recently!");
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "You can't heal yourself!");
                }
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000AA, "Player not found");
            }
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "USAGE: /heal <id>");
        }
        return 1;
    }
Reply
#8

Oh, Tnx +1 Reputation!

SOLVED
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)