Skip to content

update for isAction#48

Merged
GhzGarage merged 3 commits intoqbcore-framework:mainfrom
Mustachedom:main
Jan 5, 2025
Merged

update for isAction#48
GhzGarage merged 3 commits intoqbcore-framework:mainfrom
Mustachedom:main

Conversation

@Mustachedom
Copy link
Contributor

@Mustachedom Mustachedom commented Jan 4, 2025

no sense in having

 data[#data = 1] = {
    data.params.event[?]
}

if you are just utilizing a function with this PR you can do

exports['qb-menu']:OpenMenu({
{
header = 'hello',
isAction = function()
 print('hello world')
end
}
})

Describe Pull request
ideally this will make things easier on devs since it will greatly reduce the tables needed to make a menu **if they are using an isAction = function() **

instead of doing

 for k, v in pairs (data) do
            jobs[#jobs + 1] = {
                header = 'Job: ' .. v.label,
                txt = 'Rank: ' .. v.rank .. ' | Salary: $' .. v.pay,
                params = {
                isServer = true,
                event =  'qb-multijob:server:changeJob',
                    args = {
                        job = v.job,
                        rank = v.level
                    }
                }   
            }
        end

They can now do

 for k, v in pairs (data) do
           jobs[#jobs + 1] = {
               header = 'Job: ' .. v.label,
               txt = 'Rank: ' .. v.rank .. ' | Salary: $' .. v.pay,
              isAction = function()
                TriggerServerEvent('qb-multijob:server:changeJob', {job = v.job, rank = v.level})
           }
       end

While still maintaing the older method with a bunch of tables so it will be backwards compatible for other scripts

Questions (please complete the following information):

  • Have you personally loaded this code into an updated qbcore project and checked all it's functionality? [yes] (Be honest)
  • Does your code fit the style guidelines? [yes]
  • Does your PR fit the contribution guidelines? [yes]

no sense in having 
```
 data[#data = 1] = {
    data.params.event[?]
}
```

if you are just utilizing a function with this PR you can do 

```
exports['qb-menu']:OpenMenu({
{
header = 'hello',
isAction = function()
 print('hello world')
end
}
})
```
Keeps consistent with qb-target
client/main.lua Outdated
if sendData then
local data = sendData[tonumber(option)]
sendData = nil
if data.action ~= nil then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a whitespace after the then, just for the linting report to pass

@Cocodrulo
Copy link
Contributor

The rest of the PR looks great to me, only that yo should edit the PR comment to point out that is not isAction anymore, now is just action.

@Mustachedom
Copy link
Contributor Author

good looking out @Cocodrulo this is why i dont push edits in bed way past my bedtime

keeps more in line with qb-target

also removed blank space
@Mustachedom
Copy link
Contributor Author

Mustachedom commented Jan 5, 2025

#update

no sense in having

 data[#data = 1] = {
    data.params.event[?]
}

if you are just utilizing a function with this PR you can do

exports['qb-menu']:OpenMenu({
{
header = 'hello',
action = function()
 print('hello world')
end
}
})

Describe Pull request ideally this will make things easier on devs since it will greatly reduce the tables needed to make a menu **if they are using an action = function() **

instead of doing

 for k, v in pairs (data) do
            jobs[#jobs + 1] = {
                header = 'Job: ' .. v.label,
                txt = 'Rank: ' .. v.rank .. ' | Salary: $' .. v.pay,
                params = {
                isServer = true,
                event =  'qb-multijob:server:changeJob',
                    args = {
                        job = v.job,
                        rank = v.level
                    }
                }   
            }
        end

They can now do

 for k, v in pairs (data) do
           jobs[#jobs + 1] = {
               header = 'Job: ' .. v.label,
               txt = 'Rank: ' .. v.rank .. ' | Salary: $' .. v.pay,
              action = function()
                TriggerServerEvent('qb-multijob:server:changeJob', {job = v.job, rank = v.level})
           }
       end

While still maintaing the older method with a bunch of tables so it will be backwards compatible for other scripts

Questions (please complete the following information):

  • Have you personally loaded this code into an updated qbcore project and checked all it's functionality? [yes] (Be honest)
  • Does your code fit the style guidelines? [yes]
  • Does your PR fit the contribution guidelines? [yes]

@GhzGarage GhzGarage merged commit 212100d into qbcore-framework:main Jan 5, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants