Problem with /buyhouse | Dcmd -
Tyler_Idy - 02.12.2010
When I do /buyhouse, it doesnt load the money and subtract it from the player. Its saved correctly before you ask. I know that for sure. But take a look if you think you can help.
Код:
dcmd_buyhouse(playerid,params[])
{
new pName[24], PlayerFile[50],HouseFile[50],owner[24],renter[24],housetext[250];
GetPlayerName(playerid, pName, sizeof(pName));
format(PlayerFile, sizeof(PlayerFile), "/LVRP/users/%s.ini", pName);
PlayerInfo[playerid][Money] = dini_Int(PlayerFile,"Money");
new houseid = GetHouseID(playerid);
format(HouseFile,sizeof(HouseFile),"/LVRP/houses/%d.ini",GetHouseID(playerid));
format(owner,sizeof(owner),"%s",dini_Get(HouseFile,"Owner"));
if(houseid == -255) return SendClientMessage(playerid,COLOR_RED,"You are not at a house!");
if(dini_Int(PlayerFile,"House") != 0) return SendClientMessage(playerid,COLOR_RED,"You already own a house!");
if(!strcmp(owner,"Nobody",true))
{
if(dini_Int(PlayerFile,"Money") >= dini_Int(HouseFile,"HPrice"))
{
dini_Set(HouseFile,"Owner",pName);
dini_IntSet(PlayerFile,"House",houseid);
dini_IntSet(PlayerFile,"Money",dini_Int(PlayerFile,"Money")-dini_Int(HouseFile,"HPrice"));
Delete3DTextLabel(HouseText[houseid]);
format(renter,sizeof(renter),"%s",dini_Get(HouseFile,"Renter"));
format(housetext,sizeof(housetext),"Owner: %s || Renter: %s\nPrice: $%d || Rent: $%d\nHouseID: %d",pName,renter,HouseInfo[houseid][HPrice],HouseInfo[houseid][Rent],houseid);
HouseText[houseid] = Create3DTextLabel(housetext,COLOR_LIGHTBLUE,dini_Float(HouseFile,"OutX"),dini_Float(HouseFile,"OutY"),dini_Float(HouseFile,"OutZ"),30.0,0,1);
}
else return SendClientMessage(playerid,COLOR_RED,"NOT ENOUGH MONEY!");
}
else return SendClientMessage(playerid,COLOR_RED,"THIS HOUSE IS ALREADY OWNED!");
return 1;
#pragma unused params
}
Re: Problem with /buyhouse | Dcmd -
Jochemd - 02.12.2010
Well I think it's just cause you haven't used GivePlayerMoney... You only write it.
Re: Problem with /buyhouse | Dcmd -
Tyler_Idy - 03.12.2010
Well its not needed. when you do /stats it says the same amount, plus. I have a timer that sets the players money back to what its supposed to. To stop confusion from time to time.
Re: Problem with /buyhouse | Dcmd -
Tyler_Idy - 03.12.2010
__bump__
Re: Problem with /buyhouse | Dcmd -
Ash. - 03.12.2010
pawn Код:
dini_IntSet(PlayerFile,"Money",dini_Int(PlayerFile,"Money")-dini_Int(HouseFile,"HPrice"));
- All you're doing here, is saving the money to file, you arent actually doing the "GivePlayerMoney" etc part...
Try this (under the line above)
pawn Код:
GivePlayerMoney(playerid, -dini_Int(HouseFile, "HPrice"));
Re: Problem with /buyhouse | Dcmd -
Tyler_Idy - 04.12.2010
The dumb thing is though. Its not saving the money to the file.... I dont know why. Did I do something wrong?