/heal another player
#1

Ok guys, this don't work:

pawn Код:
if(strcmp("/heal", cmdtext, true, 4) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            if(!strlen(cmdtext[8])) return SendClientMessage(playerid, 0xFF0000AA, "Use: /heal [playerid]");
            new gp = strval(cmdtext[8]);
            if(!IsPlayerConnected(gp)) return SendClientMessage(playerid, 0xFF0000AA, "Invalid Playerid");
            new pn[24], an[24], str[70];
            GetPlayerName(playerid, an, 24); GetPlayerName(gp, pn, 24);
            format(str, sizeof(str), "%s is healed by admin %s", pn, an);
            SendClientMessageToAll(0xA9A9A9AA, str);
            SetPlayerHealth(playerid, 100);
            return 1;
        }
    }
Can anyone correct it
------------------------------------------------------------------------------
SOLVED in this topic
Reply
#2

Use dcmd much faster and easier.
Reply
#3

Try this

Код:
if(strcmp("/heal", cmdtext, true, 4) == 0)
        {
            if(!strlen(cmdtext[8])) return SendClientMessage(playerid, 0xFF0000AA, "Use: /heal [playerid]");
            new gp = strval(cmdtext[8]);
            if(!IsPlayerConnected(gp)) return SendClientMessage(playerid, 0xFF0000AA, "Invalid Playerid");
            new pn[24], an[24], str[70];
            GetPlayerName(playerid, an, 24); GetPlayerName(gp, pn, 24);
            format(str, sizeof(str), "%s is healed by %s", pn, an);
            SendClientMessageToAll(0xA9A9A9AA, str);
            SetPlayerHealth(playerid, 100);
            return 1;
        }
Reply
#4

Код:
CMD:heal(playerid, params[])
{
	new
		otherId
	;
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You're not an admin");
        if(!IsPlayerConnected(otherId)) return SendClientMessage(playerid, -1, "ERROR: Invalid ID");
	if(sscanf(params, "d", otherId)) return SendClientMessage(playerid, -1, "USAGE: /heal [Name/ID]");
	SetPlayerHealth(otherId, 100.0);
	return 1;
}
ZCMD Is much easier and faster.
Also if you haven't defined sscanf, then add this native:
Код:
native sscanf(const data[], const format[], {Float,_}:...);
Reply
#5

Quote:
Originally Posted by Rock18
Посмотреть сообщение
Try this

Код:
if(strcmp("/heal", cmdtext, true, 4) == 0)
        {
            if(!strlen(cmdtext[8])) return SendClientMessage(playerid, 0xFF0000AA, "Use: /heal [playerid]");
            new gp = strval(cmdtext[8]);
            if(!IsPlayerConnected(gp)) return SendClientMessage(playerid, 0xFF0000AA, "Invalid Playerid");
            new pn[24], an[24], str[70];
            GetPlayerName(playerid, an, 24); GetPlayerName(gp, pn, 24);
            format(str, sizeof(str), "%s is healed by %s", pn, an);
            SendClientMessageToAll(0xA9A9A9AA, str);
            SetPlayerHealth(playerid, 100);
            return 1;
        }
Don't work ...

Quote:
Originally Posted by FreshDoubleX
Посмотреть сообщение
Код:
CMD:heal(playerid, params[])
{
	new
		otherId
	;
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You're not an admin");
        if(!IsPlayerConnected(otherId)) return SendClientMessage(playerid, -1, "ERROR: Invalid ID");
	if(sscanf(params, "d", otherId)) return SendClientMessage(playerid, -1, "USAGE: /heal [Name/ID]");
	SetPlayerHealth(otherId, 100.0);
	return 1;
}
ZCMD Is much easier and faster.
Also if you haven't defined sscanf, then add this native:
Код:
native sscanf(const data[], const format[], {Float,_}:...);
Yeah ok It doesn't work too ... (i know zcmd is better but ... i don't like to use it xD)
but thanks
Reply
#6

try this..
pawn Код:
CMD:heal(playerid, params[])
{
    new
        id;
    if (sscanf(params, "u", id)) SendClientMessage(playerid, COLOR_GREEN, "Usage: \"/heal <playerid or name>\"");
    else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_SIMPSONS, "Player not found");
    if (id == playerid) {SendClientMessage(playerid, COLOR_SIMPSONS, "You cannot set your own hp!"); return 1;}
    if(PlayerInfo[playerid][pAdminLevel] < 1){SendClientMessage(playerid, COLOR_LIGHTRED, "You Are Not Admin level required to use this cmd"); return 1;}
    else
    {
        SetPlayerHealth(id, 100.0);
        SendClientMessage(id, COLOR_LIGHTRED, "Admin healed you.");
        SendClientMessage(playerid, COLOR_LIGHTRED, "Player healed.");
    }
    return 1;
}
this is straight from my GM..
Reply
#7

Quote:
Originally Posted by SAMP WIKI
pawn Код:
dcmd_heal(playerid, params[])
{
    new
        id;
    if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\"");
    else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
    else
    {
        SetPlayerHealth(id, 100.0);
        SendClientMessage(id, 0x00FF00AA, "You have been healed");
        SendClientMessage(playerid, 0x00FF00AA, "Player healed");
    }
    return 1;
}
AND incase that one dosen't work, heres a dcmd one.
Reply
#8

Damn, thanks for helping everyone but ... xs just use
pawn Код:
if(strcmp, "/heal", cmdtext, ...)
please (a) ^^
Reply
#9

Quote:
Originally Posted by [CrC]reinixx
Посмотреть сообщение
try this..
pawn Код:
CMD:heal(playerid, params[])
{
    new
        id;
    if (sscanf(params, "u", id)) SendClientMessage(playerid, COLOR_GREEN, "Usage: \"/heal <playerid or name>\"");
    else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_SIMPSONS, "Player not found");
    if (id == playerid) {SendClientMessage(playerid, COLOR_SIMPSONS, "You cannot set your own hp!"); return 1;}
    if(PlayerInfo[playerid][pAdminLevel] < 1){SendClientMessage(playerid, COLOR_LIGHTRED, "You Are Not Admin level required to use this cmd"); return 1;}
    else
    {
        SetPlayerHealth(id, 100.0);
        SendClientMessage(id, COLOR_LIGHTRED, "Admin healed you.");
        SendClientMessage(playerid, COLOR_LIGHTRED, "Player healed.");
    }
    return 1;
}
this is straight from my GM..
Offtopic: Did you take that from SWX? I recognize the code
Reply
#10

Quote:
Originally Posted by alpha500delta
Посмотреть сообщение
Offtopic: Did you take that from SWX? I recognize the code
no.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)