SA-MP Forums Archive
My own /givehp playerid health - 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: My own /givehp playerid health (/showthread.php?tid=370851)



My own /givehp playerid health - Guitar - 21.08.2012

Hello,

I made this command:

Код:
CMD:givehp(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,COLOR_RED,".:: You are not authorized to use this command ::.");
	new targetid, str[128], Float:hpamount;
	if(sscanf(params, "uu", targetid, hpamount)) return SendClientMessage(playerid, COLOR_WHITE,"/givehp [PlayerID/PartofName] [Health Points]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_ORANGE"[ERROR]"#COL_LRED" Player not connected!");
	SetPlayerHealth(targetid, hpamount);
	format(str, sizeof(str), "[ADMIN] %s given you health points(%d).", playerid, hpamount);
	SendClientMessage(targetid, COLOR_GREEN, str);
	return 1;
}
But, it doesn't show like who gave who the health points and doesn't show the health points, and it doesn't set the health .. Can you please fix it for me?


Re: My own /givehp playerid health - Gangster-rocks - 21.08.2012

Try dis bro
pawn Код:
CMD:givehp(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        new targetid, str[128], Float:hpamount;
        if(sscanf(params, "uu", targetid, hpamount)) return SendClientMessage(playerid, COLOR_WHITE,"/givehp [PlayerID/PartofName] [Health Points]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_ORANGE"[ERROR]"#COL_LRED" Player not connected!");
        SetPlayerHealth(targetid, hpamount);
        format(str, sizeof(str), "[ADMIN] %s given you health points(%d).", playerid, hpamount);
        SendClientMessage(targetid, COLOR_GREEN, str);
    }
    else
    {
        SendClientMessage(playerid,COLOR_RED,".:: You are not authorized to use this command ::.");
    }
    return 1;
}
PHP код:
Use [pawn] [/pawnTags 



Re: My own /givehp playerid health - Ronaldo_raul™ - 21.08.2012

pawn Код:
CMD:givehp ( playerid , params [ ] )
{
    if ( PlayerInfo [ playerid ] [ pAdmin ] < 1 ) return SendClientMessage ( playerid , -1 , ".:: You are not authorized to use this command ::." ) ;
    new ID , Str [ 128 ] , Float:amnt , pName [ MAX_PLAYER_NAME ] ;
    if ( sscanf ( params , "uu" , ID , amnt ) ) return SendClientMessage ( playerid , -1 , "/givehp [PlayerID/PartofName] [Health Points]" ) ;
    if ( !IsPlayerConnected ( ID ) ) return SendClientMessage ( playerid , -1 , "[ERROR] Player not connected!" ) ;
    else
    {
        SetPlayerHealth ( ID , amnt ) ;
        GetPlayerName ( ID , pName , MAX_PLAYER_NAME ) ;
        format ( Str , 128 , "[ADMIN] %s given you health points(%d)." , pName , amnt ) ;
        SendClientMessage ( ID , -1 , Str ) ;
        return 1;
    }
}
NOT TESTED! and I am sleepy >.<


Re: My own /givehp playerid health - Jochemd - 21.08.2012

pawn Код:
if(sscanf(params, "uu", targetid, hpamount))
Код:
Specifier(s)			Name				Example values
	i, d			Integer				1, 42, -10
	c			Character			a, o, *
	l			Logical				true, false
	b			Binary				01001, 0b1100
	h, x			Hex				1A, 0x23
	o			Octal				045 12
	n			Number				42, 0b010, 0xAC, 045
	f			Float				0.7, -99.5
	g			IEEE Float			0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E
	u			User name/id (bots and players)	******, 0
	q			Bot name/id			ShopBot, 27
	r			Player name/id			******, 42



Re: My own /givehp playerid health - Ronaldo_raul™ - 21.08.2012

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
pawn Код:
if(sscanf(params, "uu", targetid, hpamount))
Код:
Specifier(s)			Name				Example values
	i, d			Integer				1, 42, -10
	c			Character			a, o, *
	l			Logical				true, false
	b			Binary				01001, 0b1100
	h, x			Hex				1A, 0x23
	o			Octal				045 12
	n			Number				42, 0b010, 0xAC, 045
	f			Float				0.7, -99.5
	g			IEEE Float			0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E
	u			User name/id (bots and players)	******, 0
	q			Bot name/id			ShopBot, 27
	r			Player name/id			******, 42
damn. My mistake. :/