Help me with this command
#1

I have made a house system.Everything forks fine exept 1 command.

Код:
CMD:enterhouse(playerid,params[])
{
	for(new h=0;h<MAX_HOUSES+1;h++)
	{
	    if(IsPlayerInRangeOfPoint(playerid,1.0,HouseInfo[h][hEnterX],HouseInfo[h][hEnterY],HouseInfo[h][hEnterZ]))
	    {
	        SetPlayerPos(playerid,HouseInfo[h][hExitX],HouseInfo[h][hExitY],HouseInfo[h][hExitZ]);
	        SetPlayerInterior(playerid,HouseInfo[h][hInterior]);
	    }
	}
	return 1;
}
When i use this command it teleports me to the coord but it says "Unknown command".
Can someone help me to fix it please?
Reply
#2

Because HouseInfo goes out of bounds. Replace with MAX_HOUSES+1 with sizeof (HouseInfo) in the loop.
When a player is in range of a house, set their interior and position and stop the loop using break;
Reply
#3

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
Because HouseInfo goes out of bounds. Replace with MAX_HOUSES+1 with sizeof (HouseInfo) in the loop.
When a player is in range of a house, set their interior and position and stop the loop using break;
Thank you so much.

But now i have problem with this command.

Код:
CMD:buyhouse(playerid,params[])
{
    for(new h=0;h<sizeof(HouseInfo);h++)
	{
	    if(IsPlayerInRangeOfPoint(playerid,1.0,HouseInfo[h][hEnterX],HouseInfo[h][hEnterY],HouseInfo[h][hEnterZ]))
	    {
     		if(GetPlayerMoney(playerid) >= HouseInfo[h][hPrice])
       		{
         		new hpath[256];
	            format(hpath,sizeof(hpath),"/Houses/%d.ini",h);
	            dini_IntSet(hpath,"hOwned",1);
	    		dini_Set(hpath,"hOwner",GetName(playerid));
	    		PlayerHouse[playerid] = h;
	    		Delete3DTextLabel(HouseInfo[h][Label]);
				LoadHouses();
				break;
            }
	    }
    }
    return 1;
}
It dont work.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)