Pikachu Posted September 29, 2012 Share Posted September 29, 2012 Client Side: JobGUI = guiCreateWindow(249,240,307,176,"Job GUI",false) guiWindowSetSizable(JobGUI,false) guiWindowSetMovable(JobGUI,false) guiSetAlpha(JobGUI,0.89999997615814) guiSetVisible(JobGUI, false) EndStartJ = guiCreateButton(26,37,254,58,"End/start shift",false,JobGUI) QuitJ = guiCreateButton(26,98,254,58,"Quit job",false,JobGUI) function ShowGUI ( ) guiSetVisible ( JobGUI, not guiGetVisible ( JobGUI ) ) showCursor ( not isCursorShowing( ) ) end bindKey("F2","down", ShowGUI) function shift() local localPlayer = getLocalPlayer() triggerServerEvent("jobShift", localPlayer) end addEventHandler("onClientGUIClick", EndStartJ, shift) function hideGUI() guiSetVisible(JobGUI, false) showCursor(false) end addEvent("hide", true) addEventHandler("hide", localPlayer, hideGUI) Server Side: emp = createTeam("Unemployed team", 127, 127, 127) occ = createTeam("Unoccupied team", 173, 255, 0) function jobShift() local team = getPlayerTeam(source) if (team and getTeamName(team) == "Staff") or (team and getTeamName(team) == "Armed Forces") or (team and getTeamName(team) == "SWAT Team") or (team and getTeamName(team) == "Government") or (team and getTeamName(team) == "Civilian Workers") or (team and getTeamName(team) == "Medic") or (team and getTeamName(team) == "Police") or (team and getTeamName(team) == "Criminal") then teamO = getPlayerTeam(source) pSkin = getElementModel(source) setPlayerTeam(source, emp) setElementModel(source, 0) triggerClientEvent("hide", getRootElement()) end elseif (team and getTeamName(team) == emp) then setElementModel(source, pSkin) triggerClientEvent("hide", getRootElement()) end end addEvent("jobShift", true) addEventHandler("jobShift", getRootElement(), jobShift) What it should do: make players able to set their team to "Unemployed" and back to their old team.... That's all for now. But the problem is when i end shift, i can't come back to my old team.... Can somebody help me please? Link to comment
Jaysds1 Posted September 30, 2012 Share Posted September 30, 2012 try this, Server: local allowedTeams = { ["Staff"]=true, ["Armed Forces"]=true, ["SWAT Team"]=true, ["Government"]=true, ["Civilian Workers"]=true, ["Medic"]=true, ["Police"]=true, ["Criminal"]=true; } emp = createTeam("Unemployed team", 127, 127, 127) occ = createTeam("Unoccupied team", 173, 255, 0) function jobShift() local team = getPlayerTeam(client) local pSkin = getElementModel(client) if team then --just check if the player is on a team if allowedTeams[getTeamName(team)] then --if there team name is in the table, it returns true setPlayerTeam(client, emp) setElementModel(client, 0) triggerClientEvent(client,"hide",client) --trigger this for the one client, not all the clients elseif team == emp then --emp is a team not the name of the team setElementModel(client, pSkin) triggerClientEvent(client,"hide",client) end end end addEvent("jobShift", true) addEventHandler("jobShift", getRootElement(), jobShift) Client: JobGUI = guiCreateWindow(249,240,307,176,"Job GUI",false) guiWindowSetSizable(JobGUI,false) guiWindowSetMovable(JobGUI,false) guiSetAlpha(JobGUI,0.89999997615814) guiSetVisible(JobGUI, false) EndStartJ = guiCreateButton(26,37,254,58,"End/start shift",false,JobGUI) QuitJ = guiCreateButton(26,98,254,58,"Quit job",false,JobGUI) function ShowGUI ( ) local guiVisible = guiGetVisible ( JobGUI ) guiSetVisible ( JobGUI, not guiVisible) showCursor ( guiVisible ) end bindKey("F2","down", ShowGUI) function shift() triggerServerEvent("jobShift", localPlayer) end addEventHandler("onClientGUIClick", EndStartJ, shift) function hideGUI() guiSetVisible(JobGUI, false) showCursor(false) end addEvent("hide", true) addEventHandler("hide",root, hideGUI) Link to comment
Jokeℝ1472771893 Posted October 3, 2012 Share Posted October 3, 2012 Don't work.when i press F2 nothing happened Link to comment
Castillo Posted October 3, 2012 Share Posted October 3, 2012 Errors or anything at debugscript? Link to comment
Castillo Posted October 3, 2012 Share Posted October 3, 2012 Seems like you have set the client side script as server side in the meta.xml. Link to comment
Jokeℝ1472771893 Posted October 3, 2012 Share Posted October 3, 2012 yeah my bad,but when i press F2 it's show me Gui without Cursor then when i press F2 again i see only Cursor Link to comment
TAPL Posted October 3, 2012 Share Posted October 3, 2012 yeah my bad,but when i press F2 it's show me Gui without Cursor then when i press F2 again i see only Cursor function ShowGUI() guiSetVisible(JobGUI, not guiGetVisible(JobGUI)) showCursor(guiGetVisible(JobGUI)) end bindKey("F2","down", ShowGUI) Link to comment
Castillo Posted October 3, 2012 Share Posted October 3, 2012 JobGUI = guiCreateWindow(249,240,307,176,"Job GUI",false) guiWindowSetSizable(JobGUI,false) guiWindowSetMovable(JobGUI,false) guiSetAlpha(JobGUI,0.89999997615814) guiSetVisible(JobGUI, false) EndStartJ = guiCreateButton(26,37,254,58,"End/start shift",false,JobGUI) QuitJ = guiCreateButton(26,98,254,58,"Quit job",false,JobGUI) function ShowGUI ( ) guiSetVisible ( JobGUI, not guiGetVisible ( JobGUI ) ) showCursor ( guiGetVisible ( JobGUI ) ) end bindKey("F2","down", ShowGUI) function shift() triggerServerEvent("jobShift", localPlayer) end addEventHandler("onClientGUIClick", EndStartJ, shift) function hideGUI() guiSetVisible(JobGUI, false) showCursor(false) end addEvent("hide", true) addEventHandler("hide",root, hideGUI) Link to comment
Jokeℝ1472771893 Posted October 3, 2012 Share Posted October 3, 2012 I can't start Shift when i End it and i can't Quit Job if i End It. Link to comment
Pikachu Posted October 3, 2012 Author Share Posted October 3, 2012 I can't start Shift when i End it and i can't Quit Job if i End It. Are you stupid or what O_o ? You should help me with the script, not ask for help in this topic! Somebody lock this topic and pm me if he have the fix. Link to comment
Jokeℝ1472771893 Posted October 3, 2012 Share Posted October 3, 2012 if you create this Topic it's not mean that all must help u,if someone have question can ask here. Link to comment
Pikachu Posted October 3, 2012 Author Share Posted October 3, 2012 if you create this Topic it's not mean that all must help u,if someone have question can ask here. You shouldn't steal others' scripts and ask for help about it in their topics. Link to comment
Jokeℝ1472771893 Posted October 3, 2012 Share Posted October 3, 2012 steal? u ask here and i test it and i find errors. Link to comment
Pikachu Posted October 3, 2012 Author Share Posted October 3, 2012 steal? u ask here and i test it and i find errors. If you are going to test it, that means you should help me with it after that, not ask for help. Somebody lock this please. Link to comment
Recommended Posts