SA-MP Forums Archive
Help me with this command - 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: Help me with this command (/showthread.php?tid=661660)



Help me with this command - scripter112 - 10.12.2018

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?


Re: Help me with this command - Calisthenics - 10.12.2018

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;


Re: Help me with this command - scripter112 - 10.12.2018

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.