Jump to content

simple help with marker


Recommended Posts

for i = 1, #teams do 
    team = createTeam(teams[i][1], teams[i][2], teams[i][3], teams[i][4]) 
end 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i = 1, #jobs do 
            local players = getElementsByType("player") 
            ped = createPed(jobs[i][2], jobs[i][3], jobs[i][4], jobs[i][5]) 
            setElementRotation(ped, 0, 0, jobs[i][6]) 
            setElementFrozen(ped, true) 
            setElementData(ped, "job.ped", true) 
            setElementData(ped, "job.title", jobs[i][1]) 
            setElementData(ped, "job.team", jobs[i][7]) 
            setElementData(ped, "job.info", jobs[i][9]) 
            setElementData(ped, "job.r", jobs[i][10]) 
            setElementData(ped, "job.g", jobs[i][11]) 
            setElementData(ped, "job.b", jobs[i][12]) 
            setElementData(ped, "job.skin", jobs[i][2]) 
            setElementData(ped, "job.skinRequired", jobs[i][8]) 
            setElementData(ped, "job.enabled", jobs[i][13]) 
            blip = createBlip(jobs[i][3], jobs[i][4], jobs[i][5], 56, 2, 255, 255, 255, 255, 0, 350.0, root) 
        end 
    end) 
  

i just want to create marker Attached to ped/jobs and ty

im not a good Scripter

Edited by Guest
Link to comment

Here you go.

for i = 1, #teams do 
    team = createTeam(teams[i][1], teams[i][2], teams[i][3], teams[i][4]) 
end 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i = 1, #jobs do 
            local players = getElementsByType("player") 
            ped = createPed(jobs[i][2], jobs[i][3], jobs[i][4], jobs[i][5]) 
            setElementRotation(ped, 0, 0, jobs[i][6]) 
            setElementFrozen(ped, true) 
            setElementData(ped, "job.ped", true) 
            setElementData(ped, "job.title", jobs[i][1]) 
            setElementData(ped, "job.team", jobs[i][7]) 
            setElementData(ped, "job.info", jobs[i][9]) 
            setElementData(ped, "job.r", jobs[i][10]) 
            setElementData(ped, "job.g", jobs[i][11]) 
            setElementData(ped, "job.b", jobs[i][12]) 
            setElementData(ped, "job.skin", jobs[i][2]) 
            setElementData(ped, "job.skinRequired", jobs[i][8]) 
            setElementData(ped, "job.enabled", jobs[i][13]) 
            blip = createBlip(jobs[i][3], jobs[i][4], jobs[i][5], 56, 2, 255, 255, 255, 255, 0, 350.0, root) 
            createBlipAttachedTo(marker, 55) 
            attachElements(marker,ped) 
        end 
    end) 

Link to comment

for i = 1, #teams do 
    team = createTeam(teams[i][1], teams[i][2], teams[i][3], teams[i][4]) 
end 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i = 1, #jobs do 
            local players = getElementsByType("player") 
            ped = createPed(jobs[i][2], jobs[i][3], jobs[i][4], jobs[i][5]) 
            setElementRotation(ped, 0, 0, jobs[i][6]) 
            setElementFrozen(ped, true) 
            setElementData(ped, "job.ped", true) 
            setElementData(ped, "job.title", jobs[i][1]) 
            setElementData(ped, "job.team", jobs[i][7]) 
            setElementData(ped, "job.info", jobs[i][9]) 
            setElementData(ped, "job.r", jobs[i][10]) 
            setElementData(ped, "job.g", jobs[i][11]) 
            setElementData(ped, "job.b", jobs[i][12]) 
            setElementData(ped, "job.skin", jobs[i][2]) 
            setElementData(ped, "job.skinRequired", jobs[i][8]) 
            setElementData(ped, "job.enabled", jobs[i][13]) 
            blip = createBlip(jobs[i][3], jobs[i][4], jobs[i][5], 56, 2, 255, 255, 255, 255, 0, 350.0, root) 
        end 
    end) 
     
addEvent("givePlayerJob", true) 
  
