My own /givehp playerid health
#1

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?
Reply
#2

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 
Reply
#3

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 >.<
Reply
#4

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
Reply
#5

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. :/
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)