Jump to content

Error for making spawn script[URGENT STILL NEED ANSWER


Exile

Recommended Posts

I have a working spawn system,it spawns and everything but the GUI dosen't disappear after I press spawn,here's the spawn_client

local localPlayer = getLocalPlayer()

local resX, resY = guiGetScreenSize()

local startX = resX * (2 / 3)

local startY = 0

local windowX = resX * (1 / 5)

local windowY = resY

local xml = xmlLoadFile("spawns.xml") -- open the XML file

local cityNodes = xmlNodeGetChildren(xml) -- get all child nodes of the root node ()

local cities = {} -- create a new global variable to store the welcome messages

for i,node in ipairs(cityNodes) do

cityname = xmlNodeGetAttribute(node, "name")

local classnodes = xmlNodeGetChildren(node)

cities[cityname] = {}

for i2,node2 in ipairs(classnodes) do

classname = xmlNodeGetAttribute(node2, "name")

local spawnnodes = xmlNodeGetChildren(node2)

cities[cityname][classname] = {}

for i3, node3 in ipairs(spawnnodes) do

skinName = xmlNodeGetAttribute(node3, "name")

cities[cityname][classname][skinName] = {}

cities[cityname][classname][skinName]["spawnX"] = xmlNodeGetAttribute(node3, "spawnX")

cities[cityname][classname][skinName]["spawnY"] = xmlNodeGetAttribute(node3, "spawnY")

cities[cityname][classname][skinName]["spawnZ"] = xmlNodeGetAttribute(node3, "spawnZ")

cities[cityname][classname][skinName]["r"] = xmlNodeGetAttribute(node3, "r")

cities[cityname][classname][skinName]["g"] = xmlNodeGetAttribute(node3, "g")

cities[cityname][classname][skinName]["b"] = xmlNodeGetAttribute(node3, "b")

local skinNodes = xmlNodeGetChildren(node3)

cities[cityname][classname][skinName]["skins"] = {}

for i4, node4 in ipairs(skinNodes) do

local skinID = xmlNodeGetValue(node4)

table.insert(cities[cityname][classname][skinName]["skins"], skinID)

end

cities[cityname][classname][skinName]["permission"] = xmlNodeGetAttribute(node3, "lock")

cities[cityname][classname][skinName]["information"] = xmlNodeGetAttribute(node3, "information")

cities[cityname][classname][skinName]["weapons"] = xmlNodeGetAttribute(node3, "weapons")

end

end

end

xmlUnloadFile(xml)

function setCamera()

setCameraMatrix(1192.3686523438, -2036.3634033203, 69.235496520996, 1191.3736572266, -2036.330078125, 69.141883850098, 0, 70)

end

function wastedScreenFix()

guiSetVisible(GUIEditor_Window[1], true)

end

---------------------------------------------- wasted selection GUI

function drawWastedSelection()

--Make vars

GUIEditor_Window = {}

GUIEditor_Button = {}

GUIEditor_Memo = {}

GUIEditor_Label = {}

cost = math.random(50,5000)

--Make GUI

GUIEditor_Window[1] = guiCreateWindow(0.25,0.8,0.5,0.3,"EmpireRPG - Spawn",true)

guiWindowSetMovable(GUIEditor_Window[1], false)

guiWindowSetSizable(GUIEditor_Window[1], false)

GUIEditor_Button[2] = guiCreateButton(0.2,0.3,0.6,0.2,"Return to the spawn menu",true,GUIEditor_Window[1])

--GUIEditor_Label[4] = guiCreateLabel(0.2,0.2,0.6,0.2,"©EmpireRPG",true,GUIEditor_Window[1])

showCursor(true)

--Button Handlers

addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], onHospitalbuttonclick )

addEventHandler ( "onClientGUIClick", GUIEditor_Button[2], drawSpawnScreen )

addEventHandler ( "onClientGUIClick", GUIEditor_Button[2], hidewastedscreen )

