Jump to content

help.


Nerses

Recommended Posts

Eror

ERROR: [gameplay]/UIPbusiness/business.slua:363: attempt to concatenate local 'occupation' (a boolean value)

Script

name = {} 
isPlayerWorking = {}
oldPlayerJob = {}
jobHunt = {}
specialGroups = {["FBI"]=true, ["Special Forces"]=true, ["FreeFamily"]=true}
jobsLocation = {
    --LS
   
    {job = "Fisherman", x = 729, y = -1488, z = 1, r = 255, g = 255, b = 0, team = "Civilian Employees", jobEvent = "event", maxWL = 3, description = "Will be improved soon"}, -- LS
   
    {job = "Pilot", x = 1957, y = -2184, z = 13, r = 255, g = 255, b = 0, team = "Civilian Employees", skin = {61}, jobEvent = "pilotTaken", maxWL = 3, description = "As a pilot, you must fly around to\neach airport and deliver\nthe cargo."},
 
    {job = "Trucker", x = 2190, y = -2252, z = 13, r = 255, g = 255, b = 0, team = "Civilian Employees", skin = {128, 133, 202, 206}, jobEvent = "truckerTaken", maxWL = 3, description = "As a trucker, you must drive to\nthe destination given and deliver the cargo."},
 
    {job = "Bus Driver", x = 1109, y = -1807, z = 16, r = 255, g = 255, b = 0, team = "Civilian Employees", skin = {255}, jobEvent = "busTakenLS", maxWL = 3, description = "As a Bus Driver, you must drive\naround to each of the stops. "},
 
    {job = "Taxi Driver", x = 1742, y = -1863, z = 13, r = 255, g = 255, b = 0, team = "Civilian Employees", skin = {253}, jobEvent = "taxiTakenLS", maxWL = 3, description = "As a taxi driver, you must go to\neach pedestrian and take\nthem to there location."},
 
    --{job = "Train Driver", x = 1754, y = -1945, z = 13, r = 255, g = 255, b = 0, team = "Civilian Employees", skin = {253}, jobEvent = "trainTaken", maxWL = 3, description = "As a Train Driver, you must go to\neach train stop."},
 
    {job = "Mechanic", x = 1048, y = -1028, z = 31.7, r = 255, g = 255, b = 0, team = "Civilian Employees", skin = {50, 305, 309, 268}, jobEvent = "mechanicTaken", maxWL = 3, description = "As a mechanic, you must go around\nrepairing other peoples cars\nor maybe even your own.\n\nTo repair a vehicle press 'm' to\ntoggle the cursor and click on a vehicle"},
   
    {job = "Medic", x = 1178, y = -1328, z = 13.5, r = 0, g = 255, b = 255, team = "Emergency Services", skin = {274, 275, 276}, jobEvent = "medicTaken", maxWL = 0, description = "As a medic, you must go around healing\npeople with the spray can given to you.\n\nIf somebody enteres your ambulace you\nget paid too"},
 
    {job = "Medic", x = 2025, y = -1404, z = 17, r = 0, g = 255, b = 255, team = "Emergency Services", skin = {274, 275, 276}, jobEvent = "medicTaken", maxWL = 0, description = "As a medic, you must go around healing\npeople with the spray can given to you.\n\nIf somebody enteres your ambulace you\nget paid too"},
 
    {job = "Police Officer", x = 1574.5, y = -1635.30, z = 12.60, r = 67, g = 156, b = 255, team = "Police Force", skin = {280, 281, 282, 283, 284, 288, 246}, jobEvent = "policeTaken", maxWL = 0, description = "As a Police Officer, you must go around\narresting wanted people and bringing\nthem back to the nearest police\nstation to put them in jail."},
   
    {job = "Hooker", x = 1087.63, y = -922.48, z = 43.39, r = 225, g = 0, b = 228, team = "Hookers", skin = {92, 138, 87, 178, 244, 246, 257}, jobEvent = "hookerTaken", maxWL = 0, description = "Welcome Hooker there is 100 waiting you \"{SMILIES_PATH}/icon_smile.gif\" alt=\"\" title=\"Smile\" />."},
   
   
    --SF
   
    {job = "Pilot", x = -1545, y = -441, z = 5.3, r = 255, g = 255, b = 0, team = "Civilian Employees", skin = {61}, jobEvent = "pilotTaken", maxWL = 3, description = "As a pilot, you must go around to\neach airport and deliver the cargo."},
 
    {job = "Trucker", x = -1719, y = -134, z = 3, r = 255, g = 255, b = 0, team = "Civilian Employees", skin = {128, 133, 202, 206}, jobEvent = "truckerTaken", maxWL = 3, description = "As a trucker, you must drive\nto the destination given\nand deliver the cargo."},
 
    {job = "Bus Driver", x = -2275, y = 534, z = 34.5, r = 255, g = 255, b = 0, team = "Civilian Employees", skin = {255}, jobEvent = "busTakenSF", maxWL = 3, description = "As a Bus Driver, you must drive\around to each of the stops."},
 
    {job = "Taxi Driver", x = -1984, y = 130, z = 27, r = 255, g = 255, b = 0, team = "Civilian Employees", skin = {253}, jobEvent = "taxiTakenSF", maxWL = 3, description = "As a taxi driver, you must go to\each pedestrian and take\nthem to there location."},
 
    {job = "Mechanic", x = -1895, y = 275, z = 40.7, r = 255, g = 255, b = 0, team = "Civilian Employees", skin = {50, 305, 309, 268}, jobEvent = "mechanicTaken", maxWL = 3, description = "As a mechanic, you must go around\nrepairing other peoples cars\nor maybe even your own.\n\nTo repair a vehicle press 'm' to\ntoggle the cursor and click on a vehicle"},
 
    {job = "Medic", x = -2669, y = 638, z = 14, r = 0, g = 255, b = 255, team = "Emergency Services", skin = {274, 275, 276}, jobEvent = "medicTaken", maxWL = 0, description = "As a medic, you must go around healing\npeople with the spray can given to you.\n\nIf somebody enteres your ambulace you\nget paid too"},
 
    {job = "Police Officer", x = -1613, y = 716, z = 12.8, r = 67, g = 156, b = 255, team = "Police Force", skin = {280, 281, 282, 283, 284, 288, 246}, jobEvent = "policeTaken", maxWL = 0, description = "As a Police Officer, you must go around\narresting wanted people and bringing\nthem back to the nearest police\nstation to put them in jail."},
   
    --LV
   
    {job = "Medic", x = 1607, y = 1823, z = 9.8, r = 0, g = 255, b = 255, team = "Emergency Services", jobEvent = "event", maxWL = 1, description = "As a medic, you must go around healing people with the spray can given to you. \n\nIf somebody enters your ambulance you get paid too."}, -- LV
   
    {job = "Hooker", x = 2085.99, y = 2077.58, z = 11.05, r = 225, g = 0, b = 228, team = "Hookers", skin = {92, 138, 87, 178, 244, 246, 257}, jobEvent = "hookerTaken", maxWL = 0, description = "Welcome Hooker there is 100 waiting you \"{SMILIES_PATH}/icon_smile.gif\" alt=\"\" title=\"Smile\" />."},
   
    {job = "Police Officer", x = 2302, y = 2433.80, z = 9.89, r = 67, g = 156, b = 255, team = "Police Force", skin = {280, 281, 282, 283, 284, 288, 246}, jobEvent = "policeTaken", maxWL = 0, description = "As a Police Officer, you must go around\narresting wanted people and bringing\nthem back to the nearest police\nstation to put them in jail."},
 
    --AP
   
    {job = "Police Officer", x = -2162.10, y = -2385.60, z = 29.70, r = 67, g = 156, b = 255, team = "Police Force", skin = {280, 281, 282, 283, 284, 288, 246}, jobEvent = "policeTaken", maxWL = 0, description = "As a Police Officer, you must go around\narresting wanted people and bringing\nthem back to the nearest police\nstation to put them in jail."},
   
    -- Specials
    {job = "FBI", x = 1289, y = -1661, z = 13, r = 28, g = 28, b = 28, team = "Government", skin = {286, 2}, jobEvent = "event", maxWL = 3, description = "", group = "FBI"}, -- FBI
   
    {job = "Special Forces", x = 94, y = 1917, z = 17.5, r = 10, g = 120, b = 20, team = "Special Forces", skin = {73, 179, 191, 287}, jobEvent = "event", maxWL = 3, description = "here you can take this job or choose a skin", group = "SpecialForces"}, -- Special_Forces
   
    {job = "Special Forces", x = 1122.70, y = -2037.01, z = 69.89, r = 10, g = 120, b = 20, team = "Special Forces", skin = {73, 179, 191, 287}, jobEvent = "event", maxWL = 3, description = "here you can take this job or choose a skin", group = "SpecialForces"}, -- Special_Forces
}
 
