# Job Center

## Configuration

Configuration events of files in gksphone/config/jobs

{% tabs %}
{% tab title="sh\_jobs.lua" %}
Job list and general settings section of jobs

icon = <https://fonts.google.com/icons>

MimWorkers = Minimum number of players to work

MaxWorkers = Maximum number of players to work

Location = If there is a position, specify it as vector3 or vector4 if there is no position, make it false

RequiredItem = If there is an item required to see the job, write the item code here, if not, set it to false

IsActive = to set the availability of the job

```lua

["sanitation"] = {
        ["Name"] = "Job Code",
        ["Label"] = "Name of the Job",
        ["Description"] = "Job description",
        ["Icon"] = "Icon Name",
        ["IconColor"] = "Icon color",
        ["Rating"] = 2,
        ["MimWorkers"] = 1, 
        ["MaxWorkers"] = 2, 
        ["Location"] = false, 
        ["RequiredItem"] = false, 
},

```

{% endtab %}

{% tab title="sh\_tasks.lua" %}
job code = job code in sh\_jobs.lua

TaskId = Start from 1 and increment by one

TaskText = description of the task ( %s can be edited using export )

ExtraDone = 0 -- if it is a stepped job, this is the starting count

ExtraNeed = 10, -- If it is a stepped job, specify the number you want to reach

```lua
['jobcode'] = {
  {
    ["TaskId"] = 1,
    ["TaskText"] = "Example",
    ["Finished"] = false
  },
  {
    ["TaskId"] = 2,
    ["TaskText"] = "Example %s",
    ["ExtraDone"] = 0,
    ["ExtraNeed"] = 10,
    ["Finished"] = false
  },
}
```

{% endtab %}
{% endtabs %}

## Events

Sample files are available in gksphone/client/apps/job and gksphone/server/job.

{% tabs %}
{% tab title="client" %}

```lua
RegisterNetEvent("gksphone:client:JobStartTask", function (jobInfoName, Tasks)
    -- Event running for all group members
    -- jobInfoName ( job code )
    -- Tasks ( tasks assigned for the job )
end)


RegisterNetEvent("gksphone:client:jobStartLeader", function (jobInfoName)
    -- event running for group leader when job starts
    -- jobInfoName ( job code )
end)


RegisterNetEvent("gksphone:client:JobNextTask", function (NewTaskID)
    -- Event running on all group members and when a new task progresses
    -- NewTaskID = task id of the new task
end)
```

{% endtab %}

{% tab title="server" %}

```lua
RegisterNetEvent("gksphone:server:jobStartLeader", function (source, jobName, groupID, groupMembers)
    -- Server event running for group leader
    -- source = group leader player id
    -- jobName = name of job done
    -- groupID = ID of the created group
    -- groupMembers = players in the group
    -- { --groupMember Data
      -- cid = player identifier,
      -- source = player ID,
      -- online = true,
      -- name = character's first and last name
    -- }
end)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
There is no finish event, you have to finish it manually and delete the group using export
{% endhint %}

## Exports - Server

### GetJobGroupByLeader

Brings the group information of the person who is the Group Leader.

```lua
local playerIdentifier = "Player Identifier" 
local groupData = exports["gksphone"]:GetJobGroupByLeader(playerIdentifier)
print(json.encode(groupData, {indent = true}))
```

### DeleteJobGroup

Delete Group

```lua
exports["gksphone"]:DeleteJobGroup("jobcode", groupID)
```

### GetGroupByMember

Returns the information of the group with the player identifier

```lua
local playerIdentifier = "Player Identifier" 
exports["gksphone"]:GetGroupByMember(playerIdentifier)
```

## Exports - Client

### IsGroupLeader

```lua
local isLeader = exports["gksphone"]:IsGroupLeader()
print(isLeader) -- true or false
```

### IsTaskStatus

```lua
local TaskID = 1
local isLeader = exports["gksphone"]:IsTaskStatus(TaskID)
print(isLeader) -- true or false
```

### TaskUpdate

```lua
local TaskID = 1
local TaskStatus = true -- true or false
local ExtraDone = 0 -- if it is a progressive job, you can change the number accordingly
exports["gksphone"]:TaskUpdate(TaskID, TaskStatus, ExtraDone)
```

### TaskListUpdate

If you want to make changes in Task List Text, you can use

```lua
-- TaskList == Send all tasks list after making the exchange
exports["gksphone"]:TaskListUpdate(TaskList)
```

### TaskList

```lua
local taskList = exports["gksphone"]:TaskList()
```