--Make GUI Visable

guiSetVisible(GUIEditor_Window[1], false)

--Wasted Screen Camera

--local xD,yD,zD = getElementPosition( source )

--setCameraMatrix(xD,yD,zD-1,xD,yD,zD+1,90,110) -- attach camera to players face

--fadeCamera( false, 5, 119,0,0 )

--Wasted Screen Sound

local sound = playSound("client/wasted.mp3",false)

setSoundVolume(sound, 0.75)

--Draw GUI

setTimer(wastedScreenFix,500,1)

end

function onHospitalbuttonclick()

if source == GUIEditor_Button[1] then

if getPlayerMoney(getLocalPlayer()) >= cost then

guiSetVisible(GUIEditor_Window[1], false)

showCursor(false)

triggerServerEvent("SPAWNATHOSIPTAL", getLocalPlayer() )

takePlayerMoney ( cost )

elseif getPlayerMoney(getLocalPlayer()) < cost then

has = getPlayerMoney(getLocalPlayer())

take = has - cost

--outputChatBox("You respawned at hospital")

triggerEvent("SAVE:RPG:addMessage", localPlayer, "You have respawned at the hospital", 255, 0, 0)

guiSetVisible(GUIEditor_Window[1], false)

showCursor(false)

triggerServerEvent("SPAWNATHOSIPTAL", getLocalPlayer() )

takePlayerMoney ( cost )

else

outputChatBox("An error occured.", 255, 0, 0)

end

end

end

function hidewastedscreen(button)

if button == "left" then

guiSetVisible(GUIEditor_Window[1], false)

guiSetVisible(spawnWindow, true)

end

end

-------------------------------------------- end wasted selection GUI

function drawSpawnScreen()

if ( spawnWindow or infoWindow ) then

guiSetVisible(spawnWindow, false)

guiSetVisible(infoWindow, false)

end

labels = {}

spawnWindow = guiCreateWindow(0.005,0.395,0.5,0.6,"EmpireRPG Spawn Menu",true)

guiWindowSetMovable(spawnWindow, false)

guiWindowSetSizable(spawnWindow, false)

infoWindow = guiCreateWindow(0.005,0.265,0.5,0.125,"EmpireRPG Class Information",true)

guiWindowSetMovable(infoWindow,false)

guiWindowSetSizable(spawnWindow,false)

infoMemo = guiCreateMemo(0.0243,0.1712,0.9533,0.7534,"This server is ran by the Empire",true,infoWindow)

guiMemoSetReadOnly(infoMemo, true)

image = guiCreateStaticImage(0.0167,0.0387,0.975,0.225,"logo.png",true,spawnWindow)

cityGridList = guiCreateGridList(0.025,0.27,0.455,0.5,true,spawnWindow)

guiGridListSetSelectionMode(cityGridList,2)

guiGridListAddColumn(cityGridList, "City", 0.82)

classGridList = guiCreateGridList(0.52,0.27,0.455,0.3,true,spawnWindow)

guiGridListSetSelectionMode(classGridList,2)

guiGridListAddColumn(classGridList, "Team", 0.82)

spawnGridList = guiCreateGridList(0.52,0.585,0.455,0.2995,true,spawnWindow)

guiGridListSetSelectionMode(spawnGridList,2)

guiGridListAddColumn(spawnGridList, "Class", 0.82)

-- (LEFT RIGHT, UP DOWN, WIDTH,HEIGHT)

skinPrevButton = guiCreateButton(0.55,0.9,0.125,0.25,"<-",true,spawnWindow)

skinNextButton = guiCreateButton(0.82,0.9,0.125,0.25,"->",true,spawnWindow)

guiSetProperty(skinPrevButton, "Disabled", "True")

guiSetProperty(skinNextButton, "Disabled", "True")

skinNumberLabel = guiCreateLabel(0.599,0.925,0.3058,0.0326,"1",true,spawnWindow)