addEventHandler("givePlayerJob", root, 
    function(job, team, r, g, b, skinID, skinRequired) 
        local pTeam = getTeamFromName(team) 
        setPlayerTeam(source, pTeam) 
        setElementData(source, "Role", job) 
        setPlayerNametagColor(source, r, g, b) 
        if skinRequired then 
            setElementModel(source, skinID) 
        end 
        if job == "Paramedic" then 
            giveWeapon(source, 41, 9999, true) 
            elseif job == "Police Officer" or job == "Detective" or job == "Traffic Officer" then 
            giveWeapon(source, 3, 1, true) 
        end 
    end) 
     
     
    function getJobsTable(client,bool) 
    if bool then 
        triggerClientEvent(client,"returnJobsTable",client,jobTable) 
    end 
    return jobTable 
end 
addEvent("getJobTable",true) 
addEventHandler("getJobTable",root,getJobsTable) 
  
addEventHandler("onResourceStop", resourceRoot, 
function () 
    for i,v in pairs(getElementsByType("player")) do 
        if (getPlayerTeam(v)) then 
            local team = getTeamName(getPlayerTeam(v)) 
            setElementData(v,"tempTeam",tostring(team)) 
        end 
        triggerClientEvent(v,"returnJobsTable",v,jobTable) 
    end 
end) 
  
addEventHandler("onResourceStart", resourceRoot, 
function () 
    for index, team in pairs(teamTable) do 
        createTeam(tostring(team[1]), tonumber(team[2]), tonumber(team[3]), tonumber(team[4])) 
    end 
    for i,v in pairs(jobTable) do 
    local ped = createPed(tonumber(v.skin), tostring(v.x), tostring(v.y), tostring(v.z)+1) 
    if ped then 
        setPedRotation(ped, tonumber(v.rot)) 
        jobPeds[ped] = {v.team, v.role, v.weapons, v.desc, v.skin, v.wl, v.hours, v.arrests} 
        setElementData(ped,"jobPed",true) 
        setElementData(ped,"jobName",v.role) 
        setElementData(ped,"jobColor",{v.r, v.g, v.b}) 
        setElementFrozen(ped, true) 
    if v.int then 
        setElementInterior(ped, tonumber(v.int)) 
            end 
        end 
    end 
    for i,v in pairs(getElementsByType("player")) do 
    local accData = getElementData(v,"tempTeam") 
    if accData then 
        setTimer(setPlayerTeam,2000,1,v,getTeamFromName(accData)) 
    end 
    local r, g, b = getPlayerNametagColor(v) 
    plrBlips[v] = createBlipAttachedTo(v,0,2,r,g,b,255,0,1500) 
    end 
    for commandName,_ in pairs(callCommands) do 
        addCommandHandler(tostring(commandName),onJobCommandCalled) 
    end  
end) 
  

this is code i just want a marker attached to all jobs/peds :) and thank you

Link to comment
for i = 1, #teams do 
    team = createTeam(teams[i][1], teams[i][2], teams[i][3], teams[i][4]) 
end 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i = 1, #jobs do 
            local players = getElementsByType("player") 
            local marker = createMarker(0,0,0,"cylinder",1,255,255,0,255) 
            ped = createPed(jobs[i][2], jobs[i][3], jobs[i][4], jobs[i][5]) 
            setElementRotation(ped, 0, 0, jobs[i][6]) 
            setElementFrozen(ped, true) 
            setElementData(ped, "job.ped", true) 
            setElementData(ped, "job.title", jobs[i][1]) 
            setElementData(ped, "job.team", jobs[i][7]) 
            setElementData(ped, "job.info", jobs[i][9]) 
            setElementData(ped, "job.r", jobs[i][10]) 
            setElementData(ped, "job.g", jobs[i][11]) 
            setElementData(ped, "job.b", jobs[i][12]) 
            setElementData(ped, "job.skin", jobs[i][2]) 
            setElementData(ped, "job.skinRequired", jobs[i][8]) 
            setElementData(ped, "job.enabled", jobs[i][13]) 
            blip = createBlip(jobs[i][3], jobs[i][4], jobs[i][5], 56, 2, 255, 255, 255, 255, 0, 350.0, root) 
            attachElements(marker,ped,0,0,2) 
        end 
    end) 
    
addEvent("givePlayerJob", true) 
  
