Bean666 Posted July 6, 2016 Share Posted July 6, 2016 (edited) I'm getting a getelementtype nil here idk why function acceptjob(player) if (getElementType(player) == "player") then setElementData(player, "Job", "Fishermen") setElementData(player, "Fishermen", true) outputChatBox("You are now a fisherman!", player, 255, 255, 0) setPlayerTeam(player, getTeamFromName("Services")) end end addEvent("acceptjob", true) addEventHandler("acceptjob", getRootElement(), acceptjob) client that's triggering the event addEventHandler("onClientGUIClick",resourceRoot,function() if (source == accept) then guiSetVisible(window,false) showCursor(false) triggerServerEvent("acceptjob", localPlayer) elseif ( source == cancel) then guiSetVisible(window,false) showCursor(false) end end ) Edited July 7, 2016 by Guest Link to comment
Bean666 Posted July 7, 2016 Author Share Posted July 7, 2016 I'm getting a getelementtype nil here idk why function acceptjob(player) if (getElementType(player) == "player") then setElementData(player, "Job", "Fishermen") setElementData(player, "Fishermen", true) outputChatBox("You are now a fisherman!", player, 255, 255, 0) setPlayerTeam(player, getTeamFromName("Services")) end end addEvent("acceptjob", true) addEventHandler("acceptjob", getRootElement(), acceptjob) client that's triggering the event addEventHandler("onClientGUIClick",resourceRoot,function() if (source == accept) then guiSetVisible(window,false) showCursor(false) triggerServerEvent("acceptjob", localPlayer) elseif ( source == cancel) then guiSetVisible(window,false) showCursor(false) end end ) Link to comment
فاّرس Posted July 7, 2016 Share Posted July 7, 2016 cuz there's no parametrs, and you don't need to use getElementType, anyway change your trigger to : triggerServerEvent("acceptjob", localPlayer, localPlayer) and you can do it like this without changed : function acceptjob() if (getElementType(source) == "player") then setElementData(source, "Job", "Fishermen") setElementData(source, "Fishermen", true) outputChatBox("You are now a fisherman!", source, 255, 255, 0) setPlayerTeam(source, getTeamFromName("Services")) end end addEvent("acceptjob", true) addEventHandler("acceptjob", getRootElement(), acceptjob) and you don't need to use getElementType too. Link to comment
Walid Posted July 7, 2016 Share Posted July 7, 2016 For triggerServerEvent, client is always set. i.e.: triggerServerEvent("EventName" , localPlayer) source is localPlayer client is localPlayer triggerServerEvent("EventName" , resourceRoot or root) source is resourceRoot or root client is localPlayer -- Server side function acceptjob() setElementData(client, "Job", "Fishermen") setElementData(client, "Fishermen", true) outputChatBox("You are now a fisherman!", client, 255, 255, 0) setPlayerTeam(client, getTeamFromName("Services")) end addEvent("acceptjob", true) addEventHandler("acceptjob", getRootElement(), acceptjob) -- Client side addEventHandler("onClientGUIClick",resourceRoot,function() if (source == accept) then guiSetVisible(window,false) showCursor(false) triggerServerEvent("acceptjob", localPlayer) elseif ( source == cancel) then guiSetVisible(window,false) showCursor(false) end end ) 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