guiLabelSetVerticalAlign(skinNumberLabel,"center")

guiLabelSetHorizontalAlign(skinNumberLabel,"center",false)

spawnScreenOKButton = guiCreateButton(0.025,0.8,0.455,0.6,"Spawn",true,spawnWindow)

guiSetProperty(spawnScreenOKButton, "Disabled", "True")

for n, v in pairs(cities) do

local row = guiGridListAddRow(cityGridList)

guiGridListSetItemText(cityGridList, row, 1, n, false, false)

end

addEventHandler("onClientGUIClick", cityGridList, onCityClick)

addEventHandler("onClientGUIClick", classGridList, onClassClick)

addEventHandler("onClientGUIClick", spawnGridList, onSkinClick)

addEventHandler("onClientGUIClick", spawnScreenOKButton, onSpawnButtonClick)

addEventHandler("onClientGUIClick", skinPrevButton, onPrevSkin)

addEventHandler("onClientGUIClick", skinNextButton, onNextSkin)

fadeCamera(true)

setCamera()

guiSetVisible(spawnWindow, true)

--guiGridListSetSelectedItem(spawnGridList, -1, 0)

showCursor(true)

end

function onCityClick(button)

if source == cityGridList and button == "left" then

if guiGridListGetSelectedCount(cityGridList) > 0 then

guiGridListClear(classGridList)

local selectedRow, selectedCol = guiGridListGetSelectedItem( cityGridList ); -- get double clicked item in the gridlist

local cityName = guiGridListGetItemText( cityGridList, selectedRow, selectedCol ) -- get its text

local cityClasses = cities[cityName]

for x, y in pairs(cityClasses) do

local row = guiGridListAddRow(classGridList)

guiGridListSetItemText(classGridList, row, 1, x, false, false)

end

guiSetProperty(spawnScreenOKButton, "Disabled", "True")

guiSetProperty(skinPrevButton, "Disabled", "True")

guiSetProperty(skinNextButton, "Disabled", "True")

guiSetText(skinNumberLabel, 1)

unRenderSkin()

end

end

end

function onClassClick(button)

if source == classGridList and button == "left" then

if guiGridListGetSelectedCount(cityGridList) > 0 and guiGridListGetSelectedCount(classGridList) > 0 then

guiGridListClear(spawnGridList)

local selectedRow, selectedCol = guiGridListGetSelectedItem( cityGridList ); -- get double clicked item in the gridlist

local cityName = guiGridListGetItemText( cityGridList, selectedRow, selectedCol ) -- get its text

local selectedRow, selectedCol = guiGridListGetSelectedItem( classGridList ); -- get double clicked item in the gridlist

local className = guiGridListGetItemText( classGridList, selectedRow, selectedCol ) -- get its text

local classSkins = cities[cityName][className]

for x, y in pairs(classSkins) do

local row = guiGridListAddRow(spawnGridList)

guiGridListSetItemText(spawnGridList, row, 1, x, false, false)

end

guiSetProperty(spawnScreenOKButton, "Disabled", "True")

guiSetProperty(skinPrevButton, "Disabled", "True")

guiSetProperty(skinNextButton, "Disabled", "True")

guiSetText(skinNumberLabel, 1)

unRenderSkin()

end

end

end

function onSkinClick(button)

if source == spawnGridList and button == "left" then

if guiGridListGetSelectedCount(cityGridList) > 0 and guiGridListGetSelectedCount(classGridList) > 0 and guiGridListGetSelectedCount( spawnGridList ) > 0 then

local selectedRow, selectedCol = guiGridListGetSelectedItem( cityGridList ); -- get double clicked item in the gridlist

local cityName = guiGridListGetItemText( cityGridList, selectedRow, selectedCol ) -- get its text

local selectedRow, selectedCol = guiGridListGetSelectedItem( classGridList ); -- get double clicked item in the gridlist

local className = guiGridListGetItemText( classGridList, selectedRow, selectedCol ) -- get its text

