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

Add npc_relationships.lua #98

Closed
wants to merge 8 commits into from
Closed

Add npc_relationships.lua #98

wants to merge 8 commits into from

Conversation

thinedave
Copy link

A plugin made for a job. Allows certain npcs to be friendly to certain factions.

@thinedave thinedave changed the title Add npc_relationships.lua Add npc_relationships.lua and disable_pvp.lua Nov 21, 2021
@thinedave
Copy link
Author

Another plugin for a job. Allows admins to toggle PVP.

@FlorianLeChat
Copy link

The first plugin is basically a duplication of the sbox_playershurtplayers console variable but with much less performance efficiency (why do you use EntityFireBullets ?...). Moreover, if another hook returns something else before yours, then your code will not be executed and the plugin will be useless.

The second one is full of several issues like the indentation which is clearly not uniform with the rest of the Helix code. The declaration of local variables on the client and server side to use it only on the server side. Finally, there are many things to review in the loops. You should strongly look at the Helix code to try to factorize and improve the readability of both plugins.

@thinedave
Copy link
Author

As disable_pvp.lua is no longer needed, it has been removed.

The second one is full of several issues like the indentation which is clearly not uniform with the rest of the Helix code. The declaration of local variables on the client and server side to use it only on the server side. Finally, there are many things to review in the loops. You should strongly look at the Helix code to try to factorize and improve the readability of both plugins.

Your criticism has been addressed. Readability has been improved. Variables now only initialize on the server. Thank you.

@thinedave thinedave changed the title Add npc_relationships.lua and disable_pvp.lua Add npc_relationships.lua Nov 22, 2021
for i, Ply in ipairs(player.GetAll()) do -- get all players
if !Ply:GetCharacter() then continue end -- if player is not loaded

if Ply:Team() != friendlyFaction then Ply.VJ_NPC_Class = {nil}; continue end -- if not a friendly faction

Choose a reason for hiding this comment

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

Why insert a semi colon when you didn't before?

Copy link
Author

Choose a reason for hiding this comment

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

I believe semi-colons are required when not using new lines, which I saw as unnecessary seeing as it was one function.

Choose a reason for hiding this comment

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

From what I remember, I don't think there's any need for it, but as I can't test this right now, I'll trust you on this point.

Choose a reason for hiding this comment

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

They are not required in lua.

@thinedave
Copy link
Author

Thank you both for your comments. Most of the above changes have been addressed. Let me know if I missed anything.

@FlorianLeChat
Copy link

The whole thing looks pretty good to me, well done! If there are still inconsistencies or changes to be made, the Helix maintainers will report them.

This pull request was closed.
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.

None yet

3 participants