addEventHandler("givePlayerJob", root, 
    function(job, team, r, g, b, skinID, skinRequired) 
        local pTeam = getTeamFromName(team) 
        setPlayerTeam(source, pTeam) 
        setElementData(source, "Role", job) 
        setPlayerNametagColor(source, r, g, b) 
        if skinRequired then 
            setElementModel(source, skinID) 
        end 
        if job == "Paramedic" then 
            giveWeapon(source, 41, 9999, true) 
            elseif job == "Police Officer" or job == "Detective" or job == "Traffic Officer" then 
            giveWeapon(source, 3, 1, true) 
        end 
    end) 
    
    
    function getJobsTable(client,bool) 
    if bool then 
        triggerClientEvent(client,"returnJobsTable",client,jobTable) 
    end 
    return jobTable 
end 
addEvent("getJobTable",true) 
addEventHandler("getJobTable",root,getJobsTable) 
  
addEventHandler("onResourceStop", resourceRoot, 
function () 
    for i,v in pairs(getElementsByType("player")) do 
        if (getPlayerTeam(v)) then 
            local team = getTeamName(getPlayerTeam(v)) 
            setElementData(v,"tempTeam",tostring(team)) 
        end 
        triggerClientEvent(v,"returnJobsTable",v,jobTable) 
    end 
end) 
  
addEventHandler("onResourceStart", resourceRoot, 
function () 
    for index, team in pairs(teamTable) do 
        createTeam(tostring(team[1]), tonumber(team[2]), tonumber(team[3]), tonumber(team[4])) 
    end 
    for i,v in pairs(jobTable) do 
    local ped = createPed(tonumber(v.skin), tostring(v.x), tostring(v.y), tostring(v.z)+1) 
    if ped then 
        setPedRotation(ped, tonumber(v.rot)) 
        jobPeds[ped] = {v.team, v.role, v.weapons, v.desc, v.skin, v.wl, v.hours, v.arrests} 
        setElementData(ped,"jobPed",true) 
        setElementData(ped,"jobName",v.role) 
        setElementData(ped,"jobColor",{v.r, v.g, v.b}) 
        setElementFrozen(ped, true) 
    if v.int then 
        setElementInterior(ped, tonumber(v.int)) 
            end 
        end 
    end 
    for i,v in pairs(getElementsByType("player")) do 
    local accData = getElementData(v,"tempTeam") 
    if accData then 
        setTimer(setPlayerTeam,2000,1,v,getTeamFromName(accData)) 
    end 
    local r, g, b = getPlayerNametagColor(v) 
    plrBlips[v] = createBlipAttachedTo(v,0,2,r,g,b,255,0,1500) 
    end 
    for commandName,_ in pairs(callCommands) do 
        addCommandHandler(tostring(commandName),onJobCommandCalled) 
    end  
end) 
  

Link to comment

try

for i = 1, #teams do 
    team = createTeam(teams[i][1], teams[i][2], teams[i][3], teams[i][4]) 
end 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i = 1, #jobs do 
            local players = getElementsByType("player") 
            local marker = createMarker(jobs[i][3], jobs[i][4], jobs[i][5]-0.8,"cylinder",1,255,255,0,255) 
            ped = createPed(jobs[i][2], jobs[i][3], jobs[i][4], jobs[i][5]) 
            setElementRotation(ped, 0, 0, jobs[i][6]) 
            setElementFrozen(ped, true) 
            setElementData(ped, "job.ped", true) 
            setElementData(ped, "job.title", jobs[i][1]) 
            setElementData(ped, "job.team", jobs[i][7]) 
            setElementData(ped, "job.info", jobs[i][9]) 
            setElementData(ped, "job.r", jobs[i][10]) 
            setElementData(ped, "job.g", jobs[i][11]) 
            setElementData(ped, "job.b", jobs[i][12]) 
            setElementData(ped, "job.skin", jobs[i][2]) 
            setElementData(ped, "job.skinRequired", jobs[i][8]) 
            setElementData(ped, "job.enabled", jobs[i][13]) 
            blip = createBlip(jobs[i][3], jobs[i][4], jobs[i][5], 56, 2, 255, 255, 255, 255, 0, 350.0, root) 
            attachElements(marker,ped,0,0,2) 
        end 
    end) 
    
addEvent("givePlayerJob", true) 
  