local selectedRow, selectedCol = guiGridListGetSelectedItem( spawnGridList ); -- get double clicked item in the gridlist

local skinName = guiGridListGetItemText( spawnGridList, selectedRow, selectedCol ) -- get its text

guiSetProperty(spawnScreenOKButton, "Disabled", "False")

guiSetProperty(skinPrevButton, "Disabled", "False")

guiSetProperty(skinNextButton, "Disabled", "False")

guiSetText(infoMemo, cities[cityName][className][skinName]["information"])

guiSetText(skinNumberLabel, 1)

renderSkin()

end

end

end

function onSpawnButtonClick(button)

if source == spawnScreenOKButton and button == "left" then

if guiGridListGetSelectedCount( cityGridList ) > 0 and guiGridListGetSelectedCount( classGridList ) > 0 and guiGridListGetSelectedCount( spawnGridList ) > 0 then

local selectedRow, selectedCol = guiGridListGetSelectedItem( cityGridList ); -- get double clicked item in the gridlist

local cityName = guiGridListGetItemText( cityGridList, selectedRow, selectedCol ) -- get its text

local selectedRow, selectedCol = guiGridListGetSelectedItem( classGridList ); -- get double clicked item in the gridlist

local className = guiGridListGetItemText( classGridList, selectedRow, selectedCol ) -- get its text

local selectedRow, selectedCol = guiGridListGetSelectedItem( spawnGridList ); -- get double clicked item in the gridlist

local skinName = guiGridListGetItemText( spawnGridList, selectedRow, selectedCol ) -- get its text

local spawninfo = cities[cityName][className][skinName]

local skinID = spawninfo['skins'][tonumber(guiGetText(skinNumberLabel))]

unRenderSkin()

local r, g, b = spawninfo["r"], spawninfo["g"], spawninfo["b"]

triggerServerEvent("onPlayerSpawnButton", getLocalPlayer(), spawninfo["spawnX"] , spawninfo["spawnY"], spawninfo["spawnZ"], className, spawninfo['permission'], skinID,spawninfo['weapons'], getLocalPlayer(), skinName, spawninfo['r'] or nil, spawninfo['g'] or nil, spawninfo['b'] or nil)

else

displayError("Please make a selection!")

end

end

end

function onPrevSkin(button)

if source == skinPrevButton and button == "left" then

if tonumber(guiGetText(skinNumberLabel)) > 1 then

if guiGridListGetSelectedCount(cityGridList) > 0 and guiGridListGetSelectedCount(classGridList) > 0 and guiGridListGetSelectedCount( spawnGridList ) > 0 then

local currentNumber = tonumber(guiGetText(skinNumberLabel))

local newNumber = currentNumber - 1

guiSetText(skinNumberLabel, newNumber)

renderSkin()

end

end

end

end

function onNextSkin(button)

if source == skinNextButton and button == "left" then

if guiGridListGetSelectedCount(cityGridList) > 0 and guiGridListGetSelectedCount(classGridList) > 0 and guiGridListGetSelectedCount( spawnGridList ) > 0 then

local selectedRow, selectedCol = guiGridListGetSelectedItem( cityGridList ); -- get double clicked item in the gridlist

local cityName = guiGridListGetItemText( cityGridList, selectedRow, selectedCol ) -- get its text

local selectedRow, selectedCol = guiGridListGetSelectedItem( classGridList ); -- get double clicked item in the gridlist

local className = guiGridListGetItemText( classGridList, selectedRow, selectedCol ) -- get its text

local selectedRow, selectedCol = guiGridListGetSelectedItem( spawnGridList ); -- get double clicked item in the gridlist

local skinName = guiGridListGetItemText( spawnGridList, selectedRow, selectedCol ) -- get its text

local currentNumber = tonumber(guiGetText(skinNumberLabel))

local skins = cities[cityName][className][skinName]['skins']

local skinsN = table.getn(skins)

