Stylez Posted October 14, 2012 Posted October 14, 2012 Hello. Im trying to make guest button. but im keep getting this error : WARNING: guset/testC.lua36: Bad argument @ AddEventHandler [Expected element a argument 2, got nil] Here is the code function myfirstwindow() local swidth, sheight = guiGetScreenSize() local width, height = 400, 400 local x = (swidth/2) - (width/2) local y = (sheight/2) - (height/2) window1 = guiCreateWindow(x, y, width, height, "Title", false) -- MAIN WINDOW guiWindowSetMovable(window1, false) guiWindowSetSizable(window1, false) --Button guestBtn = guiCreateButton(160,370,70,30, "Play as Guest", false, window1) addEventHandler("onClientGUIClick", guestBtn, window1buttonresponse, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() myfirstwindow() outputChatBox("Wlcome to MTA:SA Cops & Robbers Server. Please Log-In") if window1 ~= nil then guiSetVisible(window1, true) else outputChatBox("An error has occured") end showCursor(true) guiSetInputEnabled(true) end ) function window1buttonresponse(button, state) if button == 'left' and state == 'up' then guiSetVisible(window1, false) showCursor(false, false) end end addEventHandler("onClientGUIClick", guestBtn, function() -- local source = guest if (source == guest)then -- triggerServerEvent("guestLogin", getRootElement()) guiSetVisible(loginWindow, false) showCursor(false) end end) SERVER client = source -- addEvent("guestLogin", true) addEventHandler("guestLogin", root, function () spawnPlayer(client, 2505.52, -1741.73, 2072.98) fadeCamera(client, false, 1.0, 0, 0, 0) -- setTimer( fadeCamera, 500, 1, client, false, 0.5 ) -- outputChatBox("Welocme To Cops & Robbers Server. Remember You are guest", client) end )
Baseplate Posted October 14, 2012 Posted October 14, 2012 function myfirstwindow() local swidth, sheight = guiGetScreenSize() local width, height = 400, 400 local x = (swidth/2) - (width/2) local y = (sheight/2) - (height/2) window1 = guiCreateWindow(x, y, width, height, "Title", false) -- MAIN WINDOW guiWindowSetMovable(window1, false) guiWindowSetSizable(window1, false) --Button guestBtn = guiCreateButton(160,370,70,30, "Play as Guest", false, window1) addEventHandler("onClientGUIClick", guestBtn, window1buttonresponse, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() myfirstwindow() outputChatBox("Wlcome to MTA:SA Cops & Robbers Server. Please Log-In") if window1 ~= nil then guiSetVisible(window1, true) else outputChatBox("An error has occured") end showCursor(true) guiSetInputEnabled(true) end ) function window1buttonresponse(button, state) if button == 'left' and state == 'up' then guiSetVisible(window1, false) showCursor(false, false) end end function kay () local source = guest if (source == guest)then triggerServerEvent("guestLogin", getRootElement()) guiSetVisible(loginWindow, false) showCursor(false) end end addEventHandler("onClientGUIClick", root, kay) That's client, try it untested
TwiX! Posted October 14, 2012 Posted October 14, 2012 c function myfirstwindow() local swidth, sheight = guiGetScreenSize() local width, height = 400, 400 local x = (swidth/2) - (width/2) local y = (sheight/2) - (height/2) window1 = guiCreateWindow(x, y, width, height, "Title", false) -- MAIN WINDOW guiWindowSetMovable(window1, false) guiWindowSetSizable(window1, false) --Button guestBtn = guiCreateButton(160,370,70,30, "Play as Guest", false, window1) addEventHandler("onClientGUIClick", guestBtn, window1buttonresponse, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() myfirstwindow() outputChatBox("Wlcome to MTA:SA Cops & Robbers Server. Please Log-In") if window1 ~= nil then guiSetVisible(window1, true) else outputChatBox("An error has occured") end showCursor(true) guiSetInputEnabled(true) end ) function window1buttonresponse(button,state) if button == 'left' and state == 'up' then guiSetVisible(window1,false); showCursor(false,false); triggerServerEvent("guestLogin",localPlayer,localPlayer); end end s addEvent("guestLogin", true) addEventHandler("guestLogin", root, function (thePlayer) spawnPlayer(thePlayer, 2505.52, -1741.73, 2072.98) fadeCamera(thePlayer, false, 1.0, 0, 0, 0) -- setTimer( fadeCamera, 500, 1, thePlayer, false, 0.5 ) -- outputChatBox("Welocme To Cops & Robbers Server. Remember You are guest", thePlayer) end ) - Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]
Stylez Posted October 14, 2012 Author Posted October 14, 2012 ERROR: Client triggered serverside event guestLogin, but event is not added serverside.. wut? addEvent("guestLogin", true)
TwiX! Posted October 14, 2012 Posted October 14, 2012 function LoggedIn(thePlayer) spawnPlayer(thePlayer, 2505.52, -1741.73, 2072.98) fadeCamera(thePlayer, false, 1.0, 0, 0, 0) -- setTimer( fadeCamera, 500, 1, thePlayer, false, 0.5 ) -- outputChatBox("Welocme To Cops & Robbers Server. Remember You are guest", thePlayer) end addEvent("guestLogin",true) addEventHandler("guestLogin",getRootElement(),LoggedIn) - Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]
Anderl Posted October 14, 2012 Posted October 14, 2012 Add server-side file before client-side, on meta.xml. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Stylez Posted October 14, 2012 Author Posted October 14, 2012 it works now, but it doesnt spawns me, just shows blue sky.
TwiX! Posted October 14, 2012 Posted October 14, 2012 /debugscript 3 - Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]
TwiX! Posted October 14, 2012 Posted October 14, 2012 so it's will work - Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]
Stylez Posted October 14, 2012 Author Posted October 14, 2012 I dont know.. it spawns me somwhere in mountains, and shows blue sky.. It should spawn me in Grove Street and should be able to move,
abu5lf Posted October 14, 2012 Posted October 14, 2012 Use : https://wiki.multitheftauto.com/wiki/SetCameraTarget ╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗ ║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║ ║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║ ║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║ ╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝ «سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك» M7mdAl7arthy : لتواصل سكايب
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