SA-MP Forums Archive
Armour not working. - 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: Armour not working. (/showthread.php?tid=642490)



Armour not working. - Clergy - 01.10.2017

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.



Re: Armour not working. - BreakStore - 01.10.2017

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;




Re: Armour not working. - Clergy - 01.10.2017

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?


Re: Armour not working. - BreakStore - 01.10.2017

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);


Re: Armour not working. - FuNkYTheGreat - 01.10.2017

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.


Re: Armour not working. - Clergy - 01.10.2017

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.


Re: Armour not working. - Sew_Sumi - 01.10.2017

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

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


Re: Armour not working. - Clergy - 01.10.2017

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.


Re: Armour not working. - RxErT - 01.10.2017

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


Re: Armour not working. - Clergy - 01.10.2017

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.