addEventHandler("givePlayerJob", root, 
    function(job, team, r, g, b, skinID, skinRequired) 
        local pTeam = getTeamFromName(team) 
        setPlayerTeam(source, pTeam) 
        setElementData(source, "Role", job) 
        setPlayerNametagColor(source, r, g, b) 
        if skinRequired then 
            setElementModel(source, skinID) 
        end 
        if job == "Paramedic" then 
            giveWeapon(source, 41, 9999, true) 
            elseif job == "Police Officer" or job == "Detective" or job == "Traffic Officer" then 
            giveWeapon(source, 3, 1, true) 
        end 
    end) 
    
    
    function getJobsTable(client,bool) 
    if bool then 
        triggerClientEvent(client,"returnJobsTable",client,jobTable) 
    end 
    return jobTable 
end 
addEvent("getJobTable",true) 
addEventHandler("getJobTable",root,getJobsTable) 
  
addEventHandler("onResourceStop", resourceRoot, 
function () 
    for i,v in pairs(getElementsByType("player")) do 
        if (getPlayerTeam(v)) then 
            local team = getTeamName(getPlayerTeam(v)) 
            setElementData(v,"tempTeam",tostring(team)) 
        end 
        triggerClientEvent(v,"returnJobsTable",v,jobTable) 
    end 
end) 
  
addEventHandler("onResourceStart", resourceRoot, 
function () 
    for index, team in pairs(teamTable) do 
        createTeam(tostring(team[1]), tonumber(team[2]), tonumber(team[3]), tonumber(team[4])) 
    end 
    for i,v in pairs(jobTable) do 
    local ped = createPed(tonumber(v.skin), tostring(v.x), tostring(v.y), tostring(v.z)+1) 
    if ped then 
        setPedRotation(ped, tonumber(v.rot)) 
        jobPeds[ped] = {v.team, v.role, v.weapons, v.desc, v.skin, v.wl, v.hours, v.arrests} 
        setElementData(ped,"jobPed",true) 
        setElementData(ped,"jobName",v.role) 
        setElementData(ped,"jobColor",{v.r, v.g, v.b}) 
        setElementFrozen(ped, true) 
    if v.int then 
        setElementInterior(ped, tonumber(v.int)) 
            end 
        end 
    end 
    for i,v in pairs(getElementsByType("player")) do 
    local accData = getElementData(v,"tempTeam") 
    if accData then 
        setTimer(setPlayerTeam,2000,1,v,getTeamFromName(accData)) 
    end 
    local r, g, b = getPlayerNametagColor(v) 
    plrBlips[v] = createBlipAttachedTo(v,0,2,r,g,b,255,0,1500) 
    end 
    for commandName,_ in pairs(callCommands) do 
        addCommandHandler(tostring(commandName),onJobCommandCalled) 
    end 
end) 

Link to comment
for i = 1, #teams do 
    team = createTeam(teams[i][1], teams[i][2], teams[i][3], teams[i][4]) 
end 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i = 1, #jobs do 
            local players = getElementsByType("player") 
            local marker = createMarker(0,0,0,"cylinder",1,255,255,0,255) 
            ped = createPed(jobs[i][2], jobs[i][3], jobs[i][4], jobs[i][5]) 
            setElementRotation(ped, 0, 0, jobs[i][6]) 
            setElementFrozen(ped, true) 
            setElementData(ped, "job.ped", true) 
            setElementData(ped, "job.title", jobs[i][1]) 
            setElementData(ped, "job.team", jobs[i][7]) 
            setElementData(ped, "job.info", jobs[i][9]) 
            setElementData(ped, "job.r", jobs[i][10]) 
            setElementData(ped, "job.g", jobs[i][11]) 
            setElementData(ped, "job.b", jobs[i][12]) 
            setElementData(ped, "job.skin", jobs[i][2]) 
            setElementData(ped, "job.skinRequired", jobs[i][8]) 
            setElementData(ped, "job.enabled", jobs[i][13]) 
            blip = createBlip(jobs[i][3], jobs[i][4], jobs[i][5], 56, 2, 255, 255, 255, 255, 0, 350.0, root) 
            attachElements(marker,ped,0,0,1) 
        end 
    end) 
    
addEvent("givePlayerJob", true) 
  
