31.01.2015, 14:23
Hi,
I've been trying to make a house system, but I came across a problem which I just can't seem to solve.
So say I create a house in Idlewood, then I buy it. It works fine. But as soon as I make another house somewhere else and I try to buy it, it will put me inside the first house I made (Idlewood) and when I exit and go back to the house which wasn't working. Nothing would change. You will still be able to buy the house, I keep trying and it doesn't work.
So in short words, I make a house in Idlewood and buy it but when I make a house somewhere else and try to buy it, it won't work.
Here is the code,
I can't seem to fix it
I've been trying to make a house system, but I came across a problem which I just can't seem to solve.
So say I create a house in Idlewood, then I buy it. It works fine. But as soon as I make another house somewhere else and I try to buy it, it will put me inside the first house I made (Idlewood) and when I exit and go back to the house which wasn't working. Nothing would change. You will still be able to buy the house, I keep trying and it doesn't work.
So in short words, I make a house in Idlewood and buy it but when I make a house somewhere else and try to buy it, it won't work.
Here is the code,
pawn Код:
if(dialogid == BUY_HOUSE && response==1)
{
switch(listitem)
{
case 0:
{
new id = 0, name[25], count = 0;
if( count >= 3 )
return SendClientMessage(playerid, RED, "ERROR:{FFFFFF} You can't own more than 3 houses at a time");
if( GetPlayerMoney(playerid) < hInfo[id][Price] )
return SendClientMessage(playerid, RED, "ERROR:{FFFFFF} You do not have enough money to buy this house");
for(new i=1; i<=CreatedHouses; i++)
{
id = i;
break;
}
for(new i=1; i<=CreatedHouses; i++)
{
GetPlayerName(playerid, name, sizeof(name));
if(strcmp(name, hInfo[i][Owner]) == 0)
{
count++;
}
}
//count++;
GetPlayerName(playerid, name, 25);
hInfo[id][Owned] = 1;
hInfo[id][Owner] = name;
GivePlayerMoney( playerid, -hInfo[id][Price] );
DestroyDynamicMapIcon(hInfo[id][Icon]);
PutPlayerInHouse(playerid, id);
new
str[300],
query[400];
format(str, sizeof(str),"House Owned: Yes\nHouse Owner: %s\nHouse Price: $%i\nHouse Locked: %s", hInfo[id][Owner], hInfo[id][Price], (hInfo[id][Locked] == 1) ? ("Yes") : ("No"));
UpdateDynamic3DTextLabelText(Text3D:hInfo[id][Label], 0xFF0000FF, str);
format(query, sizeof(query), "UPDATE `"Houses_Table"` SET `Owned` = '%i', `Owner` = '%s' WHERE `ID` = '%i'",hInfo[id][Owned], hInfo[id][Owner], id);
mysql_query(query);
}
}
}