SA-MP Forums Archive
Buyable houses problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Buyable houses problem (/showthread.php?tid=208754)



Buyable houses problem - Outcast - 09.01.2011

When I put a house on a server and I try to /buy it it says that I own a house already, but I don't. Owners.ini file is empty. I can't figure this out.

This is the code:
Код:
COMMAND:buy(playerid, params[])
{
	for(new i; i<MAX_HOUSES; i++)
	{
	if(!IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ])) continue;

	new Pname[24]; GetPlayerName(playerid, Pname, 24);
	for(new S; S<MAX_HOUSES; S++)
	{
	if(!strcmp(dini_Get("Owners.ini", HouseInfo[S][HouseNames]), Pname)) return SendClientMessage(playerid, 0xF60000AA, "You already have a house!");
	}
	if(GetPlayerMoney(playerid) < HouseInfo[i][HouseCost]) return SendClientMessage(playerid, 0xF60000AA, "You don't have enough money to buy this house");
	if(HouseInfo[i][Owned] == 1) return SendClientMessage(playerid, 0xF60000AA, "This house is already owned!");
	GivePlayerMoney(playerid, - HouseInfo[i][HouseCost]);
	GameTextForPlayer(playerid, "~r~House Purchased!", 2000, 3);
	HouseInfo[i][Owned] = 1;
	GetPlayerName(playerid, Pname, 24);
	format(HouseInfo[i][HouseOwner], 24, "%s", Pname);
	dini_Set("Owners.ini", HouseInfo[i][HouseNames], Pname);
	return 1;
	}
	SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house");
	return 1;
}
please help, I'm still learning to script.