• Job switching npc [darkrp]
    33 replies, posted
hey so i'm making a npc that is supposed to make a window come up and display 1 job at a time until i click the next button to display the next job in the list. so i made the npc and the vgui but now im stuck and idk how to get the job list into a tabel that i can cycle thru or even change the job of the player.. i have looked in the darkrp code and for a beginner it is really confusing. posting here for help is all i can think of doing. so the question summed up is how can i get the darkrp job list into a tabel(if it is not one) and change the players job when he clicks a button? if my rant confused you here is a pic [IMG]http://i.imgur.com/kXHXnNX.jpg[/IMG] so in the middle its supposed to show the job model and info and the number 6 is supposed to display the team name but it just shows the number. [CODE]net.Receive("hello", function() pie = net.ReadBit() if pie == true then ply.SetTeam = TEAM_CITIZEN else end end)[/CODE] tryed doing this in the server side after i click the button. yes i know i'm a noob..
team.GetName(6)
SWEET! thanks, that fixes one problem
team.GetAllTeams() will give you a table of all teams. ply:SetTeam() will set the players team.
idk how to use team.GetAllTeams() to display the the team name and info
[lua]PrintTable(team.GetAllTeams())[/lua] Or [lua] for k,v in pairs(team.GetAllTeams()) do print("Name: "..team.GetName(v).." | Number: "..v) end [/lua]
what about description, model and color?
[QUOTE=TrippleT;46177036]what about description, model and color?[/QUOTE] Description and Model: Look at F4 menu code Color: team.GetColor()
i tryed that but the darkrp code is so confusing. i'm still a beginner [editline]7th October 2014[/editline] mabe what im trying to make is too complex and i should just give up and make something else
[QUOTE=TrippleT;46177110]i tryed that but the darkrp code is so confusing. i'm still a beginner [editline]7th October 2014[/editline] mabe what im trying to make is too complex and i should just give up and make something else[/QUOTE] At least attempt to try, if it's complex, just break it down into what does what and you'll understand it.
i did try i made the menu and made it show team name that's a huge thing for me
[QUOTE=TrippleT;46177147]i did try i made the menu and made it show team name that's a huge thing for me[/QUOTE] Then keep going and don't stop until you finish (at least sleep though)
[URL="http://gmodwiki.net/Lua/VGUI/Elements/DModelPanel"]http://gmodwiki.net/Lua/VGUI/Elements/DModelPanel[/URL] You can just type the description out your self. EX. if team == 1 then description = "shit head" elseif team == 2 then description = "chicken" end there is probably a better way of doing this but I can't think right now.
thanks! [editline]8th October 2014[/editline] [QUOTE=LUModder;46177514]Then keep going and don't stop until you finish (at least sleep though)[/QUOTE] ok :D ill do it! [editline]8th October 2014[/editline] [QUOTE=LUModder;46176947][lua]PrintTable(team.GetAllTeams())[/lua] Or [lua] for k,v in pairs(team.GetAllTeams()) do print("Name: "..team.GetName(v).." | Number: "..v) end [/lua][/QUOTE] but how do i take v and make it displayed in label:SetText() i tryed making v = jobname but it says error. and i want to display one job at a time so do i add them all into a table inside the for loop? and team.GetName() is not working
Use [lua]for k, v in pairs(RPExtraTeams) do //v.name for name //v.model for model //v.description for description end[/lua]
[QUOTE=Dummore;46179602]Use [lua]for k, v in pairs(RPExtraTeams) do //v.name for name //v.model for model //v.description for description end[/lua][/QUOTE] so how would i use this? say i wanted the info for citizen job would i make v.name = 1? or make v.name = jobname so i can display it in a different function?
[CODE]for k, v in pairs(RPExtraTeams) do jobname = v.name jobmodel = v.model jobdescrip = v.description //all the code with those variables has to be in this for loop. end[/CODE]
so i have to make my dpanel in there? ok thanks! thats why i spent hours wondering why v.name = jobname gave a error... this is not like C++
[QUOTE=TrippleT;46179724]so i have to make my dpanel in there? ok thanks! thats why i spent hours wondering why v.name = jobname gave a error... this is not like C++[/QUOTE]Might be because jobname was a nil value. Just add the stuff I had in the last for loop and you should be fine. Btw you don't need to put the base frame in the for loop, only stuff that should change based on what job is displaying.
yeah i switched it up lol "jobname = v.name" ok thanks this helps. im so much closer to finishing it. but since this is a loop how should i display 1 at a time and scroll thru with the buttons. [editline]8th October 2014[/editline] wont this just scan and display every team name on my dpanel.settext
[QUOTE=TrippleT;46179760]yeah i switched it up lol "jobname = v.name" ok thanks this helps. im so much closer to finishing it. but since this is a loop how should i display 1 at a time and scroll thru with the buttons. [editline]8th October 2014[/editline] wont this just scan and display every team name on my dpanel.settext[/QUOTE]nope It will display as many dpanel. settext () as many teams there is and with that teams name
so what should i do when some one clicks the select job button? how will it know what job to change it to
[IMG]http://i.imgur.com/xyFOjjV.png[/IMG] see... i tryed displaying it from the loop and it shows all at once [editline]8th October 2014[/editline] tryed v.name[1] and just random char's come up? yeah it shows the first letter of all my jobs at the same time
[QUOTE=TrippleT;46183060][IMG]http://i.imgur.com/xyFOjjV.png[/IMG] see... i tryed displaying it from the loop and it shows all at once [editline]8th October 2014[/editline] tryed v.name[1] and just random char's come up? yeah it shows the first letter of all my jobs at the same time[/QUOTE] Clear the label every switch and call SizeToContents along with it
ok so i got all the name and info done but i cant figure out how to change the team of the person who clicked it, i know its in server side
[QUOTE=TrippleT;46183590]ok so i got all the name and info done but i cant figure out how to change the team of the person who clicked it, i know its in server side[/QUOTE] Again, look at how the F4 menu does it.
[QUOTE=LUModder;46184237]Again, look at how the F4 menu does it.[/QUOTE] i allready told you i have looked and there is so many hooks and checks i don't understand any of it...
[QUOTE=TrippleT;46184255]i allready told you i have looked and there is so many hooks and checks i don't understand any of it...[/QUOTE] press control f and search for team or set or switch. You will find it somewhere
[QUOTE=Nick78111;46184435]press control f and search for team or set or switch. You will find it somewhere[/QUOTE] [CODE] self.DoClick = fn.Compose{closeFunc, fn.Partial(RunConsoleCommand, "darkrp", job.command //changed this to "cp" )} [/CODE] i got this and it works but if gives a error saying fn is nill i changed job.command to "cp" because i want it to change ur job to cp when u click a button i fixed it just had to remove the closeFunc sweet everything works now! thanks!
ok now since the npc is working and everything is great how can i make somthing float above his head like the chat bubble so u know its a npc?
Sorry, you need to Log In to post a reply to this thread.