addEventHandler("givePlayerJob", root, 
    function(job, team, r, g, b, skinID, skinRequired) 
        local pTeam = getTeamFromName(team) 
        setPlayerTeam(source, pTeam) 
        setElementData(source, "Role", job) 
        setPlayerNametagColor(source, r, g, b) 
        if skinRequired then 
            setElementModel(source, skinID) 
        end 
        if job == "Paramedic" then 
            giveWeapon(source, 41, 9999, true) 
            elseif job == "Police Officer" or job == "Detective" or job == "Traffic Officer" then 
            giveWeapon(source, 3, 1, true) 
        end 
    end) 
    
    
    function getJobsTable(client,bool) 
    if bool then 
        triggerClientEvent(client,"returnJobsTable",client,jobTable) 
    end 
    return jobTable 
end 
addEvent("getJobTable",true) 
addEventHandler("getJobTable",root,getJobsTable) 
  
addEventHandler("onResourceStop", resourceRoot, 
function () 
    for i,v in pairs(getElementsByType("player")) do 
        if (getPlayerTeam(v)) then 
            local team = getTeamName(getPlayerTeam(v)) 
            setElementData(v,"tempTeam",tostring(team)) 
        end 
        triggerClientEvent(v,"returnJobsTable",v,jobTable) 
    end 
end) 
  
addEventHandler("onResourceStart", resourceRoot, 
function () 
    for index, team in pairs(teamTable) do 
        createTeam(tostring(team[1]), tonumber(team[2]), tonumber(team[3]), tonumber(team[4])) 
    end 
    for i,v in pairs(jobTable) do 
    local ped = createPed(tonumber(v.skin), tostring(v.x), tostring(v.y), tostring(v.z)+1) 
    if ped then 
        setPedRotation(ped, tonumber(v.rot)) 
        jobPeds[ped] = {v.team, v.role, v.weapons, v.desc, v.skin, v.wl, v.hours, v.arrests} 
        setElementData(ped,"jobPed",true) 
        setElementData(ped,"jobName",v.role) 
        setElementData(ped,"jobColor",{v.r, v.g, v.b}) 
        setElementFrozen(ped, true) 
    if v.int then 
        setElementInterior(ped, tonumber(v.int)) 
            end 
        end 
    end 
    for i,v in pairs(getElementsByType("player")) do 
    local accData = getElementData(v,"tempTeam") 
    if accData then 
        setTimer(setPlayerTeam,2000,1,v,getTeamFromName(accData)) 
    end 
    local r, g, b = getPlayerNametagColor(v) 
    plrBlips[v] = createBlipAttachedTo(v,0,2,r,g,b,255,0,1500) 
    end 
    for commandName,_ in pairs(callCommands) do 
        addCommandHandler(tostring(commandName),onJobCommandCalled) 
    end 
end) 
  

Link to comment

thank you so much really but can u help me in a last thing the job panel shows when i press 'M' and Click on ped i want to change it when a player hit the marker

  
addEventHandler("onClientClick", root, 
    function(button, state, aX, aY, wX, wY, wZ, clickedElement) 
            local pX, pY, pZ = getElementPosition(localPlayer) 
            if clickedElement and button == "right" and state == "up" and (getElementType(clickedElement) == "ped") and (getDistanceBetweenPoints3D(pX, pY, pZ, wX, wY, wZ) <= 2) then 
                if (getElementData(clickedElement, "job.ped") == true) then 
                    job = getElementData(clickedElement, "job.title") 
                    team = getElementData(clickedElement, "job.team") 
                    info = getElementData(clickedElement, "job.info") 
                    cR = getElementData(clickedElement, "job.r") 
                    cG = getElementData(clickedElement, "job.g") 
                    cB = getElementData(clickedElement, "job.b") 
                    skinID = getElementData(clickedElement, "job.skin") 
                    skinRequired = getElementData(clickedElement, "job.skinRequired") 
                    enabled = getElementData(clickedElement, "job.enabled") 
                    arrests = getElementData(localPlayer, "Arrests") 
                    showJobWindow(true) 
                end 
            end 
    end) 
  
