Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CreatePlayer Function #1012

Merged
merged 4 commits into from
Sep 23, 2023
Merged

Conversation

Cocodrulo
Copy link
Contributor

Description

This pull request is for adding a more comprehensive way of notifying a player and checking if a player has items from the server side. For developers, specifically the ones that are starting, it would be easier to think that to notify a player or check if it has a specific item, you will first have to instance the Player variable.

Checklist

  • I have personally loaded this code into an updated qbcore project and checked all of its functionality.
  • My code fits the style guidelines.
  • My PR fits the contribution guidelines.

A more comprehensive way of notifying a player and checking if a player has items from the server side.
Copy link

@StoreSky StoreSky left a comment

Choose a reason for hiding this comment

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

It works perfectly and I think it makes total sense

@Edvo1901
Copy link

Hmm, in my opinion, I doubt this is necessary. I am not saying it useless but let take the HasItem function for example. By default, I need only 1 line of code to check if a player has an item.

local hasItem = QBCore.Functions.HasItem(source, "item", "amount")

In your PR, I need to do up to 3 lines.

local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end --This is optional
local hasItem = Player.Functions.HasItem("item", "amount")

Is this really necessary tho?

@Cocodrulo
Copy link
Contributor Author

I see your point, but most times yo check if a player has an item server side, you are the going to remove the item or do smth so the Player is already initialized. This change is not meant to be neccessary, because it is not, but is meant to help people that are starting with QBCore understand the things better, like you have the get the player you want to notify seems very logical to me, but in qbcore is not like that, and also it would be a change that doesn't break any script, but it is helpful for developers, that won't have to get the player source each time the want to check items o notify

@GhzGarage GhzGarage merged commit 5a7f41f into qbcore-framework:main Sep 23, 2023
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.

5 participants