Can't get a command to have multiple variables.
#1

Код:
//set command
CMD:set(playerid,params[])
{
    new float:hp,targetid,health,armor,float:armour,str[128],target[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_ADMIN,"SERVER: You need to be an RCON Administrator to use this command.");
	sscanf(params,"s",health);
	{
	if(sscanf(params,"uf",targetid,hp)) return SendClientMessage(playerid,COLOR_LIGHTGREY,"USAGE: /set health [ID/NAME] [AMOUNT]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,COLOR_LIGHTGREY,"SERVER: That player is not connected.");
	SetPlayerHealth(targetid,hp);
	GetPlayerName(playerid,name,sizeof(name));
	GetPlayerName(targetid,target,sizeof(target));
	if(targetid == playerid) format(str,sizeof(str),"SERVER: You have set your health to %f",hp);
	else format(str,sizeof(str),"SERVER: You have set %s(%i) their health to %f",target,targetid,hp);
	SendClientMessage(playerid,COLOR_RED,str);
	format(str,sizeof(str),"SERVER: %s(%i) has set your health to %f",name,playerid,hp);
	SendClientMessage(targetid,COLOR_RED,str);
	return 1;
	}
	sscanf(params,"s",armor);
	{
	if(sscanf(params,"uf",targetid,armour)) return SendClientMessage(playerid,COLOR_LIGHTGREY,"USAGE: /set armor [ID/NAME] [AMOUNT]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,COLOR_LIGHTGREY,"SERVER: That player is not connected.");
	SetPlayerHealth(targetid,armour);
	GetPlayerName(playerid,name,sizeof(name));
	GetPlayerName(targetid,target,sizeof(target));
	if(targetid == playerid) format(str,sizeof(str),"SERVER: You have set your armor to %f",armour);
	else format(str,sizeof(str),"SERVER: You have set %s(%i) their armor to %f",target,targetid,armour);
	SendClientMessage(playerid,COLOR_RED,str);
	format(str,sizeof(str),"SERVER: %s(%i) has set your armor to %f",name,playerid,armour);
	SendClientMessage(targetid,COLOR_RED,str);
	return 1;
	}
	return 1;
}
Basically, I want the cmd to work like this:

I type /set then it asks what i want to set for example
USAGE: /set armor hp
then i pick for example hp and it will go on to the command
same for armor, but it wont compile. idk what im doing wrong, please help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)