jobWnd = guiCreateWindow(503,255,327,267,"test",false) 
guiWindowSetSizable(jobWnd,false) 
jobLabel = guiCreateLabel(11,24,303,186,"DESCRIPTION",false,jobWnd) 
guiSetFont(jobLabel,"clear-normal") 
takeButt = guiCreateButton(11,219,141,36,"Take Job",false,jobWnd) 
closeButt = guiCreateButton(173,219,141,36,"Close",false,jobWnd) 
addEventHandler("onClientGUIClick", closeButt, function() showJobWindow(false) end, false) 
guiSetVisible(jobWnd, false) 
  
addEventHandler("onClientGUIClick", takeButt,  
    function() 
        if enabled then 
            if job == "Detective" and arrests < 150 then  outputChatBox("You need "..150-arrests.." arrests before you can get this job!", 255, 0, 0) return end 
            if job == "Traffic Officer" and arrests < 75  outputChatBox("You need "..75-arrests.." arrests before you can get this job!", 255, 0, 0) return end 
            outputChatBox("You are now employed as a "..job.." !", 0, 255, 0) 
            guiSetVisible(jobWnd, false) 
            triggerServerEvent("givePlayerJob", localPlayer, job, team, cR, cG, cB, skinID, skinRequired) 
            else 
            outputChatBox("This job is not available yet!", 255, 0, 0) 
        end 
    end, false) 
  
function showJobWindow(state) 
    if state == true then 
        guiSetVisible(jobWnd, true) 
        guiSetText(jobLabel, tostring(info)) 
        guiSetText(jobWnd, tostring(job)) 
        else 
        guiSetVisible(jobWnd, false) 
    end 
end 
  
addEventHandler("onClientPedDamage", root, 
    function() 
        if (getElementData(source, "job.ped") == true) then 
            cancelEvent() 
        end 
    end) 
  
bindKey("m", "down", 
function() 
    showCursor(not isCursorShowing()) 
end) 
  

Link to comment

Client:

addEvent("ShowTheGui",true) 
 addEventHandler("ShowTheGui",root, 
 function() 
        showJobWindow(true) 
 end) 
  
  
  
jobWnd = guiCreateWindow(503,255,327,267,"test",false) 
guiWindowSetSizable(jobWnd,false) 
jobLabel = guiCreateLabel(11,24,303,186,"DESCRIPTION",false,jobWnd) 
guiSetFont(jobLabel,"clear-normal") 
takeButt = guiCreateButton(11,219,141,36,"Take Job",false,jobWnd) 
closeButt = guiCreateButton(173,219,141,36,"Close",false,jobWnd) 
addEventHandler("onClientGUIClick", closeButt, function() showJobWindow(false) end, false) 
guiSetVisible(jobWnd, false) 
  
addEventHandler("onClientGUIClick", takeButt, 
    function() 
        if enabled then 
            if job == "Detective" and arrests < 150 then  outputChatBox("You need "..150-arrests.." arrests before you can get this job!", 255, 0, 0) return end 
            if job == "Traffic Officer" and arrests < 75 then outputChatBox("You need "..75-arrests.." arrests before you can get this job!", 255, 0, 0) return end 
            outputChatBox("You are now employed as a "..job.." !", 0, 255, 0) 
            guiSetVisible(jobWnd, false) 
            triggerServerEvent("givePlayerJob", localPlayer, job, team, cR, cG, cB, skinID, skinRequired) 
            else 
            outputChatBox("This job is not available yet!", 255, 0, 0) 
        end 
    end, false) 
  
function showJobWindow(state) 
    if state == true then 
        guiSetVisible(jobWnd, true) 
        guiSetText(jobLabel, tostring(info)) 
        guiSetText(jobWnd, tostring(job)) 
        else 
        guiSetVisible(jobWnd, false) 
    end 
end 
  
addEventHandler("onClientPedDamage", root, 
    function() 
        if (getElementData(source, "job.ped") == true) then 
            cancelEvent() 
        end 
    end) 
  
bindKey("m", "down", 
function() 
    showCursor(not isCursorShowing()) 
end) 

Server:

for i = 1, #teams do 
    team = createTeam(teams[i][1], teams[i][2], teams[i][3], teams[i][4]) 