if currentNumber < skinsN then

local newNumber = currentNumber + 1

guiSetText(skinNumberLabel, newNumber)

renderSkin()

end

end

end

end

function renderSkin()

if renderedPed then

destroyElement(renderedPed)

renderedPed = nil

end

local selectedRow, selectedCol = guiGridListGetSelectedItem( cityGridList ); -- get double clicked item in the gridlist

local cityName = guiGridListGetItemText( cityGridList, selectedRow, selectedCol ) -- get its text

local selectedRow, selectedCol = guiGridListGetSelectedItem( classGridList ); -- get double clicked item in the gridlist

local className = guiGridListGetItemText( classGridList, selectedRow, selectedCol ) -- get its text

local selectedRow, selectedCol = guiGridListGetSelectedItem( spawnGridList ); -- get double clicked item in the gridlist

local skinName = guiGridListGetItemText( spawnGridList, selectedRow, selectedCol ) -- get its text

local currentNumber = tonumber(guiGetText(skinNumberLabel))

local skinID = cities[cityName][className][skinName]['skins'][tonumber(guiGetText(skinNumberLabel))]

renderedPed = createPed(skinID, 1190, -2035.5, 69, 270)

end

function unRenderSkin()

if renderedPed then

destroyElement(renderedPed)

renderedPed = nil

end

end

function hideSpawnScreen()

if spawnWindow then

guiSetVisible(spawnWindow, false)

guiSetVisible(infoWindow, false)

showCursor(false)

if hataEkrani then

guiSetVisible(hataEkrani, false)

end

guiSetText(infoMemo, "")

end

end

-- Attach the hide function to the hide command

addCommandHandler ( "hide", hideSpawnScreen )

addEvent("onSpawnSuccessful", true)

addEventHandler("onSpawnSuccessful", getRootElement(), hideSpawnScreen)

function createMessageBox()

hataEkrani = guiCreateWindow(resX / 2 - 150, resY / 2 - 100, 300, 200, "Error", false)

hataUyari = guiCreateMemo(5, 25, 295, 125, "", false, hataEkrani)

guiMemoSetReadOnly(hataUyari, true)

hataEkraniButton = guiCreateButton(110, 160, 80, 25, "OK", false, hataEkrani)

guiWindowSetMovable(hataEkrani, false)

guiWindowSetSizable(hataEkrani, false)

guiSetVisible(hataEkrani, false)

addEventHandler("onClientGUIClick", hataEkraniButton, function()

guiSetProperty(hataEkrani, "AlwaysOnTop", "False")

guiSetVisible(hataEkrani, false)

end, false)

end

function displayError(error)

if not hataEkrani then

createMessageBox()

end

guiSetText(hataUyari, error)

guiSetProperty(hataEkrani, "AlwaysOnTop", "True")

guiSetVisible(hataEkrani, true)

if not spawnWindow then

drawSpawnScreen()

elseif not guiGetVisible(spawnWindow) then

drawSpawnScreen()

end

end

addEvent("onSpawnError", true)

addEventHandler("onSpawnError", getRootElement(), displayError)

addCommandHandler( "spawnerror",displayError)

function checkPlayerAlive()

--outputConsole("Client side check done!")

triggerServerEvent("wasPlayerAliveEvent", getLocalPlayer())

end

addEvent("onPlayerWasntAlive", true)

addEventHandler("onPlayerWasntAlive", getRootElement(), drawSpawnScreen)

addEvent("onClientPlayerLogin", true)

addEventHandler("onClientPlayerLogin", getRootElement(), drawSpawnScreen)

addEvent("onPlayerWasted", true)

addEventHandler("onPlayerWasted", getRootElement(), drawSpawnScreen)

local pedRot = 0;

function rotatePed()

if (renderedPed) then

setPedRotation( renderedPed,( pedRot+235 ) );

pedRot = ( pedRot + 2.5 );

end

end

setTimer(rotatePed,50,0)

