Armour not working.
#1

Armour is totally not working on my RP based script.
This is the /setarmor command:

Код:
CMD:setarmor(playerid, params[])
{
	new playa, armor;
	if(PlayerInfo[playerid][pAdmin] >= 3 || PlayerInfo[playerid][pEventModd] > 0)
	{
		if(!sscanf(params, "ui", playa, armor))
		{
			if(IsPlayerConnected(playa))
			{
				if(playa != INVALID_PLAYER_ID)
				{
					strmid(giveplayer, PlayerICName(playa), 0, MAX_PLAYER_NAME);
					SetPlayerArmour(playa, armour);
					format(str, sizeof(str), "You have set %s's armor to %d.", giveplayer, armor);
					SendClientMessage(playerid, COLOR_GREY, str);
				}
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /setarmor [playerid/PartOfName] [armor]");
		}
	}
	else
	{
		AdmErrorMsg;
	}
	return 1;
}
Is there anything wrong with the command? Plus, Like.. Armour in general ain't working wether trying to consume crack which adds armor or buy a vest. I've updated to the latest SSCANF tho. Is there anything i'm supposed to update or fix?

Thanks.
Reply
#2

Try this command:
PHP код:
CMD:setarmor(playerid,params[])
{
    new 
playa,armor;
    if(
PlayerInfo[playerid][pAdmin] <= || PlayerInfo[playerid][pEventModd] < 0) return AdmErrorMsg;
    if(
sscanf(params"ui"playaarmor)) return SendClientMessage(playeridCOLOR_GREY"{00BFFF}Usage:
   {FFFFFF} /setarmor [playerid/PartOfName] [armor]"
);
    if(
IsPlayerConnected(playa)
    {
         
strmid(giveplayerPlayerICName(playa), 0MAX_PLAYER_NAME);
     
SetPlayerArmour(playa100);
         
format(strsizeof(str), "You have set %s's armor to %d."giveplayerarmor);
     
SendClientMessage(playeridCOLOR_GREYstr);   
    }
    return 
1;

Reply
#3

Quote:
Originally Posted by BreakStore
Посмотреть сообщение
Try this command:
PHP код:
CMD:setarmor(playerid,params[])
{
    new 
playa,armor;
    if(
PlayerInfo[playerid][pAdmin] <= || PlayerInfo[playerid][pEventModd] < 0) return AdmErrorMsg;
    if(
sscanf(params"ui"playaarmor)) return SendClientMessage(playeridCOLOR_GREY"{00BFFF}Usage:
   {FFFFFF} /setarmor [playerid/PartOfName] [armor]"
);
    if(
IsPlayerConnected(playa)
    {
         
strmid(giveplayerPlayerICName(playa), 0MAX_PLAYER_NAME);
     
SetPlayerArmour(playa100);
         
format(strsizeof(str), "You have set %s's armor to %d."giveplayerarmor);
     
SendClientMessage(playeridCOLOR_GREYstr);   
    }
    return 
1;

I don't think thats right? Could you please explain?
Reply
#4

At first, I optimized the code to see if the problem was going to be solved.

You must keep this function ?
strmid(giveplayer, PlayerICName(playa), 0, MAX_PLAYER_NAME);
Reply
#5

PHP код:
CMD:setarmor(playeridparams[])
{
    new 
playaFloat:armor;
    if(
PlayerInfo[playerid][pAdmin] >= || PlayerInfo[playerid][pEventModd] > 0)
    {
        if(!
sscanf(params"uf"playaarmor))
        {
            if(
IsPlayerConnected(playa))
            {
                if(
playa != INVALID_PLAYER_ID)
                {
                    
strmid(giveplayerPlayerICName(playa), 0MAX_PLAYER_NAME);
                    
SetPlayerArmour(playaarmour);
                    
format(strsizeof(str), "You have set %s's armor to %.1f."giveplayerarmor);
                    
SendClientMessage(playeridCOLOR_GREYstr);
                }
            }
        }
        else
        {
            
SendClientMessage(playeridCOLOR_GREY"{00BFFF}Usage:{FFFFFF} /setarmor [playerid/PartOfName] [armor]");
        }
    }
    else
    {
        
AdmErrorMsg;
    }
    return 
1;

The problem was very simple, Because armor is not just a random number, It's a float, same as health.
Reply
#6

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
PHP код:
CMD:setarmor(playeridparams[])
{
    new 
playaFloat:armor;
    if(
PlayerInfo[playerid][pAdmin] >= || PlayerInfo[playerid][pEventModd] > 0)
    {
        if(!
sscanf(params"uf"playaarmor))
        {
            if(
IsPlayerConnected(playa))
            {
                if(
playa != INVALID_PLAYER_ID)
                {
                    
strmid(giveplayerPlayerICName(playa), 0MAX_PLAYER_NAME);
                    
SetPlayerArmour(playaarmour);
                    
format(strsizeof(str), "You have set %s's armor to %.1f."giveplayerarmor);
                    
SendClientMessage(playeridCOLOR_GREYstr);
                }
            }
        }
        else
        {
            
SendClientMessage(playeridCOLOR_GREY"{00BFFF}Usage:{FFFFFF} /setarmor [playerid/PartOfName] [armor]");
        }
    }
    else
    {
        
AdmErrorMsg;
    }
    return 
1;

The problem was very simple, Because armor is not just a random number, It's a float, same as health.
Not working mate. Any help would be appreciated.
Reply
#7

If you've got an anti-cheat, this could be the issue.

With anti-cheats they usually have special functions to set armor.
Reply
#8

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
If you've got an anti-cheat, this could be the issue.

With anti-cheats they usually have special functions to set armor.
Disabled, Still doesn't work.
Reply
#9

Try this one which im using it in my script:

PHP код:
CMD:setarmour(playerid,params[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 2)
    {
        new 
ID; new amount;
        if(
sscanf(params,"ui",ID,amount)) return SendClientMessage(playerid,0xf8f8f8fff,"Syntax: {F00f00}/setarmour [ID] [amount]");
        if(!
IsPlayerConnected(ID)) return SendClientMessage(playerid0xf8f8f8fff,"ERROR: {FFFFFF}Player isn't connected!");
        if(
amount || amount 100) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}Invalid amount (0 -> 100).");
        if(
PlayerInfo[ID][pAdmin] >= PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid0xf8f8f8fff,"ERROR: {FFFFFF}You can't set armour to this admin!");
        new 
string[128]; new pname[MAX_PLAYER_NAME];
        
GetPlayerName(playeridpnamesizeof(pname));
        
format(stringsizeof(string), "{f00f00}Administrator {f00f00}%s {ffa700}has set your armour amount to {f00f00}%d!",pname,amount);
        
SendClientMessage(ID,0xf8f8f8fff,string);
        
SetPlayerArmour(ID,amount);
        
SendClientMessage(playerid0xf8f8f8fff,"[ADMIN] {FFFFFF}Player armour amount has been changed!");
    }
    else
    {
    
SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;

it should work, but if it doesn't you should kill yourself
Reply
#10

Quote:
Originally Posted by RxErT
Посмотреть сообщение
Try this one which im using it in my script:

PHP код:
CMD:setarmour(playerid,params[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 2)
    {
        new 
ID; new amount;
        if(
sscanf(params,"ui",ID,amount)) return SendClientMessage(playerid,0xf8f8f8fff,"Syntax: {F00f00}/setarmour [ID] [amount]");
        if(!
IsPlayerConnected(ID)) return SendClientMessage(playerid0xf8f8f8fff,"ERROR: {FFFFFF}Player isn't connected!");
        if(
amount || amount 100) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}Invalid amount (0 -> 100).");
        if(
PlayerInfo[ID][pAdmin] >= PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid0xf8f8f8fff,"ERROR: {FFFFFF}You can't set armour to this admin!");
        new 
string[128]; new pname[MAX_PLAYER_NAME];
        
GetPlayerName(playeridpnamesizeof(pname));
        
format(stringsizeof(string), "{f00f00}Administrator {f00f00}%s {ffa700}has set your armour amount to {f00f00}%d!",pname,amount);
        
SendClientMessage(ID,0xf8f8f8fff,string);
        
SetPlayerArmour(ID,amount);
        
SendClientMessage(playerid0xf8f8f8fff,"[ADMIN] {FFFFFF}Player armour amount has been changed!");
    }
    else
    {
    
SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;

it should work, but if it doesn't you should kill yourself
It's not working!, I don't think its from the command. Its from the 'SetPlayerArmour' itself.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)