0

所以我在为 Garrys mod 制作插件时遇到了这个错误,我已经尝试了一段时间,但不能完全弄清楚这个错误:

[错误] addons/ted_stockmarket/lua/autorun/server/stockmarket_init.lua:6: 尝试调用布尔值 1. loadcompany - addons/ted_stockmarket/lua/autorun/server/stockmarket_init.lua:6 2. 未知 - addons/ ted_stockmarket/lua/autorun/server/stockmarket_init.lua:20 3. 未知 - lua/includes/modules/concommand.lua:54

文件是完整的,所以行号是准确的,在 pastebin 上做,因为我现在无法弄清楚这个格式。代码有点乱,我有一段时间没碰过,文件中的一半东西肯定会被替换

include("stockmarketprices.lua")
include("stockmarket_config.lua")

local function loadcompany(cmp)

if cmp != nil and sql.TableExists("stockmarket_sharedata") then sql.Query("INSERT INTO stockmarket_sharedata (Companyshort, Company, Shares, Value) VALUES ('"..cmp[2]..", "..cmp[3]..", "..cmp[4]..", "..cmp[5])"')"


end
end

local function test()

    if !sql.TableExists(stockmarket_sharedata) then
        print("Stock market performing initial load...")
        sql.Query( "CREATE TABLE stockmarket_sharedata ( Companyshort string not null, Company string not null, Shares string not null, Value int not null, Rate decimal not null)" )

        print("Stock market done loading, restart your server to apply changes.")
    end
    if stock1[1] == 1 then loadcompany(stock1)
        print(stock1[3].." is done loading!")
        end
end
hook.Add("Initialize", "First Load", test)

function sharepricechange(shortname, chance, low, high, direction)
if math.random(1, 100) <= chance then shortname.marketbump = math.random(low, high) end


end



hook.Add( "PlayerSay", "chatcommands", function( ply, text )
    local text = string.lower( text )
    local amount = tonumber(string.sub(text, 16))
    local shares = tonumber(file.Read("stockmarket/lifeinsuranceshrs.txt"))

        if  string.sub(text, 1, 14) == "/buyshares ins" and amount <= shares then
            file.Write("stockmarket/lifeinsuranceshrs.txt", ((tonumber(file.Read("stockmarket/lifeinsuranceshrs.txt"))) - tonumber(string.sub(text, 16))))
            print("You have invested! There are now "..file.Read("stockmarket/lifeinsuranceshrs.txt").. " shares left for life insurance")
        else end

        if text == "/stockmarkethelp" then
            ply:PrintMessage(HUD_PRINTCONSOLE, [[ /buyshares "company" "amount" - Purchase a specified amount of shares from a specified company.
            /stockmarket - Prints all information about the stock market in console.]])
        return("") end

end)

function ResetStockmarket(ply)
if ply:IsUserGroup("superadmin") then
local files, directories = file.Find( "*", "DATA")
print(files[1])
file.Delete("stockmarket")end
if !ply:IsUserGroup("superadmin") then ply:PrintMessage( HUD_PRINTCONSOLE, "You are not the right rank to use this command" )
end
end

concommand.Add( "stockmarket_reset", ResetStockmarket)
concommand.Add( "stockmarket_test", test)

pastebin.com/ERFfnbMc

stock1 = { -- DO NOT CHANGE THE TABLE IDENTIFIER
1, -- First line, determine whether or not you want this company to work
"FLN", -- The shortname of the company, keep 3 letters for consistency
"Flynn's Funerals", -- The name of the company
10000, -- The default amount of shares avaliable
94, -- The starting price of each share
0 -- The rate of the shares change in value, do not touch this.
}

pastebin.com/jbJseUWC

4

0 回答 0