• Restricting jobs based on time spent as other jobs - DarkRP
    4 replies, posted
I am aware there is a DarkRP help thread, I've already gone to it. This turns out to be something more complicated that few (if any) people have tried before, where that thread seems to be more for simple questions and rooting out the source of errors. I'm looking to restrict jobs based on the amount of time a player spends as a different job, to mimic a simple levels system. For example, to access a "Level 2 Gundealer," you need 2 hours as a Gundealer. I don't know much lua, but I think the best way to go about this is to track when plyMeta.isJob (I'll explain this below) returns true with some sort of timer, then use it with customcheck for the given amount of time. Problem is, I have no idea how to do this. So far what I [I]do[/I] have is this bit I got from FPtje (modified slightly for my purposes): [lua]local plyMeta = FindMetaTable("Player") plyMeta.IsSales = fn.Compose{fn.Curry(fn.Eq, 2)(TEAM_GUN, TEAM_MERCH, TEAM_BLACK), plyMeta.Team} -- Salesmen jobs plyMeta.IsGov = fn.Compose{fn.Curry(fn.Eq, 2)(TEAM_POLICE, TEAM_PMEDIC, TEAM_UCOP, TEAM_SCHIEF, TEAM_CHIEF, TEAM_MAYOR, TEAM_MGUARD), plyMeta.Team} -- Government jobs plyMeta.IsGang = fn.Compose{fn.Curry(fn.Eq, 2)(TEAM_GANG, TEAM_GMEDIC, TEAM_MOB, TEAM_SPY, TEAM_WGANG, TEAM_WGMEDIC, TEAM_WMOD, TEAM_WSPY, TEAM_Thief), plyMeta.Team} -- Gang jobs[/lua] I tried modifying Utime to use these values, but it turned into a bit of a cluster and I scrapped it. Whether that is possible or not, I do not know.
Don't mean to bump my own thread, but I've thought up another method that I think might be easier. If I were to duplicate and rename DarkRP's money payday system into 3 additional pools and treat it like "XP," using a renamed "ply:CanAfford" (or something like that, I forget the exact name) in the custom check field. What would be the best way to do this?
Have it so when a player joins it checks the db for a "first joined field" if they dont have it then make it as that current time. Else subtract the joined time from the current time (its unix timestamp i think) to get the total seconds played. Put that as a serverside var so ply.timePlayed then when they change job check that timePlayed?
I actually think I'm going to do this with the payday method I mentioned, thanks thoough!. Does anyone know what things I'd have to copy to make duplicates of the payday system? I have no idea how db stuff works, so any advice helps.
Alright, I've made a lot of progress on this. I've duplicated the wallet/payday system into 3 new sets, (gangxp, salesxp and copxp). I've set up a table, have tested the system in DarkRP and it all checks out, with commands to restrict jobs if a player does not have enough xp, set/resetxp commands, and an almost working automatic payday (it isn't database related so I think I can figure it out). I only have one problem remaining. The player's experience doesn't save between server visits. When they leave, their experience resets to the default setting. I think it's something to do with the storeXP functions, but I'm not positive and I've sort of hit a dead end here.[URL="https://dl.dropboxusercontent.com/u/17239680/Facepunch/sv_xpdata.lua"]Here's my data code[/URL], anything going on outside of this file is described in comments. Any help would be appreciated, I have very little knowledge in using database stuff, so if it's something obvious there's a good chance I've missed it. Edit: Nevermind, I've figure it out, I'm just incredibly dumb :v:
Sorry, you need to Log In to post a reply to this thread.