Edited by Guest
Link to comment

Please use the LUA tags.

Try this:

local localPlayer = getLocalPlayer() 
local resX, resY = guiGetScreenSize()
local startX = resX * (2 / 3)
local startY = 0
local windowX = resX * (1 / 5)
local windowY = resY
 
local xml = xmlLoadFile("spawns.xml") -- open the XML file
local cityNodes = xmlNodeGetChildren(xml) -- get all child nodes of the root node ()
local cities = {} -- create a new global variable to store the welcome messages
 
local GUIEditor_Window = {}
local GUIEditor_Button = {}
local GUIEditor_Memo = {}
local GUIEditor_Label = {}
 
for i,node in ipairs(cityNodes) do
    cityname = xmlNodeGetAttribute(node, "name")
    local classnodes = xmlNodeGetChildren(node)
    cities[cityname] = {}
    for i2,node2 in ipairs(classnodes) do
        classname = xmlNodeGetAttribute(node2, "name")
        local spawnnodes = xmlNodeGetChildren(node2)
        cities[cityname][classname] = {}
        for i3, node3 in ipairs(spawnnodes) do
            skinName = xmlNodeGetAttribute(node3, "name")
            cities[cityname][classname][skinName] = {}
            cities[cityname][classname][skinName]["spawnX"] = xmlNodeGetAttribute(node3, "spawnX")
            cities[cityname][classname][skinName]["spawnY"] = xmlNodeGetAttribute(node3, "spawnY")
            cities[cityname][classname][skinName]["spawnZ"] = xmlNodeGetAttribute(node3, "spawnZ")
            cities[cityname][classname][skinName]["r"] = xmlNodeGetAttribute(node3, "r")
            cities[cityname][classname][skinName]["g"] = xmlNodeGetAttribute(node3, "g")
            cities[cityname][classname][skinName]["b"] = xmlNodeGetAttribute(node3, "b")
            local skinNodes = xmlNodeGetChildren(node3)
            cities[cityname][classname][skinName]["skins"] = {}
            for i4, node4 in ipairs(skinNodes) do
                local skinID = xmlNodeGetValue(node4)
                table.insert(cities[cityname][classname][skinName]["skins"], skinID)
            end
            cities[cityname][classname][skinName]["permission"] = xmlNodeGetAttribute(node3, "lock")
            cities[cityname][classname][skinName]["information"] = xmlNodeGetAttribute(node3, "information")
            cities[cityname][classname][skinName]["weapons"] = xmlNodeGetAttribute(node3, "weapons")
        end
    end
end
xmlUnloadFile(xml)
 
function setCamera()
    setCameraMatrix(1192.3686523438, -2036.3634033203, 69.235496520996, 1191.3736572266, -2036.330078125, 69.141883850098, 0, 70)
end
 
function wastedScreenFix()
    guiSetVisible(GUIEditor_Window[1], true)
end
 
 
---------------------------------------------- wasted selection GUI
function drawWastedSelection()
--Make vars
 
cost = math.random(50,5000)
 
--Make GUI
GUIEditor_Window[1] = guiCreateWindow(0.25,0.8,0.5,0.3,"EmpireRPG - Spawn",true)
guiWindowSetMovable(GUIEditor_Window[1], false)
guiWindowSetSizable(GUIEditor_Window[1], false)
 
GUIEditor_Button[2] = guiCreateButton(0.2,0.3,0.6,0.2,"Return to the spawn menu",true,GUIEditor_Window[1])
 
--GUIEditor_Label[4] = guiCreateLabel(0.2,0.2,0.6,0.2,"(c)EmpireRPG",true,GUIEditor_Window[1])
showCursor(true)
 
--Button Handlers
addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], onHospitalbuttonclick )
addEventHandler ( "onClientGUIClick", GUIEditor_Button[2], drawSpawnScreen )
addEventHandler ( "onClientGUIClick", GUIEditor_Button[2], hidewastedscreen )
 
