Jump to content

Adding Custom Ints


Recommended Posts

ERROR: [gameplay]\interior-system\s_interior_system.lua:88: attempt to concatenate local 'max_items' (a nil value)

Error Is Line 88

addEvent("onPlayerInteriorChange", true) 
local intTable = {} 
local safeTable = {} 
  
mysql = exports.mysql 
  
-- START OF INTERIOR SYSTEM SCRIPT 
  
-- //////////////////////////////////// 
-- //           MYSQL                // 
-- //////////////////////////////////// 
sqlUsername = exports.mysql:getMySQLUsername() 
sqlPassword = exports.mysql:getMySQLPassword() 
sqlDB = exports.mysql:getMySQLDBName() 
sqlHost = exports.mysql:getMySQLHost() 
sqlPort = exports.mysql:getMySQLPort() 
  
handler = mysql_connect(sqlHost, sqlUsername, sqlPassword, sqlDB, sqlPort) 
  
function checkMySQL() 
    if not (mysql_ping(handler)) then 
        handler = mysql_connect(sqlHost, sqlUsername, sqlPassword, sqlDB, sqlPort) 
    end 
end 
setTimer(checkMySQL, 300000, 0) 
  
function closeMySQL() 
    if (handler) then 
        mysql_close(handler) 
    end 
end 
addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), closeMySQL) 
-- //////////////////////////////////// 
-- //           MYSQL END            // 
-- //////////////////////////////////// 
  
function SmallestID( ) -- finds the smallest ID in the SQL instead of auto increment 
    local result = mysql_query(handler, "SELECT MIN(e1.id+1) AS nextID FROM interiors AS e1 LEFT JOIN interiors AS e2 ON e1.id +1 = e2.id WHERE e2.id IS NULL") 
    if result then 
        local id = tonumber(mysql_result(result, 1, 1)) or 1 
        mysql_free_result(result) 
        return id 
    end 
    return false 
end 
  
function createInterior(thePlayer, commandName, interiorId, inttype, cost, ...) 
    if (exports.global:isPlayerLeadAdmin(thePlayer)) then 
        local cost = tonumber(cost) 
        if not (interiorId) or not (inttype) or not (cost) or not (...) or ((tonumber(inttype)<0) or (tonumber(inttype)>3)) then 
            outputChatBox("SYNTAX: /" .. commandName .. " [interior ID] [TYPE] [Cost] [Name]", thePlayer, 255, 194, 14) 
            outputChatBox("TYPE 0: House", thePlayer, 255, 194, 14) 
            outputChatBox("TYPE 1: Business", thePlayer, 255, 194, 14) 
            outputChatBox("TYPE 2: Government (Unbuyable)", thePlayer, 255, 194, 14) 
            outputChatBox("TYPE 3: Rentable", thePlayer, 255, 194, 14) 
        elseif not exports.global:takeMoney(getTeamFromName("Government of Fort Carson"), cost) then 
            outputChatBox("The government can't afford this property.", thePlayer, 255, 0, 0) 
        else 
            name = table.concat({...}, " ") 
             
            local x, y, z = getElementPosition(thePlayer) 
            local dimension = getElementDimension(thePlayer) 
            local interiorwithin = getElementInterior(thePlayer) 
             
            local inttype = tonumber(inttype) 
            local owner = nil 
            local locked = nil 
             
            if (inttype==2) then 
                owner = 0 
                locked = 0 
            else 
                owner = -1 
                locked = 1 
            end 
             
            interior = interiors[tonumber(interiorId)] 
            if interior then 
                local ix = interior[2] 
                local iy = interior[3] 
                local iz = interior[4] 
                local optAngle = interior[5] 
                local interiorw = interior[1] 
                local max_items = interior[6] 
                 
                local rot = getPedRotation(thePlayer) 
                local id = SmallestID() 
                local query = mysql_query(handler, "INSERT INTO interiors SET id=" .. id .. ",x='" .. x .. "', y='" .. y .."', z='" .. z .."', type='" .. inttype .. "', owner='" .. owner .. "', locked='" .. locked .. "', cost='" .. cost .. "', name='" .. mysql_escape_string(handler, name) .. "', interior='" .. interiorw .. "', interiorx='" .. ix .. "', interiory='" .. iy .. "', interiorz='" .. iz .. "', dimensionwithin='" .. dimension .. "', interiorwithin='" .. interiorwithin .. "', angle='" .. optAngle .. "', angleexit='" .. rot .. "', max_items='" .. max_items .. "', fee=0") 
                 
                if (query) then 
                    outputChatBox("Created Interior with ID " .. id .. ".", thePlayer, 255, 194, 14) 
                    mysql_free_result(query) 
                    reloadOneInterior(id, false, false) 
                else 
                    outputChatBox("Failed to create interior - Invalid characters used in name of the interior.", thePlayer, 255, 0, 0) 
                end 
            else 
                outputChatBox("Failed to create interior - There is no such interior (" .. ( interiorID or "??" ) .. ").", thePlayer, 255, 0, 0) 
            end 
        end 
    end 
end 
addCommandHandler("addinterior", createInterior, false, false) 
  

Link to comment
Never use Valhalla script if you don't know what you're doing. It's not a simple script you know. Mabako has always made his scripts perfect so that only he can understand something from it, hehe.

I understand them just not every single bit i have converted the shodown script into a fully functioning fort carson roleplay script :D

Link to comment
Never use Valhalla script if you don't know what you're doing. It's not a simple script you know. Mabako has always made his scripts perfect so that only he can understand something from it, hehe.

I understand them just not every single bit i have converted the shodown script into a fully functioning fort carson roleplay script :D

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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