16.12.2011, 18:20
Ok so i got this on my createhouse command wich works fine without the loading part:
And the CreateEntrance thingy looks like this:
To load it i got this but i think something is wrong here:
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
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;
}
Код:
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); } }
Код:
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 added the Housing_loadall to gamemodeinit
Help please? :S