• What do you need help with? V3
    6,419 replies, posted
So, Ive read through all of the stuff on the GMOD Wiki. What do I do next? Look through other peoples work and see if I can understand what makes them tick?
Yep.
I added a new entity to my darkrp, and when i try to spawn it this pops up: [CODE]ERROR: GAMEMODE:'PlayerSay' Failed: [gamemodes\finaldarkrp\gamemode\main.lua:1166] attempt to index field 'dt' (a nil value) [cpp] Error: hook->PlayerSay returned a non-string![/CODE] Anyone got any fixes? I don't see why the error would be in the gamemode file if the only new thing is the one entity?
You know, the code of the entity would help us find the problem.
Heres the only file i edited (You can see where i commented out and replaced): [LUA]AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") function ENT:Initialize() self.Entity:SetModel("models/props_c17/pottery09a.mdl") self.Entity:PhysicsInit(SOLID_VPHYSICS) self.Entity:SetMoveType(MOVETYPE_VPHYSICS) self.Entity:SetSolid(SOLID_VPHYSICS) self.Entity:SetUseType(SIMPLE_USE) local phys = self.Entity:GetPhysicsObject() if phys and phys:IsValid() then phys:Wake() end self.Entity:SetNWBool("Usable", false) self.Entity:SetNWBool("Plantable", true) level = 0 self.damage = 10 local ply = self.Entity:GetNWEntity("owning_ent") end function ENT:OnTakeDamage(dmg) self.damage = self.damage - dmg:GetDamage() if (self.damage <= 0) then local effectdata = EffectData() effectdata:SetOrigin(self.Entity:GetPos()) effectdata:SetMagnitude(2) effectdata:SetScale(2) effectdata:SetRadius(3) util.Effect("Sparks", effectdata) self.Entity:Remove() end end function ENT:Use() if self.Entity:GetNWBool("Usable") == true then self.Entity:SetNWBool("Usable", false) self.Entity:SetNWBool("Plantable", true) self.Entity:SetModel("models/props_c17/pottery09a.mdl") local SpawnPos = self.Entity:GetPos() local WeedBag = ents.Create("durgz_weed") if level = 1 then WeedBag:SetPos(SpawnPos) WeedBag:Spawn() end if level = 2 then WeedBag:SetPos(SpawnPos) WeedBag:Spawn() WeedBag:Spawn() end if level = 3 then WeedBag:SetPos(SpawnPos) WeedBag:Spawn() WeedBag:Spawn() WeedBag:Spawn() end if level = 4 then WeedBag:SetPos(SpawnPos) WeedBag:Spawn() WeedBag:Spawn() WeedBag:Spawn() WeedBag:Spawn() end if level = 5 then WeedBag:SetPos(SpawnPos) WeedBag:Spawn() WeedBag:Spawn() WeedBag:Spawn() WeedBag:Spawn() WeedBag:Spawn() end end end function ENT:Touch(hitEnt) if hitEnt:GetClass() == "seed_weed" then if self.Entity:GetNWBool("Plantable") == true then if level = 0 then hitEnt:Remove() level = 1 self.Entity:SetModel("models/props_foliage/potted_plant3.mdl") self:SetColor(0, 190, 14, 255) elseif level = 1 then hitEnt:Remove() level = 2 self.Entity:SetModel("models/props_foliage/potted_plant1.mdl") self:SetColor(0, 190, 14, 255) elseif level = 2 then hitEnt:Remove() level = 3 self.Entity:SetModel("models/props_foliage/potted_plant2.mdl") self:SetColor(0, 190, 14, 255) elseif level = 3 then hitEnt:Remove() level = 4 self.Entity:SetModel("models/props/cs_office/plant01.mdl") self:SetColor(0, 190, 14, 255) elseif level = 4 then hitEnt:Remove() level = 5 self.Entity:SetModel("models/props/cs_office/plant01.mdl") self:SetColor(0, 190, 116, 255) self.Entity:SetNWBool("Plantable", false) end //--------------------------------- /*timer.Create("Stage2_"..self:EntIndex(), 10, 1, function() self.Entity:SetModel("models/nater/weedplant_pot_growing1.mdl") end) timer.Create("Stage3_"..self:EntIndex(), 15, 1, function() self.Entity:SetModel("models/nater/weedplant_pot_growing2.mdl") end) timer.Create("Stage4_"..self:EntIndex(), 20, 1, function() self.Entity:SetModel("models/nater/weedplant_pot_growing3.mdl") end) timer.Create("Stage5_"..self:EntIndex(), 25, 1, function() self.Entity:SetModel("models/nater/weedplant_pot_growing4.mdl") end) timer.Create("Stage6_"..self:EntIndex(), 30, 1, function() self.Entity:SetModel("models/nater/weedplant_pot_growing5.mdl") end) timer.Create("Stage7_"..self:EntIndex(), 35, 1, function() self.Entity:SetModel("models/nater/weedplant_pot_growing6.mdl") end) timer.Create("Stage8_"..self:EntIndex(), 40, 1, function() self.Entity:SetModel("models/nater/weedplant_pot_growing7.mdl") self.Entity:SetNWBool("Usable", true) end)*/ end end end function ENT:OnRemove() if self.Entity:GetNWBool("Plantable") == false then /*timer.Destroy("Stage2") timer.Destroy("Stage3") timer.Destroy("Stage4") timer.Destroy("Stage5") timer.Destroy("Stage6") timer.Destroy("Stage7") timer.Destroy("Stage8")*/ end end [/LUA]
[QUOTE=RCRad;34915804]Heres the only file i edited (You can see where i commented out and replaced): -code-[/QUOTE] Could you please use [noparse][LUA][/LUA][/noparse] -tags? Thanks. :)
[QUOTE=pennerlord;34916535]Could you please use [noparse][LUA][/LUA][/noparse] -tags? Thanks. :)[/QUOTE] Yeah, sorry, i changed it.
Looking for a way to notify admins if a player destroys a microwave/gunlab telling us there name in DarkRP. I know it would use things like Entity:GetPhysicsAttacker and Entity:Getname I just cant figure out how to 'put it all together'
Attempting to create a drag and drop derma system for icons inside of boxes. Transferring items from one derma menu to another derma menu by dragging basically. Could someone please give a tutorial? Aswell I'm trying to find out how to create a custom derma skin.
[QUOTE=brandonj4;34922160]Attempting to create a drag and drop derma system for icons inside of boxes. Transferring items from one derma menu to another derma menu by dragging basically. Could someone please give a tutorial? Aswell I'm trying to find out how to create a custom derma skin.[/QUOTE] [img]http://puu.sh/iPZ1[/img] [editline]as[/editline] 1. If you are asking for a tutorial on a derma skin, then a drag and drop derma system is too advanced for you. Although, it's not really that hard. Heres some advice: Make your own panels, don't try and make some shafty system using garrys derma panels. 2. Just google derma skins or something and find someone elses, i'm sure you can find an example pretty easily.
[QUOTE=brandonj4;34922160]Attempting to create a drag and drop derma system for icons inside of boxes. Transferring items from one derma menu to another derma menu by dragging basically. Could someone please give a tutorial? Aswell I'm trying to find out how to create a custom derma skin.[/QUOTE] You could take a look at the [URL="http://luabin.overvprojects.nl/?path=/lua/vgui/DFrame.lua"]DFrame code[/URL]. Since it can be drag and droped it could be useful for you.
I have this code which should respawn weapons once they are picked up. However since I'm not checking if the player already has the weapon, it spams quite a bit and lags. I tried checking if they have a weapon, however after returning false you cannot pickup another weapon in the game. [lua] local function RespawnTrigger(ply,wep) local nextclass, nextpos, nextang = wep:GetClass(), (wep:GetPos() + Vector(0,0,1)), wep:GetAngles() timer.Simple(0.1, function() local ent = ents.Create(nextclass) ent:SetPos(nextpos) ent:SetAngles(nextang) local check = ents.FindInSphere(ent:GetPos(),1) for k,v in pairs(check) do ErrorNoHalt(v:GetOwner()) if v:GetClass() == nextclass && v != ent && v:GetOwner() != "Player" then cantspawn = true end end ErrorNoHalt(cantspawn) if !cantspawn then ent:Spawn() end cantspawn = nil end) end hook.Add("PlayerCanPickupWeapon", "RespawnTrigger", RespawnTrigger) [/lua]
[QUOTE=Mrkrabz;34926658]code[/QUOTE] I made this for my server, it auto-respawns weapons after 30s like HL2DM. Might help :) [lua] --[[ === HSP Plugin Module === sv_RSWep, v1.2 Respawn picked up weapons! ]] local Time = CreateConVar("hsp_rswep", 30, true, false) local DoSound = CreateConVar("hsp_rswep_sound", 1, true, false) local Stuff = { "weapon_*", "item_*", "prop_physics_respawnable" } local BadStuff = { ["item_suitcharger"] = true, ["item_healthcharger"] = true, ["item_suit"] = true, ["item_item_crate"] = true, } function HSP.Wep_Respawn(ent,class,pos,angles,mdl) if not (class and mdl) then return end timer.Simple(Time:GetFloat(), function() local wep = ents.Create(class) wep:SetModel(mdl) wep:SetPos(pos) wep:SetAngles(angles) wep:Spawn() if DoSound:GetBool() then wep:EmitSound( Sound("weapons/stunstick/alyx_stunner"..math.random(1,2)..".wav") ) end wep:CallOnRemove("HSP.Wep_Respawn", HSP.Wep_Respawn, class,pos,angles,mdl) end) end function HSP.Wep_Respawn_Setup() local Tab = {} for k,v in pairs(Stuff) do table.Add(Tab, ents.FindByClass(v) ) end local Done = 0 for k,ent in pairs(Tab) do if not BadStuff[ ent:GetClass() ] then ent:CallOnRemove("HSP.Wep_Respawn", HSP.Wep_Respawn, ent:GetClass(),ent:GetPos(),ent:GetAngles(),ent:GetModel()) Done = Done + 1 end end if Done != 0 then print("[HSP] Will respawn ["..Done.."] items!") end end hook.Add("InitPostEntity", "HSP.Wep_Respawn_Setup", HSP.Wep_Respawn_Setup) [/lua]
Anyone know what the entity name is for the airboat? An example would be like the pistol ammo, which I believe is item_ammo_pistol.
[QUOTE=ace4343;34937004]Anyone know what the entity name is for the airboat? An example would be like the pistol ammo, which I believe is item_ammo_pistol.[/QUOTE] prop_vehicle_airboat ?
[QUOTE=highvoltage;34937118]prop_vehicle_airboat ?[/QUOTE] I mean, if you use ent_create to make it in the console, what would it be?
prop_vehicle_airboat is what the entity is, but you have to set the model yourself.
[QUOTE=pennerlord;34925391]You could take a look at the [URL="http://luabin.overvprojects.nl/?path=/lua/vgui/DFrame.lua"]DFrame code[/URL]. Since it can be drag and droped it could be useful for you.[/QUOTE] Could you please show the part where it's like that? I for some reason can't see that sort of page on chrome..
[QUOTE=brandonj4;34938560]Could you please show the part where it's like that? I for some reason can't see that sort of page on chrome..[/QUOTE] Works for me
[QUOTE=Dame Flawless;34941285]Works for me[/QUOTE][IMG]http://s6.postimage.org/g08sqbca7/doesnt_work.png[/IMG]
Is there a clientside ply:SelectWeapon()? edit: nevermind, found out. "use <class>"
[QUOTE=brandonj4;34947041][IMG]http://s6.postimage.org/g08sqbca7/doesnt_work.png[/IMG][/QUOTE] Refresh the site. Happend to me sometimes too, but I simply had to refresh it.
This is my first code, it's derma but basically an error pops up when I execute it via console. [code][lua\derma\init.lua:53] RunConsoleCommand: Command is blocked! (sv_cheats)[lua\derma\init.lua:53] RunConsoleCommand: Command is blocked! (sv_cheats)17:40[lua\derma\init.lua:53] RunConsoleCommand: Command is blocked! (sv_cheats)[/code] [code]local DermaPanel = vgui.Create("DFrame") -- Creates the frame itself DermaPanel:SetPos(50,50) -- Position on the players screen DermaPanel:SetSize(500, 500) -- Size of the frame DermaPanel:SetTitle("ALIVE") -- Title of the frame DermaPanel:SetVisible(true) DermaPanel:SetDraggable(false) -- Draggable by mouse? DermaPanel:ShowCloseButton(true) -- Show the close button? DermaPanel:SetMouseInputEnabled(true) DermaPanel:MakePopup() -- Show the frame local DermaButton = vgui.Create("DButton") DermaButton:SetParent(DermaPanel) DermaButton:SetText("ALIVE?") DermaButton:SetPos(50,50) DermaButton:SetSize(150,50) DermaButton.DoClick = function () RunConsoleCommand("kill") end local CheckBoxThing = vgui.Create("DCheckBoxLabel", DermaPanel) CheckBoxThing:SetPos(50,250) CheckBoxThing:SetText("Cheats?") CheckBoxThing:SetConVar("sv_cheats") CheckBoxThing:SetValue(1) CheckBoxThing:SizeToContents() [/code] I also tried settings the ConVar to "sv_cheats 1" but instead it returns: [code][lua\derma\init.lua:53] RunConsoleCommand: Command has invalid characters! (sv_cheats 1 (' ')) The first parameter of this function should contain only the command, the second parameter should contain arguments.[lua\derma\init.lua:53] RunConsoleCommand: Command has invalid characters! (sv_cheats 1 (' '))[/code]
Well, kinda easy answer but the command "sv_cheats" is blocked. As you can't use it on your menu.
[QUOTE=Persious;34991699]Well, kinda easy answer but the command "sv_cheats" is blocked. As you can't use it on your menu.[/QUOTE] Is there any way to change that so it does work?
I am not sure, maybe with a module or something. -------------------------------------------------- [lua] _Entity = LastStand.FolderName .. "/entities/entities/*" for k, v in pairs( file.FindDir( _Entity ) ) do if ( v ) then print( "-> ENTITY: " .. v .. " loaded" ) end end [/lua] It doesn't print anything?
are you forgetting a true value as the 2nd arg of file.FindDIr
How do I change a players name? Sort of like ply:Name() = "derpface" But when I tried that it didn't work. Is there a special way to do that?
[QUOTE=Banana Lord.;34994381]are you forgetting a true value as the 2nd arg of file.FindDIr[/QUOTE] Ah, I forgot that. Let me try and see what happens then. [editline]4th March 2012[/editline] It doesn't print anything except a blank space.
[QUOTE=Duskling;34994518]How do I change a players name? Sort of like ply:Name() = "derpface" But when I tried that it didn't work. Is there a special way to do that?[/QUOTE] override _R.Player.Nick [editline]4th March 2012[/editline] [QUOTE=Persious;34994615]Ah, I forgot that. Let me try and see what happens then. [editline]4th March 2012[/editline] It doesn't print anything except a blank space.[/QUOTE] where is this code running from
Sorry, you need to Log In to post a reply to this thread.