17.12.2011, 19:10
Ok so i got this:
So everytime i use it it returns SERVER: Unkown Command. But when i dont put in the houseprice variable it returns the sscanf thingy. Anyone can see the problem? :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'", UserStats[playerid][Name]);
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;
}
stock 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);
}
return 1;
}