Jump to content

[HELP] script


Pikachu

Recommended Posts

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

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
yeah :D my bad,but when i press F2 it's show me Gui without Cursor then when i press F2 again i see only Cursor :D
function ShowGUI() 
    guiSetVisible(JobGUI, not guiGetVisible(JobGUI)) 
    showCursor(guiGetVisible(JobGUI)) 
end 
bindKey("F2","down", ShowGUI) 

Link to comment
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
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...