Help with ZCMD + sscanf
#1

Well ive recently tried to make a sethp with zcmd and sscanf, but i failed hard. Was wondering if someone could give me example(i cant show you code cause i kinda raged on it). Thanks in advance.
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=244841
Reply
#3

Код:
CMD:sethp(playerid, params[])
{
	new player2, health;
	if(sscanf(params, "ud", player2, health)) SendClientMessage(playerid, COLOR_WHITE, "[USAGE]:/sethp <playerid>");
	else if(IsPlayerConnected(player2)) SendClientMessage(playerid, COLOR_WHITE, "Invalid Player.");
	else
	{
	   SetPlayerHealth(player2, health);
	   SendClientMessage(playerid, COLOR_WHITE, "Player Health Set.");
	   SendClientMessage(player2 , COLOR_WHITE, "Your health has been set.");
	   return 1;
	}
	return 1;
}
Compiles fine, but doesn't work.
Reply
#4

pawn Код:
CMD:sethp(playerid, params[])
{
    new player2, Float:health;
    if(sscanf(params, "uf", player2, health)) SendClientMessage(playerid, COLOR_WHITE, "[USAGE]:/sethp <playerid> <health>");
    else if(!IsPlayerConnected(player2)) SendClientMessage(playerid, COLOR_WHITE, "Invalid Player.");
    else
    {
       SetPlayerHealth(player2, health);
       SendClientMessage(playerid, COLOR_WHITE, "Player Health Set.");
       SendClientMessage(player2 , COLOR_WHITE, "Your health has been set.");
       return 1;
    }
    return 1;
}
Reply
#5

pawn Код:
COMMAND:sethp(playerid, params[])
{
    new user, amount;
    if(sscanf(params, "ui", user, amount))
        return SendClientMessage(playerid, white, "USAGE: /sethp [playerid] [amount]");
    SetPlayerHealth(user, amount);
    SendClientMessage(user, white, "Your health has been set.");
    return 1;
}
Reply
#6

Auto kills me , Still kills me
Reply
#7

Quote:
Originally Posted by [NRP]Blade
Посмотреть сообщение
Auto kills me , Still kills me
Are you positive? Let me go in-game and test it out.
Reply
#8

pawn Код:
command(sethp, playerid, params[])
{
    new player2, Float:health,string[128],string2[128];
    if(sscanf(params, "uf", player2, health)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]:/sethp <playerid> <health>");
    if(!IsPlayerConnected(player2)) return SendClientMessage(playerid, COLOR_WHITE, "Invalid Player.");
    SetPlayerHealth(player2, health);
    format(string2,sizeof(string2),"Player's health set to: %d.",health);
    SendClientMessage(playerid, COLOR_WHITE, string2);
    format(string,sizeof(string),"Your health has been set to: %d.",health);
    SendClientMessage(player2, COLOR_WHITE,string);
    return 1;
}
A more detailed command.
Reply
#9

Do you have the correct sscanf2 plugin & include? I don't think you do because I just tested & debugged it and this is what happened.

Input:
Код:
/sethp a7x 50
Output:
Quote:

[Debug] /sethp a7x 50: a7x's health has been set to 50.

I highly suggest you go re-download sscanf2.
Reply
#10

1sec
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)