23.03.2016, 09:47
Well, here's my code
Here's where I load the houses
and this
I'm using BlueG's Latest MySQL plugin. The thing is that the code above does create the house at the particular moment. but the house is not saved in the Database nor it is present there after restarting the server!
I've recently updated my MySQL plugin, before updating it was working fine, but after updating its not.
The old houses that were created before this update of plugin are loading properly. I would really be waiting for your replies.
Thanks
pawn Код:
CMD:createhouse(playerid, params[])
{
if(pAdmin[playerid] < 5)
return Error(playerid, "You are not authorized to use this command!");
new cost, hint;
new Float:X, Float:Y, Float:Z;
if(sscanf(params, "iD(0)", cost, hint)) return ShowInfoBoxEx(playerid, COLOR_SYSTEM, E_CMD_USAGE_CREATEHOUSE);
if(hint < 0 || hint > MAX_HOUSE_INTERIORS) return ShowInfoBoxEx(playerid, COLOR_SYSTEM, E_INVALID_HINT);
if(cost < MIN_HOUSE_VALUE || cost > MAX_HOUSE_VALUE) return ShowInfoBoxEx(playerid, COLOR_SYSTEM, E_INVALID_HVALUE);
else
{
// Set a random interior if not specified.
if(hint == 0)
{
hint = random(10);
}
GetPlayerPos(playerid, Xp, Yp, Zp);
GetPlayerFacingAngle(playerid, Angle);
new interior = GetPlayerInterior(playerid);
GetPlayerPos(playerid, X, Y, Z);
GetPosInFrontOfPlayer(playerid, X, Y, -2.5);
format(query, sizeof(query), "INSERT INTO houses(house_id,hname,howner,hpass,x,y,z,a,cpx,cpy,cpz,hint,hvalue) VALUES(0,'House For Sale!','INVALID_PLAYER_ID','INVALID_HOUSE_PASSWORD', %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %d, %d)", X, Y, Zp, (180.0 + Angle), Xp, Yp, Zp, interior, cost);
mysql_tquery(cHandle, query,"OnHouseCreate", "ifffffffdd", playerid, Xp, Yp, Zp, (180.0 + Angle), X, Y, Zp, hint, cost);
}
return 1;
}
pawn Код:
function LoadHouseData()
{
new count;
cache_get_data(rows, fields);
if(!rows)
{
// House doesn't exist
}
else
{
for(new h; h < rows; h++)
{
// Proceed loading house data.
h_id = cache_get_row_int(h, 0);
cache_get_row(h, 1, hInfo[h][HouseName]);
cache_get_row(h, 2, hInfo[h][HouseOwner]);
cache_get_row(h, 3, hInfo[h][HouseLocation]);
cache_get_row(h, 4, hInfo[h][HousePassword]);
hInfo[h][SpawnOutX] = cache_get_row_float(h, 5);
hInfo[h][SpawnOutY] = cache_get_row_float(h, 6);
hInfo[h][SpawnOutZ] = cache_get_row_float(h, 7);
hInfo[h][SpawnOutAngle] = cache_get_row_float(h, 8);
hInfo[h][CPOutX] = cache_get_row_float(h, 9);
hInfo[h][CPOutY] = cache_get_row_float(h, 10);
hInfo[h][CPOutZ] = cache_get_row_float(h, 11);
hInfo[h][HouseValue] = cache_get_row_int(h, 12);
hInfo[h][HouseStorage] = cache_get_row_int(h, 13);
hInfo[h][HouseInterior] = cache_get_row_int(h, 14);
hInfo[h][HousePrivacy] = cache_get_row_int(h, 15);
// Create House Pickup
HousePickupOut[h_id] = CreateDynamicPickup(PICKUP_MODEL_OUT, PICKUP_TYPE, hInfo[h_id][CPOutX], hInfo[h_id][CPOutY], hInfo[h_id][CPOutZ], 0, 0, -1, 20.0);
CreateCorrectHouseExitCP(h_id);
new labeltext[300];
if(!strcmp(hInfo[h_id][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE))
{
format(labeltext, sizeof(labeltext), LABELTEXT1, hInfo[h_id][HouseName], hInfo[h_id][HouseValue], h_id);
HouseMIcon[h_id] = CreateDynamicMapIcon(hInfo[h_id][CPOutX], hInfo[h_id][CPOutY], hInfo[h_id][CPOutZ], 31, -1, 0, 0, -1, MICON_VD);
}
else if(strcmp(hInfo[h_id][HouseOwner], INVALID_HOWNER_NAME, CASE_SENSETIVE))
{
format(labeltext, sizeof(labeltext), LABELTEXT2, hInfo[h_id][HouseName], hInfo[h_id][HouseOwner], hInfo[h_id][HouseValue], Answer(hInfo[h_id][HousePrivacy], "Open", "Closed"), h_id);
HouseMIcon[h_id] = CreateDynamicMapIcon(hInfo[h_id][CPOutX], hInfo[h_id][CPOutY], hInfo[h_id][CPOutZ], 32, -1, 0, 0, -1, MICON_VD);
}
HouseLabel[h_id] = CreateDynamic3DTextLabel(labeltext, COLOR_GREEN, hInfo[h_id][CPOutX], hInfo[h_id][CPOutY], hInfo[h_id][CPOutZ]+0.7, TEXTLABEL_DISTANCE, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, TEXTLABEL_TESTLOS, 0, 0, -1, TEXTLABEL_DISTANCE);
Iter_Add(Houses, h);
count++;
}
// DEBUG
printf("UoS: %d houses loaded!", count);
}
return 1;
}
pawn Код:
stock LoadHouses()
{
LoadHouseInteriors(); // Load house interiors
format(query, sizeof(query), "SELECT house_id,hname,howner,hlocation,hpass,x,y,z,a,cpx,cpy,cpz,hvalue,hstorage,hint,hprivacy FROM houses");
mysql_tquery(cHandle, query, "LoadHouseData", "", 0);
}
I've recently updated my MySQL plugin, before updating it was working fine, but after updating its not.
The old houses that were created before this update of plugin are loading properly. I would really be waiting for your replies.
Thanks