Failing zcmd + sscanf.. help?
#1

Hi, i have made a admin heal command.. everything works fine excpect :

1. it does not set the ammount of health i tell him to.. health 1 works, if i put at the health 2 it makes it 66366 or something..

2. It sends a message to me that i have set the players hp to that ammount and it gives the player the message that he got that much hp from me.. that works perfect but it also sends the message whats supossed to go to the player back to me.. so i receieve :

''Enrico (id) has set your HP to ''HP''
"You have set's ''PLAYER's'' hp to ''HP''

Help pleasE?

Код:
CMD:aheal(playerid, params[])
{
	new targetid, Float:health, targetname[MAX_PLAYER_NAME], string[70], string2[70];
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "This command is only for administrators!");
	if(sscanf(params,"ur", targetid, health)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /aheal [playerid/partofname] [health]");
	else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Invalid player ID!");
	else
	{
		SetPlayerHealth(targetid, health);
		GetPlayerName(targetid, targetname, MAX_PLAYER_NAME);
		format(string, sizeof(string), "You've set %s's (%d) health to %d.", targetname, targetid, health);
		SendClientMessage(playerid,COLOR_WHITE,string);
		format(string2, sizeof(string2), "%s has set your health to %d.", playerid, health);
		SendClientMessage(targetid,COLOR_WHITE,string2);
		
	}	
	return 1;
}
Reply
#2

pawn Код:
CMD:aheal(playerid, params[])
{
    new targetid, Float:health, targetname[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[70], string2[70];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "This command is only for administrators!");
    if(sscanf(params,"ui", targetid, health)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /aheal [playerid/partofname] [health]");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Invalid player ID!");
    SetPlayerHealth(targetid, health);
    GetPlayerName(targetid, targetname, sizeof(targetname));
    GetPlayerName(playerid, adminname, sizeof(adminname));
    format(string, sizeof(string), "You've set %s's (%d) health to %d.", targetname, targetid, health);
    SendClientMessage(playerid,COLOR_WHITE,string);
    format(string2, sizeof(string2), "%s has set your health to %d.", adminname, health);
    return SendClientMessage(targetid,COLOR_WHITE,string2);
}
health is not "r" player but integer ( a number).
Edit: I added the adminname you forgot it and in the last line it will send the Rcon Admin's ID.
Reply
#3

Thank you testing!
Reply
#4

pawn Код:
CMD:aheal(playerid, params[])
{
    new targetid, Float:health, targetname[MAX_PLAYER_NAME], playername[MAX_PLAYER_NAME],string[128];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "This command is only for administrators!");
    if(sscanf(params,"uf", targetid, health)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /aheal [playerid/partofname] [health]");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Invalid player ID!");
    SetPlayerHealth(targetid, health);
    GetPlayerName(targetid, targetname, MAX_PLAYER_NAME);
    GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
    format(string, sizeof(string), "You've set %s's (%d) health to %0.1f.", targetname, targetid, health);
    SendClientMessage(playerid,COLOR_WHITE,string);
    format(string, sizeof(string), "%s has set your health to %0.1f.", playername, health);
    SendClientMessage(targetid,COLOR_WHITE,string);
    return 1;
}
Reply
#5

Thanks it works!, but now there is another problem (was before also) it doesn't say my name but ''Acmd_goto$^$$" has set your HP to 1-100.. bla bla? How can i fix this?

if(sscanf(params,"u", TargetID)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /goto [playerid/partofname]");

That one for goto playername's or id's is that only U or UR?
Reply
#6

pawn Код:
if(sscanf(params,"ui", TargetID)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /goto [playerid/partofname]");
in my way this should be well try it.....
Reply
#7

r = Player name/id
u = User name/id (bots and players)
Quote:
Originally Posted by Danyal
Посмотреть сообщение
pawn Код:
if(sscanf(params,"ui", TargetID)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /goto [playerid/partofname]");
in my way this should be well try it.....
Are you serious, do you use an integer number to set the sscanf as "i", for only name/id you need r or u.
u if you need NPCs id works too.
Reply
#8

Fixed the problem with the name on my own.. made another variable.

Hope it works.
Reply
#9

well Dwane thanks for info idk that/ forgot that :P
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)