Problem with house buy
#1

Hi...I wanted to script a kind of a little house buy system....
so I did that:

Код:
enum PlayerStats
{
	housepos[256]
}
new PlayerData[MAX_PLAYERS][PlayerStats];
new h0;
forward housetime(playerid);
new houset;
OnGameModeInit....
if(dini_Int("Files/Houses/h0.sav", "Owned") == 0){
	h0 = CreatePickup(1272, 23, -260.2831,1170.5859,20.9399);
}else{
	h0 = CreatePickup(1273, 23, -260.2831,1170.5859,20.9399);
}


public OnPlayerPickUpPickup(playerid, pickupid)
{
	if(pickupid == h0){
	    new dat[256];
	    format(dat, sizeof(dat), "Files/Houses/%d.sav", pickupid);
	    new own = dini_Int(dat, "Owned");
	    if(own == 0){
	        new price, string[256], id, slots;
	        price = dini_Int(dat, "Price");
	        id = dini_Int(dat, "ID");
	        slots = dini_Int(dat, "Slots");
	        format(string, sizeof(string), "You can buy this house by typing /hbuy within 15 seconds.");
	        SendClientMessage(playerid, ORANGE, string);
	        format(string, sizeof(string), "Price: %d$ || Vehicle Slots: %d || House ID: %d", price, slots, id);
	        SendClientMessage(playerid, ORANGE, string);
	        houset = SetTimerEx("housetime", 15000, false, "i", playerid);
	        PlayerData[playerid][housepos] = pickupid;
	        return 1;
		 }else if(own == 1){
		    new string[256], id, slots, name;
		    id = dini_Int(dat, "ID");
			slots = dini_Int(dat, "Slots");
			name = dini_Int(dat, "Name");
			format(string, sizeof(string), "Owner: %s || Vehicle Slots: %d || House ID: %d", name, slots, id);
			SendClientMessage(playerid, ORANGE, string);
			return 1;
		}
	}
	return 1;
}
public housetime(playerid)
{
	PlayerData[playerid][housepos] = 999;
	return 1;
}

dcmd_hbuy(playerid, params[])
{
	#pragma unused params
	if(PlayerData[playerid][housepos] == 999){
	    SendClientMessage(playerid, DRED, "Sorry, your buy-time-period is over.");
	    return 1;
	}else{
	    new dat[256], string[256], pname[MAX_PLAYER_NAME], price, id, slots, money, log[256], acc[256];
	    format(acc, sizeof(acc), "Files/User/%s.sav", pname);
	    format(dat, sizeof(dat), "Files/Houses/%d.sav", PlayerData[playerid][housepos]);
	    price = dini_Int(dat, "Price");
	    money = GetPlayerMoney(playerid);
	    if(price <= money){
	        if(dini_Int(acc, "House") == 999){
		        KillTimer(houset);
			    GetPlayerName(playerid, pname, sizeof(pname));
				dini_IntSet(dat, "Owned", 1);
				dini_Set(dat, "Name", pname);
				slots = dini_Int(dat, "Slots");
				id = dini_Int(dat, "ID");
				format(string, sizeof(string), "You bough house %d for %d$ with %d vehicle slots. Congrulations!", id, price, slots);
				SendClientMessage(playerid, GREEN, string);
				DestroyPickup(PlayerData[playerid][housepos]);
				new Float:x, Float:y, Float:z;
				x = dini_Int(dat, "x");
				y = dini_Int(dat, "y");
				z = dini_Int(dat, "z");
				PlayerData[playerid][housepos] = CreatePickup(1273,23,x,y,z);
 				dini_Set(acc, "House", PlayerData[playerid][housepos]);
 				GivePlayerMoney(playerid, -price);
 				format(log, sizeof(log), "%s bought house %d - Slots: %d, Price: %d, ID: %d", pname, PlayerData[playerid][housepos], slots, price, id);
 				SLog(log);
 				PlayerData[playerid][housepos] = 999;
				return 1;
			}else{
			    SendClientMessage(playerid, GREY, "Sorry, the current house limit is 1.");
			}
		}else{
		    SendClientMessage(playerid, GREY, "Sorry, you don't have enough money.");
		}
	}
	return 1;
}
but it doesn't work... if I change the "Owned" in the h0.sav to 1 it still doesn't say the name...shows the info which it should show if Owned is 0
Also it always says "the current house limit is 1" however the "House" says 999 in the account file...
can anyone help me?
Reply


Messages In This Thread
Problem with House System - by Sascha - 10.08.2010, 19:25
Re: Problem with house buy - by Sascha - 11.08.2010, 08:42
Re: Problem with house buy - by Sascha - 11.08.2010, 16:38
Re: Problem with house buy - by Kar - 11.08.2010, 16:40
Re: Problem with house buy - by Sascha - 11.08.2010, 16:42
Re: Problem with house buy - by Kar - 11.08.2010, 16:44

Forum Jump:


Users browsing this thread: 1 Guest(s)