end 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i = 1, #jobs do 
            local players = getElementsByType("player") 
            marker = createMarker(0,0,0,"cylinder",1,255,255,0,255) 
            ped = createPed(jobs[i][2], jobs[i][3], jobs[i][4], jobs[i][5]) 
            setElementRotation(ped, 0, 0, jobs[i][6]) 
            setElementFrozen(ped, true) 
            setElementData(ped, "job.ped", true) 
            setElementData(ped, "job.title", jobs[i][1]) 
            setElementData(ped, "job.team", jobs[i][7]) 
            setElementData(ped, "job.info", jobs[i][9]) 
            setElementData(ped, "job.r", jobs[i][10]) 
            setElementData(ped, "job.g", jobs[i][11]) 
            setElementData(ped, "job.b", jobs[i][12]) 
            setElementData(ped, "job.skin", jobs[i][2]) 
            setElementData(ped, "job.skinRequired", jobs[i][8]) 
            setElementData(ped, "job.enabled", jobs[i][13]) 
            blip = createBlip(jobs[i][3], jobs[i][4], jobs[i][5], 56, 2, 255, 255, 255, 255, 0, 350.0, root) 
            attachElements(marker,ped,0,0,1) 
        end 
    end) 
     
    addEventHandler("onMarkerHit",marker, 
    function(player) 
    triggerClientEvent("ShowTheGui",getRootElement()) 
    end) 
    
addEvent("givePlayerJob", true) 
  
addEventHandler("givePlayerJob", root, 
    function(job, team, r, g, b, skinID, skinRequired) 
        local pTeam = getTeamFromName(team) 
        setPlayerTeam(source, pTeam) 
        setElementData(source, "Role", job) 
        setPlayerNametagColor(source, r, g, b) 
        if skinRequired then 
            setElementModel(source, skinID) 
        end 
        if job == "Paramedic" then 
            giveWeapon(source, 41, 9999, true) 
            elseif job == "Police Officer" or job == "Detective" or job == "Traffic Officer" then 
            giveWeapon(source, 3, 1, true) 
        end 
    end) 
    
    
    function getJobsTable(client,bool) 
    if bool then 
        triggerClientEvent(client,"returnJobsTable",client,jobTable) 
    end 
    return jobTable 
end 
addEvent("getJobTable",true) 
addEventHandler("getJobTable",root,getJobsTable) 
  
addEventHandler("onResourceStop", resourceRoot, 
function () 
    for i,v in pairs(getElementsByType("player")) do 
        if (getPlayerTeam(v)) then 
            local team = getTeamName(getPlayerTeam(v)) 
            setElementData(v,"tempTeam",tostring(team)) 
        end 
        triggerClientEvent(v,"returnJobsTable",v,jobTable) 
    end 
end) 
  
addEventHandler("onResourceStart", resourceRoot, 
function () 
    for index, team in pairs(teamTable) do 
        createTeam(tostring(team[1]), tonumber(team[2]), tonumber(team[3]), tonumber(team[4])) 
    end 
    for i,v in pairs(jobTable) do 
    local ped = createPed(tonumber(v.skin), tostring(v.x), tostring(v.y), tostring(v.z)+1) 
    if ped then 
        setPedRotation(ped, tonumber(v.rot)) 
        jobPeds[ped] = {v.team, v.role, v.weapons, v.desc, v.skin, v.wl, v.hours, v.arrests} 
        setElementData(ped,"jobPed",true) 
        setElementData(ped,"jobName",v.role) 
        setElementData(ped,"jobColor",{v.r, v.g, v.b}) 
        setElementFrozen(ped, true) 
    if v.int then 
        setElementInterior(ped, tonumber(v.int)) 
            end 
        end 
    end 
    for i,v in pairs(getElementsByType("player")) do 
    local accData = getElementData(v,"tempTeam") 
    if accData then 
        setTimer(setPlayerTeam,2000,1,v,getTeamFromName(accData)) 
    end 
    local r, g, b = getPlayerNametagColor(v) 
    plrBlips[v] = createBlipAttachedTo(v,0,2,r,g,b,255,0,1500) 
    end 
    for commandName,_ in pairs(callCommands) do 
        addCommandHandler(tostring(commandName),onJobCommandCalled) 
    end 
end) 
  

Link to comment

Try this ( server sided )

for i = 1, #teams do 
    team = createTeam(teams[i][1], teams[i][2], teams[i][3], teams[i][4]) 