function ceateJobLocations()
    for index, val in pairs(jobsLocation) do
        marker = createMarker(val.x, val.y, val.z-0.5, "cylinder", 2, val.r, val.g, val.b, 255)
        blip = createBlipAttachedTo(marker, 56)
        setBlipVisibleDistance(blip, 300)
        name[marker] = val.job
        addEventHandler("onMarkerHit", marker, enteredMarker)
    end
end
addEventHandler("onResourceStart", resourceRoot, ceateJobLocations)
 
function isPlrWorking(player)
    if (isPlayerWorking[player] and not exports.UIPteams:isPlayerInTeams(player, "Unemployed")) then
        return true
    else
        return false
    end
end
 
function enteredMarker(player, matchingDim)
    if (matchingDim and isElement(player) and getElementType(player) == "player" and not isPedInVehicle(player)) then
        if (exports.UIPpolice:isPlayerArrested(player)) then return end
        local jobName = name[source]
        for index, job in pairs(jobsLocation) do
            if (job.job == jobName) then
                local wl = getPlayerWantedLevel(player) or 0
                if (wl > job.maxWL) then
                    exports.UIPtexts:output("You can not take this job with "..wl.." stars", player, 255, 0, 0)
                    return
                end
                if (job.miniumArrests) then
                    --local arrests = exports.UIPpolice:getPlayerArrests(player)
                    if (arrests <= job.miniumArrests) then
                        exports.UIPtexts:output("This job requires you to have "..job.miniumArrests.." arrests, you got "..arrests, player, 255, 0, 0)
                        return
                    end
                end
                if (job.skin) then
                    skins = job.skin
                else
                    skins = false
                end
                local pGroup = getElementData(player, "Group") or "N/A"
                if (job.group and job.group ~= pGroup) then
                    exports.UIPtexts:output("You can't take this job", player, 255, 0, 0)
                    return
                end
                triggerClientEvent(player, "UIPbusiness.showManagmentInfo", player, jobName, job.description, skins)
                return
            end
        end
    end