--Make GUI Visable
guiSetVisible(GUIEditor_Window[1], false)
 
--Wasted Screen Camera
--local ,yD,zD = getElementPosition( source )
--setCameraMatrix(,yD,zD-1,,yD,zD+1,90,110) -- attach camera to players face
--fadeCamera( false, 5, 119,0,0 )
 
--Wasted Screen Sound
local sound = playSound("client/wasted.mp3",false)
setSoundVolume(sound, 0.75)
 
--Draw GUI
setTimer(wastedScreenFix,500,1)
 
end
 
function onHospitalbuttonclick()
if source == GUIEditor_Button[1] then
if getPlayerMoney(getLocalPlayer()) >= cost then
guiSetVisible(GUIEditor_Window[1], false)
showCursor(false)
triggerServerEvent("SPAWNATHOSIPTAL", getLocalPlayer() )
takePlayerMoney ( cost )
elseif getPlayerMoney(getLocalPlayer()) < cost then
has = getPlayerMoney(getLocalPlayer())
take = has - cost
--outputChatBox("You respawned at hospital")
triggerEvent("SAVE:RPG:addMessage", localPlayer, "You have respawned at the hospital", 255, 0, 0)
guiSetVisible(GUIEditor_Window[1], false)
showCursor(false)
triggerServerEvent("SPAWNATHOSIPTAL", getLocalPlayer() )
takePlayerMoney ( cost )
else
outputChatBox("An error occured.", 255, 0, 0)
end
end
end
 
 
function hidewastedscreen(button)
if button == "left" then
guiSetVisible(GUIEditor_Window[1], false)
guiSetVisible(spawnWindow, true)
end
end
-------------------------------------------- end wasted selection GUI
 
 
 
function drawSpawnScreen()
if ( spawnWindow or infoWindow ) then
guiSetVisible(spawnWindow, false)
guiSetVisible(infoWindow, false)
end
 
labels = {}
 
spawnWindow = guiCreateWindow(0.005,0.395,0.5,0.6,"EmpireRPG Spawn Menu",true)
guiWindowSetMovable(spawnWindow, false)
guiWindowSetSizable(spawnWindow, false)
 
 
infoWindow = guiCreateWindow(0.005,0.265,0.5,0.125,"EmpireRPG Class Information",true)
guiWindowSetMovable(infoWindow,false)
guiWindowSetSizable(spawnWindow,false)
 
infoMemo = guiCreateMemo(0.0243,0.1712,0.9533,0.7534,"This server is ran by the Empire",true,infoWindow)
guiMemoSetReadOnly(infoMemo, true)
 
image = guiCreateStaticImage(0.0167,0.0387,0.975,0.225,"logo.png",true,spawnWindow)
 
cityGridList = guiCreateGridList(0.025,0.27,0.455,0.5,true,spawnWindow)
guiGridListSetSelectionMode(cityGridList,2)
guiGridListAddColumn(cityGridList, "City", 0.82)
 
classGridList = guiCreateGridList(0.52,0.27,0.455,0.3,true,spawnWindow)
guiGridListSetSelectionMode(classGridList,2)
guiGridListAddColumn(classGridList, "Team", 0.82)
 
 
spawnGridList = guiCreateGridList(0.52,0.585,0.455,0.2995,true,spawnWindow)
guiGridListSetSelectionMode(spawnGridList,2)
guiGridListAddColumn(spawnGridList, "Class", 0.82)
 
-- (LEFT RIGHT, UP DOWN, WIDTH,HEIGHT) 
skinPrevButton = guiCreateButton(0.55,0.9,0.125,0.25,"<-",true,spawnWindow)
skinNextButton = guiCreateButton(0.82,0.9,0.125,0.25,"->",true,spawnWindow)
 
guiSetProperty(skinPrevButton, "Disabled", "True")
guiSetProperty(skinNextButton, "Disabled", "True")
 
