16.09.2016, 08:50
why each I /createhouse, in id the house is always 0? how to order the house next id in /createhouse?
PHP код:
CMD:createhouse(playerid, params[])
{
if(pAdmin[playerid] < 4)
return Error(playerid, "You are not authorized to use this command!");
if(GetPlayerInterior(playerid) != 0)
return Error(playerid, "You can't create houses on any interior other than 0.");
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(Iter_Count(Houses) > MAX_HOUSES) return ShowInfoBoxEx(playerid, COLOR_SYSTEM, ""WHITE_E"Max limit of houses reached!");
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_query(query, false, "OnHouseCreate", "ifffffffii", playerid, Xp, Yp, Zp, (180.0 + Angle), X, Y, Zp, hint, cost);
}
return 1;
}
forward OnHouseCreate(playerid, Float:inX, Float:inY, Float:inZ, Float:outA, Float:outX, Float:outY, Float:outZ, interiorID, cost);
public OnHouseCreate(playerid, Float:inX, Float:inY, Float:inZ, Float:outA, Float:outX, Float:outY, Float:outZ, interiorID, cost)
{
new h = cache_insert_id();
new labeltext[300];
printf("A_I value of the newly entered house: %d", h);
hInfo[h][CPOutX] = inX, hInfo[h][CPOutY] = inY, hInfo[h][CPOutZ] = inZ;
hInfo[h][SpawnOutX] = outX, hInfo[h][SpawnOutY] = outY, hInfo[h][SpawnOutZ] = outZ, hInfo[h][SpawnOutAngle] = outA;
hInfo[h][HouseInterior] = interiorID;
format(hInfo[h][HousePassword], 28, "%s", "INVALID_HOUSE_PASSWORD");
format(hInfo[h][HouseName], 28, "%s", DEFAULT_HOUSE_NAME);
format(hInfo[h][HouseOwner], 24, "%s", INVALID_HOWNER_NAME);
format(hInfo[h][HouseLocation], 30, "%s", GetHouseLocation(h));
hInfo[h][HouseValue] = cost, hInfo[h][HouseStorage] = 0, hInfo[h][HouseForSale] = 0;
format(labeltext, sizeof(labeltext), LABELTEXT1, DEFAULT_HOUSE_NAME, ToCurrency(cost), h);
HouseMIcon[h] = CreateDynamicMapIcon(inX, inY, inZ, 31, -1, -1, -1, -1, MICON_VD);
HouseLabel[h] = CreateDynamic3DTextLabel(labeltext, COLOR_GREEN, inX, inY, inZ+0.7, TEXTLABEL_DISTANCE, .testlos = 1);
HousePickupOut[h] = CreateDynamicPickup(PICKUP_MODEL_OUT, PICKUP_TYPE, inX, inY, inZ, -1, -1, -1, 30.0);
HousePickupInt[h] = CreateDynamicPickup(PICKUP_MODEL_INT, PICKUP_TYPE, hIntInfo[interiorID][IntCPX], hIntInfo[interiorID][IntCPY], hIntInfo[interiorID][IntCPZ], (h + 1000), hIntInfo[interiorID][IntInterior], -1, 15.0);
ShowInfoBox(playerid, I_H_CREATED, h);
format(str, sizeof(str), "Server: "GREY2_E"House ID "GREY_E"[%d] "GREY2_E"created!", h);
SendClientMessage(playerid, COLOR_RED, str);
Iter_Add(Houses, h);
format(query, sizeof(query), "UPDATE houses SET hlocation='%s',hint=%d WHERE house_id=%d", hInfo[h][HouseLocation], interiorID, h);
MySQL_updateQuery(query);
return 1;
}