----------------------------------------->>
-- Grand Theft International (GTi)
-- Author: JT Pennington (JTPenn)
-- Date: 08 Jul 2014
-- Resource: GTIrules/rules.Lua
-- Version: 1.0
----------------------------------------->>
local font = "default"
local quickSelect = {}
--[[
addEventHandler("onClientResourceStart", resourceRoot, function()
font = guiCreateFont("courier.ttf")
end)
--]]
-- Create Rules Panel
----------------------->>
function createRulesPanel(rules)
-- Delete if Already Exists
if (isElement(window)) then
closePanel("left", "up")
return
end
-- Load Rules Data
--local rules = string.gsub(rules, "%(", "%{")
--local rules = string.gsub(rules, "%)", "%}")
loadedData, loadFail = loadstring(tostring(rules))
if (loadFail) then
outputChatBox("GTI Rules failed to load. The rules file is not configured correctly.", 255, 0, 0)
outputChatBox(loadFail, 255, 0, 0)
return false
end
loadedData()
-- Create Window
local sX, sY = guiGetScreenSize()
local wX, wY = 700, 500
local sX, sY, wX, wY = (sX/2)-(wX/2),(sY/2)-(wY/2),wX,wY
-- sX, sY, wX, wY = 437, 182, 700, 500
window = guiCreateWindow(sX, sY, wX, wY, "RPG City Regras & Ajuda", false)
guiWindowSetSizable(window, false)
guiSetAlpha(window, 1.00)
gridlist = guiCreateGridList(9, 24, 225, 467, false, window)
guiGridListAddColumn(gridlist, "Manual de Instrução", 0.9)
guiGridListSetSortingEnabled(gridlist, false)
--
addEventHandler("onClientGUIClick", gridlist, updateDocumentation, false)
-- Create the Gridlist Items
quickSelect = {}
local curr_sec
for _,tbl in ipairs(documents) do
if (not tbl[2]) then
local row = guiGridListAddRow(gridlist)
guiGridListSetItemText(gridlist, row, 1, tbl[1], true, false)
guiGridListSetItemColor(gridlist, row, 1, 215, 25, 25)
else
local row = guiGridListAddRow(gridlist)
guiGridListSetItemText(gridlist, row, 1, tbl[1], false, false)
quickSelect[row] = tbl[2]
end
end
memo = guiCreateMemo(241, 24, 450, 437, "Bem vindo/a ao RPG City Reallife. Use o menu á esquerda para navegar pela documentação do servidor.\n\nRegras do Servidor:\n\n"..theRules["English"], false, window)
guiSetFont(memo, font)
guiMemoSetReadOnly(memo, true)
button = guiCreateButton(506, 467, 185, 23, "Fechar", false, window)
--
addEventHandler("onClientGUIClick", button, closePanel, false)
showCursor(true)
end
addEvent("GTIrules.createRulesPanel", true)
addEventHandler("GTIrules.createRulesPanel", root, createRulesPanel)
-- Panel Functions
------------------->>
function togglePanel()
if (not exports.GTIaccounts:isPlayerLoggedIn()) then return end
if (isElement(window) and not guiGetVisible(window)) then
guiSetVisible(window, true)
showCursor(true)
elseif (isElement(window)) then
closePanel("left", "up")
else
triggerServerEvent("GTIrules.getHelpFile", resourceRoot)
end
end
bindKey("F9", "down", togglePanel)
addCommandHandler("rules", togglePanel)
function closePanel(btn, state)
if (btn ~= "left" or state ~= "up") then return end
guiSetVisible(window, false)
showCursor(false)
destroyElement(window)
end
function updateDocumentation(btn, state)
if (btn ~= "left" or state ~= "up") then return end
local row = guiGridListGetSelectedItem(gridlist)
if (not row or row == -1) then return end
guiSetText(memo, quickSelect[row])
end
The function createRulesPanel wont works for me, im trying for a days to make this works, but im failed, so i coming here and ask @ all if you can help me a little...
The connection to the rules.txt file its successfull established but instead to draw the window, the function try to print the rules.txt out ti the outputbox chat... like this:
* Rules not yet downloaded. Press F9 again.
GTI Rules failed to load. The rules file is not configured correctly.
[string "Art 1° - Não praticar Power Gaming: Mínimo (10H) Máximo(24H..."]:1: '=' expected near '1'
Thx in advance and sorry for my bad english...