FPtje / DarkRP

DarkRP, a non-serious roleplay gamemode for Garry's Mod.
https://darkrp.miraheze.org
MIT License
463 stars 710 forks source link

[ Refactor ] Custom jobs can't buy weapons. #1047

Closed nbxcgh closed 11 years ago

nbxcgh commented 11 years ago

Description of the problem

After disabling the default Gun Dealer job in disabled_defaults.lua so I could use my modified Gun Dealer which has a different model and weapon loadout, I found that I can no longer buy weapon shipments or separate weapons using this class. This also happens with my other classes that provide weapons or drugs to players.

GM.Config.enablebuypistol is enabled and I have GM.Config.restrictbuypistol set to true, but the modified Gun Dealer class cannot buy anything at all.

I have attached a screenshot of the Shipments and Weapons tabs greyed out while using the modified class.

How I can make the problem happen again

N/A

Error log pastebin links

N/A 2013-09-10_00001

Shigbeard commented 11 years ago

Same. Apparently only the default gun dealer can view these tabs when /buy is restricted.

Shigbeard commented 11 years ago

I'm gonna have a look around, see if I can spot the problem. So far the closest I have is this...

https://github.com/FPtje/DarkRP/blob/refactor/gamemode/modules/base/sv_purchasing.lua#L41

... v.allowed[1] ...

Wouldn't this mean its only checking the first team in the table?

And in my case, I have confirmed some things.

TEAM_GUN and TEAM_PREMIUMGUNDEALER should be able to buy weapon_ak472.

TEAM_GUN can get into the menu to buy it.

TEAM_PREMIUMGUNDEALER cannot.

I assume in OPs case, he has named his replacement gun dealer TEAM_GUN too...

nbxcgh commented 11 years ago

That's correct, the point being even though the two jobs have the same TEAM_ the class specified in jobs.lua is not allowed to buy shipments.

Shigbeard commented 11 years ago

I'm right now trying to search the source code for anything that acts on the restrictbuy config.

Shigbeard commented 11 years ago

Search "Config.restrictbuypistol" (4 hits in 3 files) S:\UserData\Downloads\darkrp\DarkRP-refactor\gamemode\config\config.lua (1 hit) Line 117: GM.Config.restrictbuypistol = false S:\UserData\Downloads\darkrp\DarkRP-refactor\gamemode\modules\base\sv_purchasing.lua (2 hits) Line 40: if not GAMEMODE.Config.restrictbuypistol or Line 41: (GAMEMODE.Config.restrictbuypistol and (not v.allowed[1] or table.HasValue(v.allowed, ply:Team()))) then S:\UserData\Downloads\darkrp\DarkRP-refactor\gamemode\modules\f4menu\cl_entitiestab.lua (1 hit) Line 153: if GAMEMODE.Config.restrictbuypistol and not table.HasValue(ship.allowed, ply:Team()) then return false, true end

Thats all i got.

My money is on https://github.com/FPtje/DarkRP/blob/refactor/gamemode/modules/f4menu/cl_entitiestab.lua#L153

ikoN420 commented 11 years ago

I just updated and this has happened to me as well for both gun dealer jobs. The last time I updated the refactor was a couple of days ago so something new must have broken it. The shipment tab is just greyed out, worked fine before.

ikoN420 commented 11 years ago

This also happens with drug dealer who has access to drug shipments btw

Shigbeard commented 11 years ago

@ikoN420 if you use the chat command to buy something those custom jobs can buy, does it work? Just wondering...

ikoN420 commented 11 years ago

it says, don't have the right job

Shigbeard commented 11 years ago

Welp, I was going to do a pull request when i got home, but this info changes everything. On 10/09/2013 12:43 PM, ikoN420 wrote:

it says, don't have the right job

— Reply to this email directly or view it on GitHub https://github.com/FPtje/DarkRP/issues/1047#issuecomment-24130111.

ikoN420 commented 11 years ago

Yeah very strange! Didn't get any errors as well. Just reverted back to Sep 06, all working fine again.

Shigbeard commented 11 years ago

Well nothing has changed in the areas i pointed out for 12 days... hmmm...

nbxcgh commented 11 years ago

I have recently discovered that the custom jobs don't work with door groups either.

Shigbeard commented 11 years ago

uugh more shit broken with the modification addon arriving i assume to be late to the party.

FPtje commented 11 years ago