end
 
function getPlayerJob(plr)
    if (not isElement(plr)) then return end
    return getElementData(plr, "Occupation")
end
 
function playerAcceptedJob(name, model)
    local player = client
    for index, job in pairs(jobsLocation) do
        if (job.job == name) then
            local account = getPlayerAccount(player)
            if (isGuestAccount(account)) then return end
            if (name == "Police Officer" or name == "Special Forces") then
                if (exports.UIPpolice:isPlayerSacked(player)) then
                    local stime = getAccountData(account, "UIPpolice.sackTime") or 0
                    local stime = math.floor(stime / 3600)
                    exports.UIPtexts:output("You have been sacked from this job and can't take it for another "..stime.." hours", player, 255, 0, 0)
                    return
                end
            end
            if (not model) then
                setElementModel(player, exports.UIPclothes:getBoughtSkin(player))
            else
                setElementModel(player, model)
            end
            setPlayerJob(player, name)
            exports.UIPteams:setPlayerTeam(player, job.team)
            if (job.event) then
                triggerEvent(job.event, player)
            end
            if (job.weapon) then
                local wep = split(job.weapons, string.byte(";"))
                for index, weapon in pairs(weapons) do
                    local stuff = split(weapon, string.byte("-"))
                    giveWeapon(player, stuff[1], stuff[2])
                end
            end
            exports.UIPtexts:output("You are now employed as a "..name.."!", player, 0, 255, 0)
            break
        end
    end
