Sign in to follow this  
Pikachu

[HELP] script

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?

Share this post


Link to post

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) 

Share this post


Link to post

Seems like you have set the client side script as server side in the meta.xml.

Share this post


Link to post
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) 

Share this post


Link to post
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) 

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.