skinNumberLabel = guiCreateLabel(0.599,0.925,0.3058,0.0326,"1",true,spawnWindow)
guiLabelSetVerticalAlign(skinNumberLabel,"center")
guiLabelSetHorizontalAlign(skinNumberLabel,"center",false)
 
 
spawnScreenOKButton = guiCreateButton(0.025,0.8,0.455,0.6,"Spawn",true,spawnWindow)
guiSetProperty(spawnScreenOKButton, "Disabled", "True")
 
 
for n, v in pairs(cities) do
local row = guiGridListAddRow(cityGridList)
guiGridListSetItemText(cityGridList, row, 1, n, false, false)
end
 
 
addEventHandler("onClientGUIClick", cityGridList, onCityClick)
addEventHandler("onClientGUIClick", classGridList, onClassClick)
addEventHandler("onClientGUIClick", spawnGridList, onSkinClick)
addEventHandler("onClientGUIClick", spawnScreenOKButton, onSpawnButtonClick)
 
addEventHandler("onClientGUIClick", skinPrevButton, onPrevSkin)
addEventHandler("onClientGUIClick", skinNextButton, onNextSkin)
 
fadeCamera(true)
setCamera()
guiSetVisible(spawnWindow, true)
--guiGridListSetSelectedItem(spawnGridList, -1, 0)
showCursor(true)
end
 
function onCityClick(button)
if source == cityGridList and button == "left" then
if guiGridListGetSelectedCount(cityGridList) > 0 then
guiGridListClear(classGridList)
local selectedRow, selectedCol = guiGridListGetSelectedItem( cityGridList ); -- get double clicked item in the gridlist
local cityName = guiGridListGetItemText( cityGridList, selectedRow, selectedCol ) -- get its text
local cityClasses = cities[cityName]
for x, y in pairs(cityClasses) do
local row = guiGridListAddRow(classGridList)
guiGridListSetItemText(classGridList, row, 1, x, false, false)
end
guiSetProperty(spawnScreenOKButton, "Disabled", "True")
guiSetProperty(skinPrevButton, "Disabled", "True")
guiSetProperty(skinNextButton, "Disabled", "True")
guiSetText(skinNumberLabel, 1)
unRenderSkin()
end
end
end
 
function onClassClick(button)
if source == classGridList and button == "left" then
if guiGridListGetSelectedCount(cityGridList) > 0 and guiGridListGetSelectedCount(classGridList) > 0 then
guiGridListClear(spawnGridList)
 
local selectedRow, selectedCol = guiGridListGetSelectedItem( cityGridList ); -- get double clicked item in the gridlist
local cityName = guiGridListGetItemText( cityGridList, selectedRow, selectedCol ) -- get its text
 
local selectedRow, selectedCol = guiGridListGetSelectedItem( classGridList ); -- get double clicked item in the gridlist
local className = guiGridListGetItemText( classGridList, selectedRow, selectedCol ) -- get its text
 
local classSkins = cities[cityName][className]
for x, y in pairs(classSkins) do
local row = guiGridListAddRow(spawnGridList)
 
guiGridListSetItemText(spawnGridList, row, 1, x, false, false)
end
guiSetProperty(spawnScreenOKButton, "Disabled", "True")
guiSetProperty(skinPrevButton, "Disabled", "True")
guiSetProperty(skinNextButton, "Disabled", "True")
guiSetText(skinNumberLabel, 1)
unRenderSkin()
end
end
end
 
function onSkinClick(button)
if source == spawnGridList and button == "left" then
if guiGridListGetSelectedCount(cityGridList) > 0 and guiGridListGetSelectedCount(classGridList) > 0 and guiGridListGetSelectedCount( spawnGridList ) > 0 then
local selectedRow, selectedCol = guiGridListGetSelectedItem( cityGridList ); -- get double clicked item in the gridlist
local cityName = guiGridListGetItemText( cityGridList, selectedRow, selectedCol ) -- get its text
 
Link to comment

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...