This wont get the armour correctly.
#1

As the title says. it always returns the "you don't have this much armour" unless the value is 1. and then it puts some random amount.

pawn Код:
if(!strcmp(item, "armour", true))
            {
                HouseArmour[houseid] = MySQL_GetValue(houseid, "HouseArmour", "houses");
                PlayerArmour[playerid] = GetPlayerArmour(playerid, PlayerArmour[playerid]);
                if(sscanf(params, "s[24]s[32]d",usage,item,slot))
                {
                    SendClientMessage(playerid, COLOUR_GREY, "Usage: /house store armour [amount]");
                    return 1;

                }
                if(slot < 1 || slot > 100)return SendClientMessage(playerid, COLOUR_GREY, "Amount must be between 0 and 100");
                if(slot > PlayerArmour[playerid]) return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much armour");
                HouseArmour[houseid] = HouseArmour[houseid] += slot;
                PlayerArmour[playerid] = PlayerArmour[playerid] -= slot;
                SetPlayerArmour(playerid, -PlayerArmour[playerid]);
                MySQL_SetFloat(houseid, "HouseArmour", HouseArmour[houseid], "houses");
                MySQL_SetFloat(PlayerSQLID[playerid], "Armour", PlayerArmour[playerid], "accounts");
                format(string, sizeof(string), "You have stored %d of armour, you now have a total of: %d armour in your house", slot, HouseArmour[houseid]);
                SendClientMessage(playerid, COLOUR_BLUE, string);
                format(string, sizeof(string), "* %s has stored some armour in their house.", GetNameEx(playerid));
                ProxDetector(30.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
            }
Reply
#2

See if this works for you... I'm surprised you didn't get any errors.

pawn Код:
if(!strcmp(item, "armour", true))
{
    HouseArmour[houseid] = MySQL_GetValue(houseid, "HouseArmour", "houses");
    PlayerArmour[playerid] = GetPlayerArmour(playerid);

    if(sscanf(params, "s[24]s[32]d",usage,item,slot))
    {
        SendClientMessage(playerid, COLOUR_GREY, "Usage: /house store armour [amount]");
        return 1;
    }
   
    if(slot < 1 || slot > 100)
        return SendClientMessage(playerid, COLOUR_GREY, "Amount must be between 0 and 100");
    if(slot > PlayerArmour[playerid])
        return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much armour");
       
    HouseArmour[houseid] = HouseArmour[houseid] += slot;
    PlayerArmour[playerid] = PlayerArmour[playerid] -= slot;
    SetPlayerArmour(playerid, -slot);

    MySQL_SetFloat(houseid, "HouseArmour", HouseArmour[houseid], "houses");
    MySQL_SetFloat(PlayerSQLID[playerid], "Armour", PlayerArmour[playerid], "accounts");

    format(string, sizeof(string), "You have stored %d of armour, you now have a total of: %d armour in your house", slot, HouseArmour[houseid]);
    SendClientMessage(playerid, COLOUR_BLUE, string);
    format(string, sizeof(string), "* %s has stored some armour in their house.", GetNameEx(playerid));
    ProxDetector(30.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
}
Reply
#3

Change

pawn Код:
PlayerArmour[playerid] = GetPlayerArmour(playerid, PlayerArmour[playerid]);
to

pawn Код:
GetPlayerArmour(playerid, PlayerArmour[playerid]);

GetPlayerArmour returns 1 at the end of all of the action it does. So after setting the variable specified in the second parameter to the player's armor, if you have Variable = GetPlayerArmour it will set the value of the variable to the return value of the function, which is 1.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)