SA-MP Forums Archive
Command problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Command problem (/showthread.php?tid=608680)



Command problem - Mijata - 04.06.2016

I have problem with this command, i can't set armour i wanna max armour to be 99.

Код:
CMD:setarmour(playerid,params[])
{
	if(pInfo[playerid][pLevel] >= 2)
	{
		new id,amount;
        if(sscanf(params, "ui",id,amount)) return SendClientMessage(playerid, yellow, "Usage: /Setarmour <Player ID/Part of nick> <Amount> (1-100)!");
        if(IsPlayerConnected(id))
		{
            if(amount > 0 || amount < 100)return SendClientMessage(playerid, red, "Invalid amount!");
			format(Jstring, sizeof(Jstring), "You have set %s's Armour to '%d'", GetName(id), amount);
			SendClientMessage(playerid,yellow,Jstring);
			format(Jstring,sizeof(Jstring),"Admin '%s' has set your Armour to '%d'", GetName(playerid), amount);
			SendClientMessage(id,yellow,Jstring);
			SetPlayerArmour(id, amount);
			CommandToAdmins(playerid,"setarmour");
			return 1;
	    }
		else return ShowMessage(playerid, red, 2);
	}
	else return ShowMessage(playerid, red, 1);
}



Re: Command problem - WhiteGhost - 04.06.2016

Those it give u an error or... and why dont u just put the amount 0 - 99 then?


Re: Command problem - Onfroi - 04.06.2016

if(amount > 0 && amount < 100)


Re: Command problem - CSLangdale - 04.06.2016

Is that not saying if the amount is greater than 0 or less than 100 it's invalid?

Код:
 
  if(amount > 0 || amount < 100)
Shouldn't it be this way round?
Код:
  if(amount < 0 || amount > 99)



Re: Command problem - MBilal - 04.06.2016

Код:
CMD:setarmour(playerid,params[])
{
		if(pInfo[playerid][pLevel] < 2)return ShowMessage(playerid, red, 1);
		new id,amount;
        if(sscanf(params, "ui",id,amount)) return SendClientMessage(playerid, yellow, "Usage: /Setarmour <Player ID/Part of nick> <Amount> (1-100)!");
        if(!IsPlayerConnected(id))	return ShowMessage(playerid, red, 2);
        if(  0 > amount > 100)return SendClientMessage(playerid, red, "Invalid amount!");
		format(Jstring, sizeof(Jstring), "You have set %s's Armour to '%d'", GetName(id), amount);
		SendClientMessage(playerid,yellow,Jstring);
		format(Jstring,sizeof(Jstring),"Admin '%s' has set your Armour to '%d'", GetName(playerid), amount);
		SendClientMessage(id,yellow,Jstring);
		SetPlayerArmour(id, amount);
		CommandToAdmins(playerid,"setarmour");
		return 1; 
}
Have fun!


Re: Command problem - Mijata - 04.06.2016

Quote:
Originally Posted by CSLangdale
Посмотреть сообщение
Is that not saying if the amount is greater than 0 or less than 100 it's invalid?

Код:
 
  if(amount > 0 || amount < 100)
Shouldn't it be this way round?
Код:
  if(amount < 0 || amount > 99)
Thanks, fixed rep+


Re: Command problem - Dayrion - 04.06.2016

By the way, armor value is a float like health.


Re: Command problem - AbyssMorgan - 04.06.2016

PHP код:
CMD:setarmour(playerid,params[])
{
    if(
pInfo[playerid][pLevel] >= 2)
    {
        new 
idFloat:amount;
        if(
sscanf(params"uf",id,amount)) return SendClientMessage(playeridyellow"Usage: /Setarmour <Player ID/Part of nick> <Amount> (1-100)!");
        if(
IsPlayerConnected(id))
        {
            if(
amount <= 0.0 || amount 100.0) return SendClientMessage(playeridred"Invalid amount!");
            
format(Jstringsizeof(Jstring), "You have set %s's Armour to '%d'"GetName(id), amount);
            
SendClientMessage(playerid,yellow,Jstring);
            
format(Jstring,sizeof(Jstring),"Admin '%s' has set your Armour to '%d'"GetName(playerid), amount);
            
SendClientMessage(id,yellow,Jstring);
            
SetPlayerArmour(idamount);
            
CommandToAdmins(playerid,"setarmour");
            return 
1;
        }
        else return 
ShowMessage(playeridred2);
    }
    else return 
ShowMessage(playeridred1);

new idiot_count = 5;


Re: Command problem - Threshold - 04.06.2016

pawn Код:
CMD:setarmour(playerid, params[])
{
    if(pInfo[playerid][pLevel] < 2) return ShowMessage(playerid, red, 1);
    new id, Float:amount;
    if(sscanf(params, "uf", id, amount)) return SendClientMessage(playerid, yellow, "Usage: /Setarmour <Player ID/Part of nick> <Amount> (0-99)!");
    if(!IsPlayerConnected(id)) return ShowMessage(playerid, red, 2);
    if(!(0.0 <= amount <= 99.0)) return SendClientMessage(playerid, red, "Invalid amount!");
    format(Jstring, sizeof(Jstring), "You have set %s's Armour to '%0.2f'", GetName(id), amount);
    SendClientMessage(playerid, yellow, Jstring);
    format(Jstring, sizeof(Jstring), "Admin '%s' has set your Armour to '%0.2f'", GetName(playerid), amount);
    SendClientMessage(id, yellow, Jstring);
    SetPlayerArmour(id, amount);
    CommandToAdmins(playerid, "setarmour");
    return 1;
}
idiot_count++;