Set health to 100 command
#1

Hi, its me again....

now i wanted to create a command to set the health of the id which the admin typed in to 100...
But i get some errors while compiling my script.

here my script:

pawn Код:
CMD:fullhealth(playerid, params[])
{
    if (IsPlayerAdmin(playerid) == 1)
    {
        new command[56];
       
        if (sscanf(params, "d", command)) return SendClientMessage(playerid, RED, "USAGE: /fullhealth [ID]");
       
        else if (!strcmp(command, "d", true))
        {
            new playername[256];
            new adminname[256];
            new string[256];
           
            SetPlayerHealth(command, 100);
           
            GetPlayerName(command, playername, sizeof(playername));
            format(string, sizeof(string), "*** Du hast die HP von %s auf 100 gesetzt.", playername);
            SendClientMessage(playerid, ORANGE, string);
           
            GetPlayerName(playerid, adminname, sizeof(adminname));
            format(string, sizeof(string), "*** Deine HP wurden von %s auf 100 gesetzt.", adminname);
            SendClientMessage(command, ORANGE, string);
        }
    }
    else
    {
        SendClientMessage(playerid, RED, "SERVER: Du bist nicht als Admin eingeloggt");
    }
    return 1;
}
please help...
Reply
#2

pawn Код:
CMD:fullhealth(playerid,params[])
{
    if(IsPlayerAdmin(playerid) == 1)
    {
        if (sscanf(params,"r",params[0])) SendClientMessage(playerid, RED, "USAGE: /fullhealth [ID]");
        else if(params[0] == INVALID_PLAYER_ID) SendClientMessage(playerid, RED, "Invalid player id.");
        else
        {
             new pname[MAX_PLAYER_NAME],string[128];
            SetPlayerHealth(params[0], 100);

            GetPlayerName(params[0],pname,sizeof(pname));
            format(string, sizeof(string), "*** Du hast die HP von %s auf 100 gesetzt.", pname);
            SendClientMessage(playerid, ORANGE, string);

            GetPlayerName(playerid,pname,sizeof(pname));
            format(string, sizeof(string), "*** Deine HP wurden von %s auf 100 gesetzt.", pname);
            SendClientMessage(params[0], ORANGE, string);
        }
    }
    else
    {
        SendClientMessage(playerid, RED, "SERVER: Du bist nicht als Admin eingeloggt");
    }
    return 1;
}
Reply
#3

Thank you
Reply
#4

hm...
But when i use the command, then i only get that message:

Quote:

*** Du hast die HP von auf 100 gesetzt

but i should see this:

Quote:

*** Du hast die HP von <Playername> auf 100 gesetzt

And the HP doesnt get set to 100.
Reply
#5

Do you even use sscanf plugin? If you use old sscanf put "u" instead of "r".
Reply
#6

euhh i dnt know... i use this plugin:
zcmdsscanf.inc

it was included with a tutorial for login command.

or should i use sscanf and zcmd seperatelly?
Reply
#7

Would be nice if u answer.

BTW i got it with an "u" in the sscanf command
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)