• Pistachio Roleplay
    322 replies, posted
Okay, so, I'm in progress of making a jobs tab in the gamemode, I've got most of it working, just a little problem. It makes 1 new category for each job I put, I've set up the tables correctly(As far as I know of) and all. Here is an image of it [IMG]http://eternal-gaming.co.uk/problem.jpg[/IMG] The code I've done for the jobs is: [LUA] function PANEL:Init() self.panel = vgui.Create("DScrollPanel", self); self.panel:Dock(FILL); self.categories = {}; for k, v in pairs(JobCats) do for k2, v2 in pairs(AllJobs) do local itemCategory = v.name or "None"; if ( v2.category == v.name and v.show == true) then local category = vgui.Create("DCollapsibleCategory"); category:SetLabel(v.name); category:Dock(TOP); category:SetExpanded(0); category.panel = vgui.Create("DPanel", category); category.panel:Dock(FILL); category.list = vgui.Create("DListLayout", category.panel); category.list:Dock(FILL); category.list:DockPadding(3, 3, 3, 7); category:SetContents(category.list); self.panel:AddItem(category); self.categories[itemCategory] = category; local category = self.categories[v.name or "None"]; local item = category.list:Add("ps_JobsItem"); item:DockMargin(3, 3, 3, 3); item:SetJob(table.Random(v2.model), v2.name, v2.desc, function() net.Start("ps_ChangeToTeam"); net.WriteInt(v2.id); net.SendToServer(); end); end; end end; end; [/LUA] All help would be greatly appreciated. [b] NOTE: This is a remake of the market tab. Just saying. [/b] [b] EDIT: Code for the tables [/b] [LUA] AllJobs = {} JobCats = {} function AddJobCat(id, name, show) table.insert(JobCats, {id = id, name = name, show = show}) end AddJobCat({TEAM_CITIZEN}, "Civillians", true) AddJobCat({TEAM_POLICE, TEAM_MAYOR}, "Government Officials", true) AddJobCat({TEAM_ARRESTED}, "Arrested", false) function AddJob(id, Name, model, Description, useable, cat) table.insert(AllJobs, {id = id, name = Name, model = model, desc = Description, useable = useable, category = cat}) end policemodels = { "models/player/riot.mdl", "models/player/swat.mdl", "models/player/urban.mdl", "models/player/gasmask.mdl" --[[ "models/player/police.mdl", "models/player/combine_soldier.mdl", "models/player/combine_soldier_prisonguard.mdl" --]] }; mayormodels = { "models/player/breen.mdl", "models/player/mossman.mdl" } citizenmodels = { -- Other. "models/player/Kleiner.mdl", "models/player/alyx.mdl", "models/player/gman_high.mdl", -- Female models. "models/player/Group01/Female_01.mdl", "models/player/Group01/Female_02.mdl", "models/player/Group01/Female_03.mdl", "models/player/Group01/Female_04.mdl", "models/player/Group01/Female_06.mdl", "models/player/Group01/Female_07.mdl", "models/player/Group03/Female_01.mdl", "models/player/Group03/Female_02.mdl", "models/player/Group03/Female_03.mdl", "models/player/Group03/Female_04.mdl", "models/player/Group03/Female_06.mdl", "models/player/Group03/Female_07.mdl", -- Male models. "models/player/Group01/male_09.mdl", "models/player/Group01/male_08.mdl", "models/player/Group01/male_07.mdl", "models/player/Group01/male_06.mdl", "models/player/Group01/male_05.mdl", "models/player/Group01/male_04.mdl", "models/player/Group01/male_03.mdl", "models/player/Group01/male_02.mdl", "models/player/Group01/male_01.mdl", "models/player/Group03/male_02.mdl", "models/player/Group03/male_03.mdl", "models/player/Group03/male_04.mdl", "models/player/Group03/male_05.mdl", "models/player/Group03/male_06.mdl", "models/player/Group03/male_07.mdl", "models/player/Group03/male_08.mdl" }; AddJob(TEAM_CITIZEN, "Citizen", citizenmodels, "A general civillian of the town. You live off benefits.", true, "Civillians") AddJob(TEAM_POLICE, "Police Officer", policemodels, "You patrol the streets to make sure every civillian of the city is safe and crime is at bay.", true, "Government Officials") AddJob(TEAM_MAYOR, "Mayor", mayormodels, "You control the government agency and tell them what to do. You are the leader of the whole city.", true, "Government Officials") AddJob(TEAM_ARRESTED, "Arrested", citizenmodels, "Arrested by the government agency.", false, "") [/LUA] Alot of stuff.
Check if there is already self.categories[itemCategory]
[QUOTE=Chessnut;38493163]Check if there is already self.categories[itemCategory][/QUOTE] I don't think there is to be honest. I've checked it over, also I've provided the tables code in the post now(edited it), that's basically all the code, apart from the whole panel, but the bit I provided is the bit that's bugging I think. I've tried multiple things, I'm on the urge of giving up and doing each bit manually including the categories, but that wouldn't be efficient.
[lua] function PANEL:Init() self.panel = vgui.Create("DScrollPanel", self); self.panel:Dock(FILL); self.categories = {}; for k, v in pairs(JobCats) do local itemCategory = v.name or "None"; if ( not self.categories[itemCategory] ) then local category = vgui.Create("DCollapsibleCategory"); category:SetLabel(v.name); category:Dock(TOP); category:SetExpanded(0); category.panel = vgui.Create("DPanel", category); category.panel:Dock(FILL); category.list = vgui.Create("DListLayout", category.panel); category.list:Dock(FILL); category.list:DockPadding(3, 3, 3, 7); category:SetContents(category.list); self.panel:AddItem(category); self.categories[itemCategory] = category; end; for k2, v2 in pairs(AllJobs) do if ( v2.category == v.name and v.show and self.categories[v2.category] ) then local category = self.categories[v2.category]; local item = category.list:Add("ps_JobsItem"); item:DockMargin(3, 3, 3, 3); item:SetJob(table.Random(v2.model), v2.name, v2.desc, function() net.Start("ps_ChangeToTeam"); net.WriteInt(v2.id); net.SendToServer(); end); end; end end; end; [/lua] [editline]18th November 2012[/editline] ps if this has dynamic jobs you're going to need to put everything in the for block into a method on the panel so you can refresh the category and repopulate it every time a new job is added
Can I use these job scripts? mmm...possibly edit? EDIT: Trying to make a faction category, no abilities or anything just a plain setting category to players.
-snip-
[QUOTE=LauScript;38494023][lua] function PANEL:Init() self.panel = vgui.Create("DScrollPanel", self); self.panel:Dock(FILL); self.categories = {}; for k, v in pairs(JobCats) do local itemCategory = v.name or "None"; if ( not self.categories[itemCategory] ) then local category = vgui.Create("DCollapsibleCategory"); category:SetLabel(v.name); category:Dock(TOP); category:SetExpanded(0); category.panel = vgui.Create("DPanel", category); category.panel:Dock(FILL); category.list = vgui.Create("DListLayout", category.panel); category.list:Dock(FILL); category.list:DockPadding(3, 3, 3, 7); category:SetContents(category.list); self.panel:AddItem(category); self.categories[itemCategory] = category; end; for k2, v2 in pairs(AllJobs) do if ( v2.category == v.name and v.show and self.categories[v2.category] ) then local category = self.categories[v2.category]; local item = category.list:Add("ps_JobsItem"); item:DockMargin(3, 3, 3, 3); item:SetJob(table.Random(v2.model), v2.name, v2.desc, function() net.Start("ps_ChangeToTeam"); net.WriteInt(v2.id); net.SendToServer(); end); end; end end; end; [/lua] [editline]18th November 2012[/editline] ps if this has dynamic jobs you're going to need to put everything in the for block into a method on the panel so you can refresh the category and repopulate it every time a new job is added[/QUOTE] Oh my gosh, I love you man! It works like a charm! That help is deeply appreciated by me and the community. Thanks again. ;)
Update on the jobs tab: [IMG]http://eternal-gaming.co.uk/mafiajobs.png[/IMG] [editline]18th November 2012[/editline] Anyway, I forgot to mention to Chessnut, you are a great coder mate, this gamemode is a work of art, really, my first post should of been this, but if you remember me, I used to be on your steam friends, on my old account. I'll PM you the name if you want, anyway, I love this gamemode and you did a swell job of it. Good work bro. ;)
[QUOTE=kjh0105;38497909] oh i found problem cl_chatbox.lua [lua] --stuff [/lua][/QUOTE] But then nothing shows up in your console so you can't log it.
use MsgC!
Where is Vehicle Scripts?
Error when trying to use AK-47 [CODE] [ERROR] lua/includes/extensions/entity.lua:156: bad argument #2 to 'SetFunc' (number expected, got boolean) 1. SetFunc - [C]:-1 2. __newindex - lua/includes/extensions/entity.lua:156 3. SetIronsights - lua/includes/extensions/entity.lua:207 4. unknown - ...des/pistachio/entities/weapons/weapon_cs_base/shared.lua:85 [/CODE]
I have a 20 server for Pistachio if anyone wants to join it. Still working out some kinks though. IP: 69.162.90.254:27016
Very good mod. I thank you again to share.
Anyone able to give me a good derma lesson with this? I'm trying to use the whole category and DScrollDownMenu thing, but I keep messing up somewhere along the way.
no we can't help you as you've supplied no errors at all or anything that gives us a clue in what exactly you need assistance with. When you do provide what you tried, and the error( if any ), then I will try to help you and i'm sure others will as well. i want to play this and i joined a server called towel gaming but it's [b]EMPTY[/b] and no attempts to populate it so if anyone wants to join you should and help me do so :). also whoever owns this towel gaming you need to change the map to something on the workshop it will increase your player count.
[QUOTE=LauScript;38530034]no we can't help you as you've supplied no errors at all or anything that gives us a clue in what exactly you need assistance with. When you do provide what you tried, and the error( if any ), then I will try to help you and i'm sure others will as well. i want to play this and i joined a server called towel gaming but it's [b]EMPTY[/b] and no attempts to populate it so if anyone wants to join you should and help me do so :). also whoever owns this towel gaming you need to change the map to something on the workshop it will increase your player count.[/QUOTE] I've heard of Towel Gaming. I think the owner used to be a regular on one of my older servers before he started TG.
[QUOTE=UniqueGuy;38500087]Update on the jobs tab: [IMG]http://eternal-gaming.co.uk/mafiajobs.png[/IMG] [editline]18th November 2012[/editline] Anyway, I forgot to mention to Chessnut, you are a great coder mate, this gamemode is a work of art, really, my first post should of been this, but if you remember me, I used to be on your steam friends, on my old account. I'll PM you the name if you want, anyway, I love this gamemode and you did a swell job of it. Good work bro. ;)[/QUOTE] You'd be willing to share your code for jobstab please?
I am setting this up on one of my two servers, and depending on the result, the second server will also run this. I am going to use rp_vuoristo, and I am removing all weaponry and vehicles.
lol removing weaponry and vehicles. are you [b]trying[/b] to get 0 players?
I really want to use this gamemode, but I feel like some features on it are to...lightrp when I'm trying to achieve SeriousRP.
the only thing that enforces the style of a light rp is the money printers. Honestly everything else could be adjusted to fit the seriousrp style of boredom :)
If you can get people to act seriously, it's serious roleplay then isn't it?
Looking good!
[QUOTE=LauScript;38557413]lol removing weaponry and vehicles. are you [b]trying[/b] to get 0 players?[/QUOTE] I'm trying to get the immature kids off. Anyway, the map is way too small for vehicles all together, and the weapons are bugged. EDIT: And vehicles tell me that they are missing the 'muscle' script.
[QUOTE=NightmareX91;38563968]I'm trying to get the immature kids off. Anyway, the map is way too small for vehicles all together, and the weapons are bugged. EDIT: And vehicles tell me that they are missing the 'muscle' script.[/QUOTE] weapons worked fine for me last time i checked but i guess removing vehicles for certain maps would be a good idea.
[QUOTE=LauScript;38566256]weapons worked fine for me last time i checked but i guess removing vehicles for certain maps would be a good idea.[/QUOTE] Anyway, I intend to have a city server for the kids aswell.
I'm running this gamemode with my friends. First time i played this it did cost money to spawn amy object which i tought was a great idea. But that just dissapeared and now i can spawn how much i want. Anyone know how to fix this problem? Edit: Fixed it. It were coded so when your karma is 1 or higher it does not cost anything to spawn items, have no idea why. You can find this on line 573ish in the file sv_main.lua.
That's because your karma is over 0.
Do you have any plans on adding "Hunger" as a varible? Great gamemode btw! When you're playing with serious people, the gamemode is perfect.
Sorry, you need to Log In to post a reply to this thread.