SA-MP Forums Archive
Question for command - 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)
+--- Thread: Question for command (/showthread.php?tid=453210)



Question for command - JayceonTaylor - 24.07.2013

Hello how can i make command for Medic /heal ID i use

pawn Код:
if(PlayerInfo[playerid][pMember] == TEAM_MEDIC)
   {
            if(PlayerInfo[playerid][pHealme] <= 0)
            {
Please help me


Re: Question for command - Tayab - 24.07.2013

I've used ZCMD.

pawn Код:
CMD:heal(playerid,params[])
{
    if(PlayerInfo[playerid][pMember] == TEAM_MEDIC)
    {
        if(PlayerInfo[playerid][pHealme] <= 0)
        {
            new Float:health,string[128],name[MAX_PLAYER_NAME];
            if(isnull(params)) return SendClientMessage(playerid,-1,"USAGE: /heal [playerid]");
            GetPlayerName(playerid,name,sizeof(name));
            SetPlayerHealth(strval(params),100);
            format(string,sizeof(string),"You've been healed by Medic %s",name);
            SendClientMessage(strval(params),0xFF8000AA,string);
        }
    }
    return 1;
}



Re : Question for command - JayceonTaylor - 24.07.2013

4 Errors "

pawn Код:
(11787) : warning 219: local variable "string" shadows a variable at a preceding level
(11788) : error 017: undefined symbol "params"
(11788) : error 029: invalid expression, assumed zero
(11788) : error 017: undefined symbol "params"
(11788) : fatal error 107: too many error messages on one line

pawn Код:
if(isnull(params)) return SendClientMessage(playerid,-1,"Ползвай: /heal [playerid]");
I Use strcmp


Re : Question for command - JayceonTaylor - 24.07.2013

And command doesnt work command heal only me pls help


Re: Question for command - Tayab - 24.07.2013

I don't know the native command system much but with help of wikki I've created it for you.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[30];
    new idx;
    cmd = strtok(cmdtext, idx);
 
    if(strcmp(cmd, "/heal", true) == 0)
    {
        new tmp[30];
        tmp = strtok(cmdtext, idx);
 
        new pID = strval(tmp);
        if(IsPlayerConnected(pID))
        {
            new Float:health,string[128],name[MAX_PLAYER_NAME];
            GetPlayerName(playerid,name,sizeof(name));
            SetPlayerHealth(strval(params),100);
            format(string,sizeof(string),"You've been healed by Medic %s",name);
            SendClientMessage(strval(params),0xFF8000AA,string);
           
        }
        return 1;
    }
    return 0;
}