• Need Some Help WIth fast replies!
    36 replies, posted
So my next project is going to be a police armory so i want to make this where when i hit e a derma panel pops up and only police can buy weapons and armor and i dont know how to start it! well i know how to make an entity so i dont need help with that
Use this: Category ENTITY/AcceptInput Net Library Usage https://www.lua.org/pil/4.3.1.html Functions/Player/Shared/getJobTable With the darkrp job table thing you could maybe do it like this: local meta = FindMetaTable( "Player" ) if( meta:getJobTable().command == "jobcp" ) then print( meta:Nick() .. " is a police!" ) end yes i did not test the get job table function with the "." command thing. But I think it works. Well It does, it should :P
how do i start it i dont get how this works?
After successfully creating your entity, use an ENTITY/AcceptInput hook to check when a player presses E on the entity, and within the hook's function send the client an empty usermessage... Here's a basic example (Untested)... function ENT:AcceptInput( Name, Activator, Caller )     if Name == "Use" and Caller:IsPlayer() then         umsg.Start("Test", Caller) -- Prepare the usermessage to that same player to open the menu on his side.         umsg.End() -- We don't need any content in the usermessage so we're sending it empty now.     end end Then on the client, you can do something along the lines of this... function WhateverYouWant()     local frame = vgui.Create( "DFrame" );     frame.w, frame.h = ScrW() / 1.25, 800;     frame:SetSize( frame.w, frame.h );     frame:Center();     frame:MakePopup();     frame:SetTitle( "" );     frame:SetPaintShadow( true ); end usermessage.Hook("Test", WhateverYouWant) -- Ensure the first parameter is the same as the usmg.Start identifier, and the second parameter is the function's identifier.
Apologies, for some reason I didn't actually have that comment when I looked at it. Unless you posted it literally as I was typing mine
do you know the error?
WeaponList={} myTable[1]="First Wep" myTable[2]="Second Wep" myTable[3]="Third Wep" There's an example of a table
WeaponList = { ["AK47"] = {price = 1100, class = "weapon_ak472"}, }
Check out this site I'm not an expert with Lua, by any definition, but that doesn't look like a valid table to me.
that doesnt help
I've told you what I believe needs to be done, which is to fix up that table. I've told you how to do it, and even given you a bloody website that explains it in a way a 5 year old could understand it. I'm trying my best to help you here, so help me by helping yourself and at least trying. I refuse to baby feed you code, it doesn't help you learn.
i fixed it i added it in shared folder and it just worked?
The table is fine. Is it local to config.lua, or global? If it's local it isn't going to work. On the other hand, it really shouldn't be global. You could try switching from "WeaponList" to "ENT.WeaponList" and "self.WeaponList" within your functions. Side note, I have no idea what's up with (A) playing weird games with metatables, (B) using usermessages instead of the network library, (C) using ENT:AcceptInput for use.
Yeah your table was valid, but you might have forgot to AddCSLuaFile config.lua
ok my friend helped me with this, and i feel like i shouldnt go with this and just do one by myself? and do it right?
Woops, sorry... It didn't seem fine to me, but i'm not exactly an expert as I said. Apologies all <3
so i put this inside init.lua self:SetUseType(SIMPLE_USE) then went to cl_init.lua and put function weaponpanelframe() local frame = vgui.Create( "DFrame" );     frame.w, frame.h = ScrW() / 1.25, 800;     frame:SetSize( frame.w, frame.h );     frame:Center();     frame:MakePopup();     frame:SetTitle( "" );     frame:SetPaintShadow( true ); end Do not understand what i did wrong lmfao
?? any help
hello?
Well considering the borderline incoherent post rambling about your friend, and the next post where you gave us code and nothing else, I'm not sure what you expect. Nobody is going to take the time to help you if you can't even describe your problem. Is this some modification of your earlier code or is it something new? Is anything set up to call `weaponpanelframe`? How are you actually handling use events? What exactly doesn't work? Are there any errors?
so i press e on my entity and a panel does not open
Please paste the code for your files. Please use the code format as well! Also post the error you are getting :P
error https://i.imgur.com/QKyJJGm.png init file AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include( "shared.lua" ) util.AddNetworkString( "SellerNPCUsed" ) function ENT:Initialize()     self:SetModel( "models/humans/Group01/male_03.mdl" ) end function = ENT:OnTakeDamage()returnfalseendfunction ENT:AcceptInput( Name, Activator, Caller )if Name == "Use" and Caller:IsPlayer() then        net.Start( "SellerNPCUsed" ) net.Send( Caller )     end end
Your code is very malformed, can you use the code tags? Make sure you use this fix.
Use this [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/Use]ENTITY:Use[/url] not accept input. Also, use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/SetupDataTables]ENTITY:SetupDataTables[/url]. You don't want to use the net library in ent functions. And I'm guessing your error is from this. function = ENT:OnTakeDamage()
so how do i fix this im confused
just wanna make it wher ewhen u press e a dpanel pops up?
Yeah? Well we aren't gonna spoon feed you. If you want someone to write code for you pay someone on gmodstore, don't come here asking for help and saying we haven't helped you when we have given you more than enough information to figure it out for yourself.
ok thanks well i dont know my error? https://i.imgur.com/QKyJJGm.png init file AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include( "shared.lua" ) util.AddNetworkString( "SellerNPCUsed" ) function ENT:Initialize() self:SetModel( "models/humans/Group01/male_03.mdl" ) end function = ENT:OnTakeDamage()returnfalseendfunction ENT:AcceptInput( Name, Activator, Caller )if Name == "Use" and Caller:IsPlayer() then net.Start( "SellerNPCUsed" ) net.Send( Caller ) end end
Sorry, you need to Log In to post a reply to this thread.