SA-MP Forums Archive
Set health to 100 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Set health to 100 command (/showthread.php?tid=150759)



Set health to 100 command - Jonni8 - 27.05.2010

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...


Re: Set health to 100 command - Sergei - 27.05.2010

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;
}



Re: Set health to 100 command - Jonni8 - 27.05.2010

Thank you


Re: Set health to 100 command - Jonni8 - 27.05.2010

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.


Re: Set health to 100 command - Sergei - 27.05.2010

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


Re: Set health to 100 command - Jonni8 - 27.05.2010

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?


Re: Set health to 100 command - Jonni8 - 27.05.2010

Would be nice if u answer.

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