end
addEvent("UIPbusiness.acceptJob", true)
addEventHandler("UIPbusiness.acceptJob", root, playerAcceptedJob)
 
function setPlayerJob(player, job)
    if (isElement(player)) then
        if (isPlayerWorking[player]) then
            local oldJob = isPlayerWorking[player]
            triggerEvent("onPlayerResign", player, oldJob)
            triggerClientEvent(player, "onClientResign", player, oldJob)
        end
        if (not beenEmployedBefore(player)) then
            setAccountData(getPlayerAccount(player), "UIPbusiness."..job, true)
        end
        triggerEvent("onPlayerGetJob", player, job)
        triggerClientEvent(player, "onClientGetJob", player, job)
        isPlayerWorking[player] = job
        setElementData(player, "Occupation", job)
    end
end
 
function firePlayer(user, cmd, target)
    local rank = exports.UIPadmin:getStaffRank(user)
    if (rank == "Project Leader") then
        local target = exports.UIPmisc:findPlayer(target)
        if (isElement(target)) then
            firePlayerFromJob(target)
            outputChatBox("Kicked "..getPlayerName(target).." from his job.", user, 0, 255, 0)
            outputChatBox("You have been kicked from your job ", target, 255, 0, 0)
        end
    end
end
addCommandHandler("fire", firePlayer)
 
function firePlayerFromJob(player)
    if (isElement(player)) then
        if (isPlayerWorking[player]) then
            local theJob = isPlayerWorking[player]
            local boughtSkin = exports.UIPclothes:getBoughtSkin(player) or 0
            setElementModel(player, boughtSkin)
            triggerEvent("onPlayerResign", player, theJob)
            triggerClientEvent(player, "onClientResign", player, theJob)
            exports.UIPteams:setPlayerTeam(player, "Unemployed")
            setElementData(player, "Occupation", "None")
        end
    end
end
 
function endPlayerDuty(player)
    if (isElement(player)) then
        local account = getPlayerAccount(player)
        if (not isGuestAccount(account)) then
            local job = isPlayerWorking[player]
            if (job) then
                triggerEvent("onPlayerEndDuty", player, job)
                triggerClientEvent(player, "onClientPlayerEndDuty", player)
                setElementData(player, "UIPbusiness.oldJob", job)
                setElementData(player, "UIPbusiness.oldSkin", getElementModel(player))
                setElementData(player, "UIPbusiness.team", getTeamName(getPlayerTeam(player)))
                oldPlayerJob[player] = {job, getElementModel(player), getTeamName(getPlayerTeam(player))}
                local boughtSkin = exports.UIPclothes:getBoughtSkin(player) or 0
                exports.UIPteams:setPlayerTeam(player, "Non Duty Workers")
                setElementModel(player, boughtSkin)
                isPlayerWorking[player] = nil
            end
        end
    end
end
 
function onPlayerOut()
    local account = getPlayerAccount(source)
    if (isGuestAccount(account)) then return end
    if (getElementData(source, "UIPbusiness.oldJob")) then
        local job, skin, team = getElementData(source, "UIPbusiness.oldJob"), getElementData(source, "UIPbusiness.oldSkin"), getElementData(source, "UIPbusiness.team")
        setAccountData(account, "UIPbusiness.oldJob", job)
        setAccountData(account, "UIPbusiness.oldSkin", skin)
        setAccountData(account, "UIPbusiness.team", team)
    else
        setAccountData(account, "UIPbusiness.oldJob", nil)
        setAccountData(account, "UIPbusiness.oldSkin", nil)
        setAccountData(account, "UIPbusiness.team", nil)
    end
end
addEventHandler("onPlayerLogout", root, onPlayerOut, true, "high")
addEventHandler("onPlayerQuit", root, onPlayerOut, true, "high")
 
function onLogin()
   
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...