end 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i = 1, #jobs do 
            local players = getElementsByType("player") 
            marker = createMarker(0,0,0,"cylinder",1,255,255,0,255) 
            ped = createPed(jobs[i][2], jobs[i][3], jobs[i][4], jobs[i][5]) 
            setElementRotation(ped, 0, 0, jobs[i][6]) 
            setElementFrozen(ped, true) 
            setElementData(ped, "job.ped", true) 
            setElementData(ped, "job.title", jobs[i][1]) 
            setElementData(ped, "job.team", jobs[i][7]) 
            setElementData(ped, "job.info", jobs[i][9]) 
            setElementData(ped, "job.r", jobs[i][10]) 
            setElementData(ped, "job.g", jobs[i][11]) 
            setElementData(ped, "job.b", jobs[i][12]) 
            setElementData(ped, "job.skin", jobs[i][2]) 
            setElementData(ped, "job.skinRequired", jobs[i][8]) 
            setElementData(ped, "job.enabled", jobs[i][13]) 
            blip = createBlip(jobs[i][3], jobs[i][4], jobs[i][5], 56, 2, 255, 255, 255, 255, 0, 350.0, root) 
            attachElements(marker,ped,0,0,1) 
        end 
    end) 
    
    addEventHandler("onMarkerHit",marker, 
    function(player) 
    triggerClientEvent(player, "ShowTheGui", player) 
    end) 
    
addEvent("givePlayerJob", true) 
  
addEventHandler("givePlayerJob", root, 
    function(job, team, r, g, b, skinID, skinRequired) 
        local pTeam = getTeamFromName(team) 
        setPlayerTeam(source, pTeam) 
        setElementData(source, "Role", job) 
        setPlayerNametagColor(source, r, g, b) 
        if skinRequired then 
            setElementModel(source, skinID) 
        end 
        if job == "Paramedic" then 
            giveWeapon(source, 41, 9999, true) 
            elseif job == "Police Officer" or job == "Detective" or job == "Traffic Officer" then 
            giveWeapon(source, 3, 1, true) 
        end 
    end) 
    
    
    function getJobsTable(client,bool) 
    if bool then 
        triggerClientEvent(client,"returnJobsTable",client,jobTable) 
    end 
    return jobTable 
end 
addEvent("getJobTable",true) 
addEventHandler("getJobTable",root,getJobsTable) 
  
addEventHandler("onResourceStop", resourceRoot, 
function () 
    for i,v in pairs(getElementsByType("player")) do 
        if (getPlayerTeam(v)) then 
            local team = getTeamName(getPlayerTeam(v)) 
            setElementData(v,"tempTeam",tostring(team)) 
        end 
        triggerClientEvent(v,"returnJobsTable",v,jobTable) 
    end 
end) 
  
addEventHandler("onResourceStart", resourceRoot, 
function () 
    for index, team in pairs(teamTable) do 
        createTeam(tostring(team[1]), tonumber(team[2]), tonumber(team[3]), tonumber(team[4])) 
    end 
    for i,v in pairs(jobTable) do 
    local ped = createPed(tonumber(v.skin), tostring(v.x), tostring(v.y), tostring(v.z)+1) 
    if ped then 
        setPedRotation(ped, tonumber(v.rot)) 
        jobPeds[ped] = {v.team, v.role, v.weapons, v.desc, v.skin, v.wl, v.hours, v.arrests} 
        setElementData(ped,"jobPed",true) 
        setElementData(ped,"jobName",v.role) 
        setElementData(ped,"jobColor",{v.r, v.g, v.b}) 
        setElementFrozen(ped, true) 
    if v.int then 
        setElementInterior(ped, tonumber(v.int)) 
            end 
        end 
    end 
    for i,v in pairs(getElementsByType("player")) do 
    local accData = getElementData(v,"tempTeam") 
    if accData then 
        setTimer(setPlayerTeam,2000,1,v,getTeamFromName(accData)) 
    end 
    local r, g, b = getPlayerNametagColor(v) 
    plrBlips[v] = createBlipAttachedTo(v,0,2,r,g,b,255,0,1500) 
    end 
    for commandName,_ in pairs(callCommands) do 
        addCommandHandler(tostring(commandName),onJobCommandCalled) 
    end 
end) 
  

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...