myhouses shows all houses -
ThatFag - 29.08.2016
hej there
im having a bug currently on my gamemode
it worked well before but now when i press /myhouses it shows all server houses and not my owned one
and idea and how to fix it please help me i really need this
here are codes
Код:
COMMAND:myhouses(playerid)
{
new
tmp[20];
SendClientMessage(playerid, COLOR_WHITE, "{004080}====================== Your Houses: ===========================");
//SendClientMessage(playerid, COLOR_WHITE, "There are the houses you own:");
for(new i; i < sizeof(House); i++)
{
format(tmp, sizeof(tmp), "Casa%d.txt", i);
if(!strcmp(House[i][tmpowner], PlayerName(playerid), false))
{
new zone[ 32 ];
GetZone(House[i][House_x],House[i][House_y],House[i][House_z], zone);
format(iStr, sizeof(iStr), "[ID: %d] [Rent Price: %s] [Till: %d] [Location: %s]", i, AddCommasToInt(dini_Int(tmp, "rentprice")), dini_Int(tmp, "till"), zone);
SendClientMessage(playerid, COLOR_LIGHTGREY, iStr);
}
}
SendClientMessage(playerid, COLOR_WHITE, "{004080}=====================================================");
return 1;
}
Re: myhouses shows all houses -
Konstantinos - 29.08.2016
All houses or those which are not owned by anyone?
PHP код:
COMMAND:myhouses(playerid)
{
SendClientMessage(playerid, COLOR_WHITE, "{004080}====================== Your Houses: ===========================");
new p_name[MAX_PLAYER_NAME], zone[32], tmp[20];
GetPlayerName(playerid, p_name, MAX_PLAYER_NAME);
for (new i; i < sizeof(House); i++)
{
if (!House[i][tmpowner][0]) continue; // if the string is empty (no owner), skip it
if (!strcmp(House[i][tmpowner], PlayerName(playerid), false))
{
GetZone(House[i][House_x], House[i][House_y], House[i][House_z], zone);
format(tmp, sizeof(tmp), "Casa%d.txt", i);
format(iStr, sizeof(iStr), "[ID: %d] [Rent Price: %s] [Till: %d] [Location: %s]", i, AddCommasToInt(dini_Int(tmp, "rentprice")), dini_Int(tmp, "till"), zone);
SendClientMessage(playerid, COLOR_LIGHTGREY, iStr);
}
}
SendClientMessage(playerid, COLOR_WHITE, "{004080}=====================================================");
return 1;
}
Re: myhouses shows all houses -
ThatFag - 29.08.2016
Its only unowned houses - testing the codes
Re: myhouses shows all houses -
ThatFag - 29.08.2016
it worked
but when i use command buyhouse it says that i own more than 10 houses
even if i dont
code of buyhouse
Код:
COMMAND:buyhouse(playerid, params[])
{
new tmpid=IsPlayerOutHouse(playerid);
if(tmpid == -1) return SendClientError(playerid, "You are not standing at any house!");
if(GetPlayerHouses(playerid) >= 10 && PlayerInfo[playerid][premium] == 0) return SendClientError(playerid, "You cannot own more than 10 houses unless are a donator.");
if(GetPlayerHouses(playerid) >= 14) return SendClientError(playerid, "You cannot own more then 13 houses.");
new filename[ 20 ];
format(filename, 20, "Casa%d.txt", tmpid);
if(!dini_Int(filename, "buyable")) return SendClientError(playerid, "This house is not on sale!");
new fullprice = dini_Int(filename, "fullprice");
if(HandMoney(playerid) < fullprice) return SendClientError(playerid, "You don't have enough money on your hand!");
SetBank(PlayerName(playerid),House[tmpid][tmpowner],fullprice);
dini_Set(filename,"owner",PlayerName(playerid));
dini_IntSet(filename, "buyable", 0);
SendClientMSG(playerid, COLOR_GREEN, "[HOUSE] Congratulations, you have bought house ID #%d! (Screenshot: F8)", tmpid);
format(iStr, sizeof(iStr), "6[HOUSE] %s has bought a house (ID: #%d) for $%d from %s.", PlayerName(playerid), tmpid, fullprice, House[tmpid][tmpowner]);
iEcho(iStr);
AppendTo(moneylog, iStr);
myStrcpy(House[tmpid][tmpowner],PlayerName(playerid));
UpdateHouse(tmpid);
return 1;
}
and a question
i got a faction systen in dini now when a player uninvite someone from faction and if he presses /factionoffline
the uninvited member is still there
is there any way to update dini file for example when a player gets uninvited he will be removed from list too ??
Re: myhouses shows all houses -
Konstantinos - 29.08.2016
In GetPlayerHouses you check with strcmp if the player's name is equal to "tmpowner" again, right? You need to make sure that it's not empty before comparing like:
pawn Код:
if (!House[i][tmpowner][0]) continue;
if (!strcmp(...)
{
// equal..
}
About your question, you want to remove the line? I think there is something like dini unset but I'm not sure as I haven't used dini. You might be interested in these:
http://forum.sa-mp.com/showpost.php?...1&postcount=16
http://forum.sa-mp.com/showpost.php?...postcount=3000
http://forum.sa-mp.com/showpost.php?...postcount=3318
Re: myhouses shows all houses -
ThatFag - 29.08.2016
Worked Thanks to you