Stylez Posted October 14, 2012 Share 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 ) Link to comment
Baseplate Posted October 14, 2012 Share 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 Link to comment
TwiX! Posted October 14, 2012 Share 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 ) Link to comment
Stylez Posted October 14, 2012 Author Share Posted October 14, 2012 ERROR: Client triggered serverside event guestLogin, but event is not added serverside.. wut? addEvent("guestLogin", true) Link to comment
TwiX! Posted October 14, 2012 Share 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) Link to comment
Anderl Posted October 14, 2012 Share Posted October 14, 2012 Add server-side file before client-side, on meta.xml. Link to comment
Stylez Posted October 14, 2012 Author Share Posted October 14, 2012 it works now, but it doesnt spawns me, just shows blue sky. Link to comment
Stylez Posted October 14, 2012 Author Share Posted October 14, 2012 i removed all resources. Link to comment
Stylez Posted October 14, 2012 Author Share 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, Link to comment
abu5lf Posted October 14, 2012 Share Posted October 14, 2012 Use : https://wiki.multitheftauto.com/wiki/SetCameraTarget 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