Jump to content

Set Job Panel


[UCG]Mike

Recommended Posts

Hey Guys ...

idk where is the problem

any one help me to chenge the server.lua or anything

Client.lua

local theJobsTable = { 
[0] = { "SWAT Team", "SWAT", 285 } 
  
} 
function centerWindow(center_window) 
    local screenW,screenH=guiGetScreenSize() 
    local windowW,windowH=guiGetSize(center_window,false) 
    local x,y = (screenW-windowW)/2,(screenH-windowH)/2 
    guiSetPosition(center_window,x,y,false) 
end 
  
hitWnd = guiCreateWindow(854, 329, 248, 399, "CNG ~ Setjob", false) 
cancel = guiCreateButton(132, 353, 83, 36, "Cancel", false, hitWnd) 
guiWindowSetSizable(hitWnd, false) 
guiWindowSetMovable(hitWnd, false) 
centerWindow(hitWnd) 
guiSetVisible(hitWnd, false) 
-- Gridlist 
buttonsGridList = guiCreateGridList(10, 67, 221, 276, false, hitWnd) 
local column1 = guiGridListAddColumn(buttonsGridList,"Occupation",0.5) 
local column2 = guiGridListAddColumn(buttonsGridList,"Team",0.5) 
local name = guiCreateEdit(16, 28, 211, 29, "", false, hitWnd) 
local set_Job = guiCreateButton(30, 353, 83, 36, "Set Job", false, hitWnd)  
guiSetProperty(hitButton, "NormalTextColour", "FFAAAAAA") 
closeButton = guiCreateButton(289, 165, 95, 34, "Close", false, hitWnd) 
addEventHandler("onClientGUIClick", root, function() if (source == closeButton) then guiSetVisible(hitWnd, false) showCursor(false) end end ) 
guiSetProperty(closeButton, "NormalTextColour", "FFAAAAAA") 
-- Labels 
guiSetFont(label1, "default-small") 
  
  
for i=0,#theJobsTable do 
    local occupation, team = theJobsTable[i][1], theJobsTable[i][2] 
    local row = guiGridListAddRow ( buttonsGridList ) 
    guiGridListSetItemText ( buttonsGridList, row, column1, occupation, false, false ) 
    guiGridListSetItemText ( buttonsGridList, row, column2, team, false, false ) 
    guiGridListSetItemData ( buttonsGridList, row, column1, i) 
end 
  
function openHitGUI () 
    if (getPlayerTeam(localPlayer)) and (getTeamName (getPlayerTeam ( localPlayer )) == "Staff") then 
    if (guiGetVisible(hitWnd)) then 
        guiSetVisible(hitWnd, false) 
            showCursor(false) 
        else 
        guiSetVisible(hitWnd, true) 
            showCursor(true) 
        end 
    end 
end 
addCommandHandler("setjob", openHitGUI) 
  
function closeWindow () 
    guiSetVisible(hitWnd, false) 
    showCursor(false) 
end 
addEventHandler("onClientGUIClick", cancel, closeWindow, false) 
function setJob() -- check 
    local row, column = guiGridListGetSelectedItem ( buttonsGridList ) 
    if ( row ) and ( column ) then 
        local jobsID = guiGridListGetItemData ( buttonsGridList, row, column ) 
        if ( jobsID ) then 
            local occupation = theJobsTable[jobsID][1] 
            local team = theJobsTable[jobsID][2] 
            local skin = theJobsTable[jobsID][3] 
            local setjobFrom = guiGetText(name) 
            if ( setjobFrom == "" ) then 
                local thePlayer = localPlayer 
                triggerServerEvent("changeJob", localPlayer, thePlayer, occupation, team, skin) 
                closeWindow () 
                outputChatBox("Your job has succesfully been changed to " ..occupation.."" , 220, 0, 0) 
            else 
                local thePlayers = getElementsByType("player") 
                for i=1, #thePlayers do 
                    if string.find(getPlayerName(thePlayers[i]):lower(), tostring(setjobFrom):lower(), 1, true) then 
                        local thePlayer = thePlayers[i] 
                        triggerServerEvent("changeJob", localPlayer, thePlayer, occupation, team, skin) 
                        closeWindow () 
                        outputChatBox("The job of" ..thePlayer.. "has succesfully been changed to"  
..occupation.."", 220, 0, 0) 
                        break 
                    end 
                end 
            end 
        end 
    end 
end 
addEventHandler("onClientGUIClick", set_Job, setJob, false) 
  

Server.lua

Teame1 = createTeam("SWAT", 0, 0, 255) 
CT = { [Teame1] = true } 
  
function CriminalSet () 
local team = getTeamFromName ( "SWAT" ) 
if team then 
setPlayerTeam ( source, team ) 
setPlayerNametagColor ( source, 255, 0, 0 ) 
setElementModel(source, 230) 
outputChatBox(" You are now Criminal ",localPlayer,255,0,0,true) 
else  
local teamx = getTeamFromName ( "SWAT" ) 
if teamx then 
cancelEvent() 
outputChatBox("You do not need to use this again!", thePlayer,0,255,255) 
end 
end 
end 
addEvent("changeJob", true) 
addEventHandler("changeJob", root, CriminalSet ) 

Link to comment

https://wiki.multitheftauto.com/wiki/Sc ... troduction

https://wiki.multitheftauto.com/wiki/In ... ng_the_GUI

https://wiki.multitheftauto.com/wiki/Debugging

Do you think we all knew scripting when we started? Nope. I have been scripting for 1,5 years to be able to script everything I want, but still I need to search for codes and even sometimes look how others made it. Not copy-pasting, only looking and trying to understand it. Then making it by myself. Start with the Scripting Introduction, then you already atleast know how to make a simple function with stuff. You only have to know and understand the basics of LUA, then you only have to get the code's from WIKI and you are done.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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