You guys have a fundamental misunderstanding of how Lua works. This is what's happening:

  1. DarkRP loads default teams
  2. TEAM_GUN is NOT set because you disabled it
  3. DarkRP loads default shipments
  4. shipments can only be bought by TEAM_GUN (which is still not set)
  5. DarkRP loads other stuff (including door teams)
  6. DarkRP loads custom jobs
  7. TEAM_GUN is your custom team
  8. DarkRP does NOT go back in time to say "hey you didn't have a TEAM_GUN earlier on, now I do, fix that shit"

Lua doesn't go back in time. I can see if I can change the load order, but if that's too much of a hassle, you have to deal with it. Recreate the shipments to include your custom job.

Shigbeard commented 11 years ago

Ugh, this wasn't broken a few days ago apparently what did you change then to cause this apart from everything?

FPtje commented 11 years ago

What is the colour of grass? Why can't you look at commit logs?

Shigbeard commented 11 years ago

What do you think i've done?

Unfortunately, nothing points to anything even remotely related to entity purchasing and/or jobs.

Shigbeard commented 11 years ago

not to mention the 2 fucking pages worth of Bo98's stuff.

Shigbeard commented 11 years ago

After double checking the commit logs, nothing related has been found for an entire FORTNIGHT!!!!

According to another user, this worked before September 06

The only commits on this day were b8cb0d485dccbd52c3ab30e875050b597455a187 and 24ec1e4975174f4309fd58460bc869bd817c56ae and 0a1f76bee5e47c5571b69dfa308d262b4edea6dd

None of them relate to entities.

So, that is why I am simply adding this.

If i dont understand LUA, then ill act apon that title to the fullest.

Shits broken FPtje. Fix it plx

Bo98 commented 11 years ago

this wasn't broken a few days ago apparently ... According to another user, this worked before September 06

"Apparently" and "according to another user" are key phrases there.

Shigbeard commented 11 years ago

WELL I HAVE NOTHING BETTER TO WORK ON!

something im sure FPtje screams in his head every time some retard creates an issue saying "Something is creating errors when i start darkrp."

q4-bi commented 11 years ago

Hey Guys,

With some discussion with iKoN, with the updates, my shipments were working regardless and his wasn't; however my gun-dealer ones weren't. Till I realised that I had my shipments added into the entities.lua (As I use to run them on 2.4.3). So some how the shipments.lua isn't ran. If you want a temp fix, place your shipments into entities.lua.

Shigbeard commented 11 years ago

0_0

Why do we even need two different files that do the exact same thing? Can't we just get rid of shipments.lua?

Except clearly they dont, given the fact that entities.lua doesnt give us #1047

q4-bi commented 11 years ago

Entities are more for money printers, health stations etc. Its to divide the file length and make it easier on the end user. Easy and simple.

Shigbeard commented 11 years ago

Well its stupid.

If they do the same thing, yet shipments.lua is faulty, it means that shipments is not being looked at by something entities is being looked at, just have them both work the exact same way in secret and be done with it.

ikoN420 commented 11 years ago

This thread has become quite confusing :P Here is how to easily replicate the underlying issue i believe

Completely up to date DarkRP folder (vanilla) Completely up to date DarkRP Modification addon (vanilla)

Add this to custom shipment:

AddCustomShipment("Health", "models/items/healthkit.mdl", "item_healthkit", 500, 20, false, 0, false, {TEAM_BARTENDER})

Add this to custom job:

TEAM_BARTENDER = AddExtraTeam( "Bartender", Color( 155, 60, 150, 255), "models/player/alyx.mdl", [[Sell Cigarettes, Alcohol and Water to people. Build a bar and host parties and such. Get wrecked. ]], {"weapon_fists"}, 'bartender', 3, 80, 0, 0, false )

The result? Shipment tab is greyed out for Bartender. Typing /buyshipment Health will result in "You do not have the right job to /buyshipment"

As I said before, everything worked fine on Saturday's darkrp so it might have been some new update that has messed with it. Just trying to help fix this :x

Also, just to add, the default gun dealer works fine with default shipments

Also also, before you reverted that latest commit, /buyshipment health would work however the tab would still be greyed out, if that gives any indication

FPtje commented 11 years ago
How I can make the problem happen again

N/A
FPtje commented 11 years ago

Because of the terrible description of the problem I got the issue completely wrong. The issue you described has an obvious interpretation that's not the one you meant. Now that you've told me how to make the problem happen again, I finally see that you meant something else.

Initially you said that the problem was in replacing the gun dealer and gundealer shipments. Apparently it has nothing to do with replacing default jobs.

FPtje commented 11 years ago

This commit explains why it happened. I figured @FiG-Scorn is curious about it. https://github.com/FPtje/DarkRP/commit/0006b641abafff7e007dbc596fade65924b6e62a