House load problem i guess
#1

Ok so i got this on my createhouse command wich works fine without the loading part:
pawn Код:
COMMAND:createhouse(playerid, params[])
{
    new string[128], Float:X, Float:Y, Float:Z, HouseID, HPrice, string2[128];
    format(string, sizeof(string), "SELECT HouseID, Houseprice, Houseowner, X, Y, Z FROM Houses WHERE HouseID = '%i'", AHouseData[HouseID]);
    mysql_query(string);
    mysql_store_result();
    if (sscanf(params, "i", HPrice)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/createhouse <price>\"");
    else
    {
        // Find the first free HouseID
        for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
            if (AHouseData[HouseID][PickupID] == 0) // Check if an empty house-index has been found (PickupID is 0)
                break; // Stop searching, the first free HouseID has been found now


        if(HouseID < MAX_HOUSES)
        {
            GetPlayerPos(playerid, X, Y, Z);
            AHouseData[HouseID][HouseX] = X;
            AHouseData[HouseID][HouseY] = Y;
            AHouseData[HouseID][HouseZ] = Z;
            AHouseData[HouseID][Owned] = false;
            AHouseData[HouseID][Houseprice] = HPrice;
            House_CreateEntrance(HouseID);
        }
        format(string2, sizeof(string2), "INSERT INTO Houses (HouseID, X, Y, Z, Owned, Houseprice) VALUES ('%i', '%f', '%f', '%f', '%s', '%i')",HouseID, AHouseData[HouseID][HouseX],AHouseData[HouseID][HouseY],AHouseData[HouseID][HouseZ], AHouseData[HouseID][Owned], AHouseData[HouseID][Houseprice]);
        mysql_query(string2);
    }
    mysql_free_result();
    return 1;
}
And the CreateEntrance thingy looks like this:
Код:
House_CreateEntrance(HouseID)
{
	
	// Setup local variables
	new Msg[128], Float:x, Float:y, Float:z;

	// Get the coordinates of the house's pickup (usually near the door)
	x = AHouseData[HouseID][HouseX];
	y = AHouseData[HouseID][HouseY];
	z = AHouseData[HouseID][HouseZ];
	
	if (AHouseData[HouseID][Owned] == true)
	{
	 	AHouseData[HouseID][PickupID] = CreateDynamicPickup(1272, 1, x, y, z, 0);
	}
	else
	{
        // Create a green house-pickup (house is free)
		AHouseData[HouseID][PickupID] = CreateDynamicPickup(1273, 1, x, y, z, 0);
		// Create the 3DText that appears above the house-pickup (displays the price of the house)
		format(Msg, 128, "{00FF00}House available for\n$%i\n/buyhouse", AHouseData[HouseID][Houseprice]);
		AHouseData[HouseID][DoorText] = CreateDynamic3DTextLabel(Msg, 0x008080FF, x, y, z + 1.0, 50.0);
		// Add a streamed icon to the map (green house), type = 31, color = 0, world = 0, interior = 0, playerid = -1, drawdist = 150.0
		AHouseData[HouseID][MapIconID] = CreateDynamicMapIcon(x, y, z, 31, 0, 0, 0, -1, 150.0);
	}

}
To load it i got this but i think something is wrong here:
Код:
new TotalHouses;
Housing_LoadAll()
{
	new string[128], HouseID;
	format(string, sizeof(string), "SELECT `HouseID` = '%i' FROM Houses", HouseID);
	mysql_query(string);
	mysql_store_result();
	// Loop through all houses and try to load them
	for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
	{
	    // Try to load the file and check if it was succesfully loaded (file exists)
		if (HouseFile_Load(HouseID) == 1)
		{
			// Add a pickup and 3DText for this house
			House_CreateEntrance(HouseID);
			// Count the amount of houses that are loaded
		    TotalHouses++;
		}
	}
	return 1;
}
// This function will load the house's datafile (used when the server is started to load all houses)
HouseFile_Load(HouseID)
{
	return 1;
	
}
I know HouseFile_Load is empty but why command isnt working when this is added
I added the Housing_loadall to gamemodeinit
Help please? :S
Reply
#2

Quote:
Originally Posted by belhot1992
Посмотреть сообщение
Your Housing_LoadAll function is not working because first you forgot to set a public for it
What the hell? Stop giving out totally wrong information! A function only ever needs to be declared public if it has to be called by the server itself (native callbacks), a timer or CallLocal/RemoteFunction. In any other case you can declare a function just fine without a keyword.
Reply
#3

Anyone knows How to LOAD the houses? :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)