Unknown command?
#1

I keep getting unknown command instead of You are not near your house, It works when I enter the house and before I buy it, But after I buy it constantly unknown command if your not near it.

Код:
CMD:furniture(playerid, params[])
{
	new key = GetPlayerInOwnedHouse(playerid);
	if(GetPVarInt(playerid,"HouseKey_1") == 1000) return SendClientMessage(playerid, COLOR_LIGHTRED, "Error: You do not own a house!");
 	if(IsPlayerInRangeOfPoint(playerid, 50.0,HouseInfo[key][HouseIntPos][0],HouseInfo[key][HouseIntPos][1],HouseInfo[key][HouseIntPos][2]) && GetPlayerVirtualWorld(playerid) == HouseInfo[key][Vw])
	{
 		HouseKeyForFurniture[playerid] = key;
   		SendClientMessage(playerid, COLOR_ORANGE, "Note: Go to your house interior and type /showhouseinfo to show the Object ID's and their position to remove from");
	    SendClientMessage(playerid, COLOR_ORANGE, "Note: You must be in a range of 3.0 meters of the object *May Course lag if its more*");
		ShowPlayerDialog(playerid, HouseFurniture, DIALOG_STYLE_LIST, "Furniture Menu", "Add Furniture\nRemove Furniture by ID\nRemove Closest Furniture\nRemove All Furniture", "Continue", "Cancel");
		return 1;
	}
	else return SendClientMessage(playerid, COLOR_LIGHTRED, "Error: You are not near any of your houses!");
}

stock GetPlayerInOwnedHouse(playerid) //Get's the ID Of the closest house to the player if they are withing a range of 3.0
{
	for(new h = 0; h < MAX_OWNABLE_HOUSES+1;h++)
	{
	    new string1[128];
	    format(string1, sizeof(string1), "HouseKey_%d", h+1);
 		if(IsPlayerInRangeOfPoint(playerid, 50.0,HouseInfo[GetPVarInt(playerid,string1)][HouseIntPos][0],HouseInfo[GetPVarInt(playerid,string1)][HouseIntPos][1],HouseInfo[GetPVarInt(playerid,string1)][HouseIntPos][2]) && GetPlayerVirtualWorld(playerid) == HouseInfo[GetPVarInt(playerid,string1)][Vw])
 		{
		    return h+1;
		}
	}
	return 1;
}
crash detect plugin

Reply
#2

This means you have some kind of runtime error, I'm 99% certain "Array index out of bounds". Install and enable crashdetect plugin, then show what happens.
Reply
#3

Reply
#4

pawn Код:
//Put that somerwhere high
#define INVALID_HOUSE_ID (1000)

//And this where it was
stock GetPlayerInOwnedHouse(playerid) //Get's the ID Of the closest house to the player if they are withing a range of 3.0
{
    for(new h = 0; h < MAX_OWNABLE_HOUSES+1;h++)
    {
        new
            string1[24],
            key
        ;

        format(string1, sizeof(string1), "HouseKey_%d", h+1);
        key = GetPVarInt(playerid, string1);
       
        if (key == INVALID_HOUSE_ID) {
            continue;
        }

        if(IsPlayerInRangeOfPoint(playerid, 50.0,HouseInfo[key][HouseIntPos][0],HouseInfo[key][HouseIntPos][1],HouseInfo[key][HouseIntPos][2]) && GetPlayerVirtualWorld(playerid) == HouseInfo[key][Vw])
        {
            return h+1;
        }
    }
    //We need to return invalid ID if house is not near someone
    return INVALID_HOUSE_ID;
}
I have one recommendation though, use -1 as invalid house id, because if you want in future more than 1000 houses, you'll have to edit all invalid house ids. Also don't use "magic numbers", as you've used 1000, but define it in one place, then use it everywhere.
Reply
#5

Quote:
Originally Posted by Misiur
Посмотреть сообщение
pawn Код:
//Put that somerwhere high
#define INVALID_HOUSE_ID (1000)

//And this where it was
stock GetPlayerInOwnedHouse(playerid) //Get's the ID Of the closest house to the player if they are withing a range of 3.0
{
    for(new h = 0; h < MAX_OWNABLE_HOUSES+1;h++)
    {
        new
            string1[24],
            key
        ;

        format(string1, sizeof(string1), "HouseKey_%d", h+1);
        key = GetPVarInt(playerid, string1);
       
        if (key == INVALID_HOUSE_ID) {
            continue;
        }

        if(IsPlayerInRangeOfPoint(playerid, 50.0,HouseInfo[key][HouseIntPos][0],HouseInfo[key][HouseIntPos][1],HouseInfo[key][HouseIntPos][2]) && GetPlayerVirtualWorld(playerid) == HouseInfo[key][Vw])
        {
            return h+1;
        }
    }
    //We need to return invalid ID if house is not near someone
    return INVALID_HOUSE_ID;
}
I have one recommendation though, use -1 as invalid house id, because if you want in future more than 1000 houses, you'll have to edit all invalid house ids. Also don't use "magic numbers", as you've used 1000, but define it in one place, then use it everywhere.
still says unknown command
Reply
#6

Does anything display in server log? If yes, change inside command
pawn Код:
if(GetPVarInt(playerid,"HouseKey_1") == 1000)
to
pawn Код:
if(key == INVALID_HOUSE_ID)
Reply
#7

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Does anything display in server log? If yes, change inside command
pawn Код:
if(GetPVarInt(playerid,"HouseKey_1") == 1000)
to
pawn Код:
if(key == INVALID_HOUSE_ID)
still says unknown command and nothing displays apart from the same shit in command console.
Reply
#8

Ok, if you're using PAWNO, select "Options -> Run options", and set value of field "With these parameters" to
Quote:

-v2 -d3

Now make sure you've got latest source, and recompile. If there are still errors, they should have more information - paste it here, and paste your current code as well.
Reply
#9

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Ok, if you're using PAWNO, select "Options -> Run options", and set value of field "With these parameters" to


Now make sure you've got latest source, and recompile. If there are still errors, they should have more information - paste it here, and paste your current code as well.
Still says unknown command, It's either something in the stock or the command it self and I've tried a lot of different things now, The command works and shows the furniture menu but when your outside of house constantly unknown command.
Reply
#10

for(new h = 0; h < MAX_OWNABLE_HOUSES+1;h++)
If you have your: new HouseInfo[MAX_OWNABLE_HOUSES][e_HouseInfo] like that. The above code would give the array out of index error when getting to last loop, so I suspect that's the issue.
Solution:
for(new h = 0; h < MAX_OWNABLE_HOUSES;h++)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)