Jump to content

housing error


rpgforlife

Recommended Posts

When i do the command to make houses and press H to open the panel i get the error:

*SANS Housing Admin* An unexpected error occured. Please contact the HQ team with error number 1

who can fix this error for me please?

commands = exports.SANScommand 
  
interiorIndex = {} 
interiorIndex["No Interior"] = 0 
interiorIndex["Motel Room 1"] = 1 
interiorIndex["Motel Room 2"] = 2 
interiorIndex["Small Flat 1"] = 3 
interiorIndex["Small Flat 2 "] = 4 
interiorIndex["Small Flat 3"] = 5 
interiorIndex["Small Flat 4"] = 6 
interiorIndex["Small Flat 5"] = 7 
interiorIndex["Single Storey House 1"] = 8 
interiorIndex["Single Storey House 2"] = 9 
interiorIndex["Single Storey House 3"] = 10 
interiorIndex["Single Storey House 4 (Modern)"] = 11 
interiorIndex["Single Storey House 5 (Modern)"] = 12 
interiorIndex["Single Storey House 6 (Modern)"] = 13 
interiorIndex["Single Storey House 7 (The Crack Den)"] = 14 
interiorIndex["Single Storey House 8 (Ryders)"] = 15 
interiorIndex["Medium House 1"] = 16 
interiorIndex["Medium House 2"] = 17 
interiorIndex["Medium House 3"] = 18 
interiorIndex["Medium House 4 (Modern)"] = 19 
interiorIndex["Medium House 5 (Carl Johnsons)"] = 20 
interiorIndex["Medium House 6 (Colonel Fuhrbergers House)"] = 21 
interiorIndex["Mansion 1"] = 22 
interiorIndex["Mansion 2 (Madd Dogg's House)"] = 23 
interiorIndex["Abandoned AC Tower"] = 24 
  
typeIndex = {} 
typeIndex["House"] = 0 
typeIndex["Business"] = 1 
typeIndex["Save Icon"] = 2 
  
db = exports.SANSdatabase 
  
function startHouseCreation(thePlayer) 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup("user." ..accName, aclGetGroup("Admin")) then 
        triggerClientEvent(thePlayer, "onStartHouseCreation", getRootElement(), thePlayer) 
    end 
end 
addCommandHandler("ch", startHouseCreation) 
  
function attemptHouseCreation(name,address,housetype, interior, price,income, x,y,z, csx, csy, csz, csrx, csry, csrz) 
     local accName = getAccountName(getPlayerAccount(source)) -- get his account name 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- Does he have access to Admin functions? 
        if name and address and housetype and interior and price and income and x and y and z and csx and csy and csz and csrx and csry and csrz then 
            local typeint = typeIndex[housetype] or 0 
            local intint = interiorIndex[interior] or 0 
            local status = 1 
            if typeint == 2 then status = 0 end 
            local queryResult = executeSQLQuery("INSERT INTO `housingdata`(`name`, `address`, `type`, `interior`, `intlock`, `owner`, `price`, `value`, `income`, `status`, `x`, `y`, `z`, `csX`, `csY`, `csZ`, `csrX`, `csrY`, `csrZ`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", name ,  address ,  typeint ,  intint ,  "0" ,  "SAHousing" ,  tonumber(price) ,  tonumber(price) ,  tonumber(income) , tonumber(status) , tonumber(x) ,  tonumber(y) ,  tonumber(z) ,  tonumber(csx) ,  tonumber(csy) ,  tonumber(csz) ,  tonumber(csrx) ,  tonumber(csry) ,  tonumber(csrz)) 
            if queryResult then 
                local houseIDquery = executeSQLQuery("SELECT last_insert_rowid() FROM `housingdata`") 
                local houseID = tonumber(houseIDquery[1]["last_insert_rowid()"]) 
                local houseIcon 
                if typeint == 2 then 
                    houseIcon = createPickup(x, y, z, 3, 1277, 0) 
                    createBlipAttachedTo(houseIcon, 35, 2, 0, 0, 0, 255, 0, 250, getRootElement()) 
                elseif typeint == 1 then 
                    houseIcon = createPickup(x, y, z, 3, 1273, 0) 
                elseif typeint == 0 then 
                    houseIcon = createPickup(x, y, z, 3, 1273, 0) 
                else 
                    return false 
                end 
                setElementID(houseIcon, "housing"..houseID) 
                setElementData(houseIcon, "isHouse", true) 
                setElementData(houseIcon, "ID", houseID) 
                commands:sendMessage( "*House creation successful.", 0, 255, 0, source) 
            else 
                commands:sendMessage( "MySQL error: " .. db:errorMessage(), 255, 255, 0, source  ) 
            end 
        else 
            commands:sendMessage( "Missing variable.", 255, 255, 0, source  ) 
        end 
    else 
        outputChatBox( "You don't have permission.", 255, 0, 0, source ) 
    end 
end 
addEvent("onCreateHouseAttempt", true) 
addEventHandler("onCreateHouseAttempt", root, attemptHouseCreation) 
  
--[[-- 
function commenceHousingEdit(houseIcon) 
    if isElement(currentIcon) then 
        if getElementData(currentIcon, "isHouse") then 
                local houses = executeSQLQuery("SELECT * FROM `housingdata` WHERE `id` = ?", getElementData(currentIcon, "houseID")) 
                if #houses == 1 then 
                    local houseData = houses[1] 
                    triggerClientEvent(source, "onDisplayHousingEditMenu", houseIcon, houseData) 
                else 
                    exports.SANScommand:sendMessage("*SANS Housing Admin* An unexpected error occured. Please contact the HQ team with error number 1.",255,0,0, source) 
                end 
        else 
            exports.SANScommand:sendMessage("*SANS Housing Admin* You're not in a houseicon.",255,0,0, source) 
        end 
    else 
        exports.SANScommand:sendMessage("*SANS Housing Admin* You're not in a houseicon.",255,0,0, source) 
    end 
end 
addEvent("onCommenceHousingEdit", true) 
addEventHandler("onCommenceHousingEdit", root, commenceHousingEdit)--]]-- 

Link to comment

well, that's not hard. Just take a speak at where it goes wrong;

local houses = executeSQLQuery("SELECT * FROM `housingdata` WHERE `id` = ?", getElementData(currentIcon, "houseID")) 

If you have basic knowledge of sql, you'll know that this query is working and will return false or a row. Only if there is some actual data. Since you are using ( it's not your resource, it's from SANS ) the following line to see if the house is actually there. You'll see that it's not, so your data is corrupt. ^^

if #houses == 1 then 

Link to comment
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...