Einheit-101 Posted February 6, 2011 Share Posted February 6, 2011 Hello Comrades! I have a little problem! I wanted to make a script that opens a window which lets you choose 2 different spawn points: 1 angel Pine, the other Blueberry acres! But it outputs some error messages: Unexpected error: Spawn GUI has not been created. (My debug outputChatbox) broph.lua:33: Bad argument @ addEventHandler broph.lua:51: Bad argument @ addEventHandler broph.lua:60: Bad argument @ ShowCursor broph.lua:61: Bad argument @ attempt to call global setInputEnabled (a nil value) function createSpawnWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwSpawn = guiCreateWindow(X, Y, Width, Height, "Select a Spawn area", true) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.2 btnPine = guiCreateButton(X, Y, 0.3, 0.15, "Angel Pine", true, wdwSpawn) btnBerry = guiCreateButton(X, Y, 0.5, 0.15, "Blueberry", true, wdwSpawn) guiSetVisible(wdwSpawn, false) end addEventHandler ( "onClientResourceStart", getRootElement(), createSpawnWindow ) function angelpine(button, state) if button == "left" and state == "up" then spawnPlayer(client, -2138.8+math.random(1,5), -2352+math.random(4,7), 37.732, 90, math.random(281,286)) fadeCamera(client, true) setCameraTarget(player, client) giveWeapon(player, 25, 25) givePlayerMoney(player, 250) outputChatBox("Spawning in Angel Pine...") guiSetInputEnabled(false) guiSetVisible(wdwSpawn, false)--208.2, -240, 1.8 showCursor(false) end end addEventHandler("onClientGUIClick", btnPine, angelpine, false) function blueberry(button, state) if button == "left" and state == "up" then spawnPlayer(client, 208.2+math.random(1,3),-240+math.random(1,3), 1.8, 90, math.random(281,286)) fadeCamera(client, true) setCameraTarget(player, client) giveWeapon(player, 25, 25) givePlayerMoney(player, 250) outputChatBox("Spawning in Blueberry...") guiSetInputEnabled(false) guiSetVisible(wdwSpawn, false) showCursor(false) end end addEventHandler("onClientGUIClick", btnPine, blueberry, false) function window(ammo, attacker, weapon, bodypart) if (wdwSpawn ~= nil) then guiSetVisible(wdwSpawn, true) else outputChatBox("Unexpected error: Spawn GUI has not been created.") end showCursor(true) guiSetInputEnabled(true) end function start() setTimer(window, 9000, 1) end addEventHandler ( "onPlayerWasted", getRootElement(), start) function start() setTimer(window, 9000, 1) end addEventHandler ( "onClientResourceStart", getRootElement(), start ) function start() setTimer(window, 9000, 1) end addEventHandler ( "onPlayerJoin", getRootElement(), start ) Link to comment
Castillo Posted February 6, 2011 Share Posted February 6, 2011 Well, you are messing client functions/events with server functions/events, use this one instead, client side: local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwSpawn = guiCreateWindow(X, Y, Width, Height, "Select a Spawn area", true) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.2 btnPine = guiCreateButton(X, Y, 0.3, 0.15, "Angel Pine", true, wdwSpawn) btnBerry = guiCreateButton(X, Y, 0.5, 0.15, "Blueberry", true, wdwSpawn) guiSetVisible(wdwSpawn, false) function angelpine(button, state) if button == "left" and state == "up" then triggerServerEvent("spawn",getLocalPlayer(),getLocalPlayer(),"angel") guiSetInputEnabled(false) guiSetVisible(wdwSpawn, false)--208.2, -240, 1.8 showCursor(false) end end addEventHandler("onClientGUIClick", btnPine, angelpine, false) function blueberry(button, state) if button == "left" and state == "up" then triggerServerEvent("spawn",getLocalPlayer(),getLocalPlayer(),"blueberry") guiSetInputEnabled(false) guiSetVisible(wdwSpawn, false) showCursor(false) end end addEventHandler("onClientGUIClick", btnBerry, blueberry, false) function window(ammo, attacker, weapon, bodypart) if (wdwSpawn ~= nil) then guiSetVisible(wdwSpawn, true) else outputChatBox("Unexpected error: Spawn GUI has not been created.") end showCursor(true) guiSetInputEnabled(true) end function start() setTimer(window, 9000, 1) end addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), start) function start2() setTimer(window, 1000, 1) end addEventHandler ( "onClientResourceStart", getRootElement(), start2) server side: addEvent("spawn",true) addEventHandler("spawn",getRootElement(), function (client,where) if where == "blueberry" then spawnPlayer(client, 208.2+math.random(1,3),-240+math.random(1,3), 1.8, 90, math.random(281,286)) fadeCamera(client, true) setCameraTarget(client, client) giveWeapon(client, 25, 25) givePlayerMoney(client, 250) outputChatBox("Spawning in Blueberry...",client) elseif where == "angel" then spawnPlayer(client, -2138.8+math.random(1,5), -2352+math.random(4,7), 37.732, 90, math.random(281,286)) fadeCamera(client, true) setCameraTarget(client, client) giveWeapon(client, 25, 25) givePlayerMoney(client, 250) outputChatBox("Spawning in Angel Pine...") end end) You must define client or server at meta.xml, example: <script src="script.lua" type="client" /> Link to comment
Einheit-101 Posted February 6, 2011 Author Share Posted February 6, 2011 (edited) Thanks for the fast reply! I will test it right now... *EDIT* O M G I dont believe it! You made it! Love you man! Edited February 6, 2011 by Guest Link to comment
Einheit-101 Posted February 6, 2011 Author Share Posted February 6, 2011 Well, you are messing client functions/events with server functions/events. Hmmm That is something i hear very often! I hate that! Link to comment
Castillo Posted February 6, 2011 Share Posted February 6, 2011 Please, don't double-post, use "EDIT" button instead, thank you. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now