Problem with /buyhouse | Dcmd
#1

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
}
Reply
#2

Well I think it's just cause you haven't used GivePlayerMoney... You only write it.
Reply
#3

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.
Reply
#4

__bump__
Reply
#5

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"));
Reply
#6

The dumb thing is though. Its not saving the money to the file.... I dont know why. Did I do something wrong?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)