FPtje / DarkRP

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

GM.Config.normalsalary Bug #2300

Closed Hazbelll closed 8 years ago

Hazbelll commented 8 years ago

The Global variable in DarkRP's config GM.Config.normalsalary appears to have no effect. New joining players will still have a starting salary of 45.

Unfortunately, I am not sure why exactly this is, but I can narrow it down to 3 reasons, which I think may overlap with one another, being an issue on Dedicated Servers when using MySQL rather than MySQLite and having the Job players spawn as when joining's salary field in the Job's table set to salary = GAMEMODE.Config.normalsalary,

I've been unable to do further testing to pinpoint the exact reason, as I don't have a local MySQL server or SRCDS to work with currently, so I do apologise. Here's the setup however:

On a Listen Server, GM.Config.normalsalary has been changed from 45 to 5. The starting job of player's salary is set to salary = GAMEMODE.Config.normalsalary,. MySQLite is being used for DarkRP. When spawning, the starting salary will be correct, matching that of GM.Config.normalsalary, without needing to change jobs and back.

On a Dedicated Server, GM.Config.normalsalary has been changed from 45 to 5. The starting job of player's salary is set to salary = GAMEMODE.Config.normalsalary,. MySQL is being used for DarkRP, specifically the MySQLoo module (although I've been meaning to switch over to tmysql4 for a while now). When spawning, the starting salary will be incorrect, being at 45. However, if the player changes jobs and back, then the salary will be correct, based off of what GM.Config.normalsalary has actually been set to.

FPtje commented 8 years ago

Salary is a fucked piece of ass. It's stored per player in the database, players can have individual salary, jobs have a salary, there's a default salary. The mayor used to be able to set salaries, but that was removed.

Shit's fucked.

Hazbelll commented 8 years ago

Yeah, I always thought it was odd that there was a setting for it in DarkRP's config to begin with, seeing as per Job Table has a field for setting their values. I assumed it was if you had multiple jobs that went off a single salary, that you could just have it point to the global variable.

If memory serves me right, I do believe I tried setting the salary to an exact value rather than from a variable and it still defaulted to 45, until a job change and back.

FPtje commented 8 years ago

That's probably because on join the database salaries are loaded:

sv_data.lua:320

        info.salary = info.salary or GAMEMODE.Config.normalsalary

        self:setDarkRPVar("money", tonumber(info.wallet))
        self:setSelfDarkRPVar("salary", tonumber(info.salary))

where info.salary is originally from the database.

Hazbelll commented 8 years ago

Ah, right. I guess it's only an issue when using MySQL for DarkRP then. Whenever I've seen it working correctly, MySQLite has been used.

EDIT: Shouldn't salaries in the Database be removed, seeing as it's a legacy thing that's no longer actively used?

FPtje commented 8 years ago

Just a side note, MySQLite is my library's name, it's a combination of MySQL and SQLite. You probably mean SQLite instead of MySQLite.

Hazbelll commented 8 years ago

Yeah, my bad. I've been mucking about with SQL related stuff too much in DarkRP lately.

FPtje commented 8 years ago

Fuck personal salaries.

Hazbelll commented 8 years ago

Fuck 'em all.