I was wondering, im trying to make a script that gives a player of certain group a loadout. This is what I have...
[CODE]function Loadout( ply )
if ply:IsSuperAdmin() then
ply:Give("gmod_tool")
ply:Give("weapon_physgun")
ply:Give("superadmin_swep")
end
if ply:IsAdmin() then
ply:Give("admin_swep")
end
ply:Give("weapon_physcannon")
ply:SelectWeapon("weapon_physcannon")
return true
end[/CODE]
What I want to know, is how could I make it were that player recieves a gmod_tool but the tool is set to removal. I want superadmins to be given a removal tool as this is for a gamemode edit and they dont have access to the "Q" menu. Any help is appreciated. Thanks in advance!
[QUOTE=Mythikos;37208739]
What I want to know, is how could I make it were that player recieves a gmod_tool but the tool is set to removal. I want superadmins to be given a removal tool as this is for a gamemode edit and they dont have access to the "Q" menu. Any help is appreciated. Thanks in advance![/QUOTE]
Probably the best way to do this is to create your own SWEP which looks like a toolgun but only has the functionality of the Remove tool (just a trace to an Entity and remove it).
There's a console command which sets the tool of the toolgun. I can't really remember how it was, "gmod_tool remover" or something I think, that will change the tool. In order to prevent the user from using any other, use the CanTool hook [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index376e.html[/url]
Anyone know how to dock a DScrollBar to a DListLayout? I've been trying for 2 hours now and I can't figure it out...
edit:
Nevermind figured it out. In case anyone is having a problem do
[lua]
scrollbarpanel:AddItem(itemtoadd)
[/lua]
After everything is done.
another edit:
Now I have this weird spacing between the panel and the start..
[quote][img]http://content.screencast.com/users/Jayzorlolzor/folders/Jing/media/492df4fc-4a32-46bc-ae7c-75853c60b1d3/2012-08-13_1306.png[/img][/quote]
[lua]-- Shared
hook.Add("CanTool", "Remover Tool Restrictor", function(ply, tr, tool)
if (tool ~= "remover") then
if (SERVER) then
ply:ChatPrint("You can't use that!");
else
RunConsoleCommand("gmod_toolmode", "remover");
end
return false;
end
end)
if (CLIENT) then
cvars.AddChangeCallback("gmod_toolmode", function(name, old, new)
if (new ~= "remover") then
RunConsoleCommand(name, "remover");
end
end);
end[/lua]
Probably best to just make a SWep as Dizla says though.
What would be the best encoding for saving a inventory in Gmod 13. I was going to use Glon ,but isn't it gone?
edit:
Nvm glon is still there.
[QUOTE=triscuit6264;37214397]What would be the best encoding for saving a inventory in Gmod 13. I was going to use Glon ,but isn't it gone?[/QUOTE]
Use the serializer Vercas made, its fast, the thread is somewhere on the second page I think.
I'm working on a little side project that involves planets and stars that will interact with eachother.
While I have sorted the basic gravity idea, I have no idea how to make props actually spin around the planets / stars by following certain orbits. At this moment my gravity is pretty much a black hole gravity that sucks props into the planet leaving them spining like crazy in a very very tight pack at the very position of the planet creating clutter and spaz.
Tl;dr I want to make props spin around an entity - orbital style. Could someone point me in the right direction? I'm not asking for code I want to solve it on my own.
[QUOTE=Deadman123;37214459]Use the serializer Vercas made, its fast, the thread is somewhere on the second page I think.[/QUOTE]
[url]http://www.facepunch.com/showthread.php?t=1194008[/url]
[QUOTE=Deadman123;37214459]Use the serializer Vercas made, its fast, the thread is somewhere on the second page I think.[/QUOTE]
[url=http://facepunch.com/showthread.php?t=1202487]:([/url]
Could someone help me use images in my hud, i followed what [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index9bd7.html[/url] said but all i get is
[IMG]http://gyazo.com/804f5c58593be2dc857689bb39c492c5.png?1344888172[/IMG]
The image is called image.vtf and theres a vmt in the same folder.
Thanks
What can I use instead of NW Vars? They seem to be broken in 13.
I'm trying to set the players max HP in a serverside file, and then display it on the HUD. GetNWInt always returns 0 for some reason.
Can someone also explain why it's bad to use them?
I'm having a weird issue with a skill table.
I'm attempting to have a skill translate it's name to it's key and it works, for the first skill. Then all of a sudden every other skill doesn't exist...
[lua]
--Translation code.
function translateSkillToKey(skill)
for k,v in pairs(skills) do
if skill == v.Name then
return k
else
return nil
end
end
end
--Metatable code. (It's returning an invalid skill error.)
function _R.Player:GetSkill(skill)
if translateSkillToKey(skill) != nil then
return self.Skills[translateSkillToKey(skill)] or 0
else
error("Invalid skill!")
end
end
[/lua]
I'm doing tests in the console and it's returning things properly...
[code]
1:
Scale = 0.35
Cap = 100
Name = Endurance
2:
Cap = 100
Name = Agility
3:
Cap = 100
Name = Stamina
[/code]
tried this too:
[code]
] lua_run print(translateSkillToKey("Agility"))
> print(translateSkillToKey("Agility"))...
nil
[/code]
Any ideas? :/
[QUOTE=Coffeee;37218774]What can I use instead of NW Vars? They seem to be broken in 13.
I'm trying to set the players max HP in a serverside file, and then display it on the HUD. GetNWInt always returns 0 for some reason.
Can someone also explain why it's bad to use them?[/QUOTE]
Use the SVN version of Gmod 13, NW Vars are fixed there.
@jrj96 Why returning nil there?
[LUA]
function translateSkillToKey(skill)
for k,v in pairs(skills) do
if skill == v.Name then
return k
else
return nil
end
end
end
[/LUA]
Shouldn't you do that instead?
[LUA]
function translateSkillToKey(skill)
for k,v in pairs(skills) do
if skill == v.Name then
return k
end
end
return false
end
[/LUA]
DarkRP Money Printers, Just two errors in console.
I watched the moneyprinter guide and did put the models in the correct places. Init.lua and in the addentities.lua
[code]
AddEntity("Drug Dealer and Black Market Printer", "models/props_c17/consolebox03a.mdl", "money_printer_helba_ddbm", 8000, 2, "/buyddbmprinter", {TEAM_DRUG, TEAM_BlackMarketDealer})
AddEntity("Mayor's Printer", "models/props_c17/consolebox05a.mdl", "money_printer_helba_mayor", 6000, 1, "/buymayorprinter", {TEAM_MAYOR})
AddEntity("MobBoss Printer MK.2", "models/props_lab/reciever01a.mdl", "money_printer_helba_mobboss_mk2", 10000, 2, "/buymobbossmk2printer", {TEAM_MOB, TEAM_MOB2, TEAM_MOB3})
AddEntity("MobBoss Printer MK.1", "models/props_c17/consolebox03a.mdl", "money_printer_helba_mobboss", 3700, 2, "/buymobbossprinter", {TEAM_MOB, TEAM_MOB2, TEAM_MOB3})
AddEntity("Gangster Money Printer", "models/props_c17/consolebox01a.mdl", "money_printer_helba_gangster", 3500, 2, "/buygangsterprinter", {TEAM_GANG, TEAM_GANG2, TEAM_GANG3})
AddEntity("Home Money Printer", "models/props_c17/consolebox01a.mdl", "money_printer_helba1", 2350, 2, "/buyhomeprinter", {TEAM_CITIZEN})
AddEntity("Advanced Money Printer", "models/props_c17/consolebox01a.mdl", "money_printer_helba2", 6700, 2, "/buyadvancedprinter", {TEAM_CITIZEN})
AddEntity("Supercharged Money Printer", "models/props_lab/reciever01a.mdl", "money_printer_helba3", 12500, 2, "/buysuperchargedprinter", {TEAM_CITIZEN})
AddEntity("Overclocked Money Printer", "models/props_c17/consolebox05a.mdl", "money_printer_helba4", 80000, 2, "/buyoverclockedprinter", {TEAM_CITIZEN})
AddEntity("SR Money Printer", "models/props_c17/consolebox03a.mdl", "money_printer_helba5", 120000, 2, "/buysrmoneyprinter", {TEAM_CITIZEN})[/code]
2 Console errors.
Attempted to create unknown entity type models/props_c17/consolebox03a.mdl!
ERROR: GAMEMODE:'PlayerSay' Failed: [gamemodes\darkrp2\gamemode\server\main.lua:1156] attempt to index field 'dt' (a nil value)
[gamemodes\darkrp2\gamemode\server\player.lua:172] RunConsoleCommand: Command has invalid characters! (models/props_lab/reciever01a.mdl_price ('/'))
The first parameter of this function should contain only the command, the second parameter should contain arguments.[gamemodes\darkrp2\gamemode\server\player.lua:172] RunConsoleCommand: Command has invalid characters!
EDIT:
Screenshot of problem:
[IMG]http://i.epvpimg.com/Zppxh.jpg[/IMG]
[QUOTE=walkmanguy;37219710]DarkRP Money Printers, Just two errors in console.
I watched the moneyprinter guide and did put the models in the correct places. Init.lua and in the addentities.lua
[code]
AddEntity("Drug Dealer and Black Market Printer", "models/props_c17/consolebox03a.mdl", "money_printer_helba_ddbm", 8000, 2, "/buyddbmprinter", {TEAM_DRUG, TEAM_BlackMarketDealer})
AddEntity("Mayor's Printer", "models/props_c17/consolebox05a.mdl", "money_printer_helba_mayor", 6000, 1, "/buymayorprinter", {TEAM_MAYOR})
AddEntity("MobBoss Printer MK.2", "models/props_lab/reciever01a.mdl", "money_printer_helba_mobboss_mk2", 10000, 2, "/buymobbossmk2printer", {TEAM_MOB, TEAM_MOB2, TEAM_MOB3})
AddEntity("MobBoss Printer MK.1", "models/props_c17/consolebox03a.mdl", "money_printer_helba_mobboss", 3700, 2, "/buymobbossprinter", {TEAM_MOB, TEAM_MOB2, TEAM_MOB3})
AddEntity("Gangster Money Printer", "models/props_c17/consolebox01a.mdl", "money_printer_helba_gangster", 3500, 2, "/buygangsterprinter", {TEAM_GANG, TEAM_GANG2, TEAM_GANG3})
AddEntity("Home Money Printer", "models/props_c17/consolebox01a.mdl", "money_printer_helba1", 2350, 2, "/buyhomeprinter", {TEAM_CITIZEN})
AddEntity("Advanced Money Printer", "models/props_c17/consolebox01a.mdl", "money_printer_helba2", 6700, 2, "/buyadvancedprinter", {TEAM_CITIZEN})
AddEntity("Supercharged Money Printer", "models/props_lab/reciever01a.mdl", "money_printer_helba3", 12500, 2, "/buysuperchargedprinter", {TEAM_CITIZEN})
AddEntity("Overclocked Money Printer", "models/props_c17/consolebox05a.mdl", "money_printer_helba4", 80000, 2, "/buyoverclockedprinter", {TEAM_CITIZEN})
AddEntity("SR Money Printer", "models/props_c17/consolebox03a.mdl", "money_printer_helba5", 120000, 2, "/buysrmoneyprinter", {TEAM_CITIZEN})[/code]
2 Console errors.
Attempted to create unknown entity type models/props_c17/consolebox03a.mdl!
ERROR: GAMEMODE:'PlayerSay' Failed: [gamemodes\darkrp2\gamemode\server\main.lua:1156] attempt to index field 'dt' (a nil value)
[gamemodes\darkrp2\gamemode\server\player.lua:172] RunConsoleCommand: Command has invalid characters! (models/props_lab/reciever01a.mdl_price ('/'))
The first parameter of this function should contain only the command, the second parameter should contain arguments.[gamemodes\darkrp2\gamemode\server\player.lua:172] RunConsoleCommand: Command has invalid characters![/QUOTE]
You don't need a / infront of the commands.
Also, in main.lua I think that "dt" is supposed to be "db". Not sure.
[QUOTE=Coffeee;37219791]You don't need a / infront of the commands.
Also, in main.lua I think that "dt" is supposed to be "db". Not sure.[/QUOTE]
Thank's mate, but somewhat why it didn't work, here's one of my money printer files. They're pretty much all the same though:
cl_init.lua:
[code]
include("shared.lua")
function ENT:Draw()
self:DrawModel()
local Pos = self:GetPos()
local Ang = self:GetAngles()
local owner = self.dt.owning_ent
owner = (ValidEntity(owner) and owner:Nick()) or "unknown"
surface.SetFont("HUDNumber6")
local TextWidth = surface.GetTextSize("DD and BM Money Printer")
local TextWidth2 = surface.GetTextSize(owner)
Ang:RotateAroundAxis(Ang:Up(), 90)
cam.Start3D2D(Pos + Ang:Up() * 11.5, Ang, 0.11)
draw.WordBox(2, -TextWidth*0.5, -30, "DD and BM Money Printer", "HUDNumber6", Color(140, 0, 0, 100), Color(255,255,255,255))
draw.WordBox(2, -TextWidth2*0.5, 18, owner, "HUDNumber6", Color(140, 0, 0, 100), Color(255,255,255,255))
cam.End3D2D()
end[/code]
shared.lua [code]
ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Helba's DD & BM Money Printer"
ENT.Author = ""
ENT.Spawnable = false
ENT.AdminSpawnable = false
function ENT:SetupDataTables()
self:DTVar("Int",0,"price")
self:DTVar("Entity",1,"owning_ent")
end[/code]
init.lua [code]
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/props_c17/consolebox03a.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
if phys:IsValid() then phys:Wake() end
self.sparking = false
self.damage = 200
self.IsMoneyPrinter = true
timer.Simple(5, self.CreateMoneybag, self)
end
function ENT:OnTakeDamage(dmg)
if self.burningup then return end
self.damage = self.damage - dmg:GetDamage()
if self.damage <= 0 then
local rnd = math.random(1, 10)
if rnd < 3 then
self:BurstIntoFlames()
else
self:Destruct()
self:Remove()
end
end
end
function ENT:Destruct()
local vPoint = self:GetPos()
local effectdata = EffectData()
effectdata:SetStart(vPoint)
effectdata:SetOrigin(vPoint)
effectdata:SetScale(1)
util.Effect("Explosion", effectdata)
Notify(self.dt.owning_ent, 1, 4, "Your Printer has exploded!")
end
function ENT:Fireball()
if not self:IsOnFire() then return end
local dist = math.random(30, 300) -- Explosion radius
self:Destruct()
for k, v in pairs(ents.FindInSphere(self:GetPos(), dist)) do
if not v:IsPlayer() and not v.IsMoneyPrinter then v:Ignite(math.random(5, 22), 0) end
end
self:Remove()
end
local function PrintMore(ent)
if ValidEntity(ent) then
ent.sparking = true
timer.Simple(1, ent.CreateMoneybag, ent)
end
end
function ENT:CreateMoneybag()
if not ValidEntity(self) then return end
if self:IsOnFire() then return end
local MoneyPos = self:GetPos()
local amount = 5000
if amount == 0 then
amount = 5000
end
DarkRPCreateMoneyBag(Vector(MoneyPos.x + 15, MoneyPos.y, MoneyPos.z + 15), amount)
self.sparking = false
timer.Simple(math.random(100, 150), PrintMore, self)
end
function ENT:Think()
if not self.sparking then return end
local effectdata = EffectData()
effectdata:SetOrigin(self:GetPos())
effectdata:SetMagnitude(1)
effectdata:SetScale(1)
effectdata:SetRadius(2)
util.Effect("Sparks", effectdata)
end
[/code]
You have the entity name and the model the wrong way around, the error in main.lua is triggering because the entity it's tried to create is invalid.
For example
[code]
AddEntity("Drug Dealer and Black Market Printer", "models/props_c17/consolebox03a.mdl", "money_printer_helba_ddbm", 8000, 2, "/buyddbmprinter", {TEAM_DRUG, TEAM_BlackMarketDealer})[/code]
Should be:
[code]AddEntity("Drug Dealer and Black Market Printer", "money_printer_helba_ddbm", "models/props_c17/consolebox03a.mdl", 8000, 2, "/buyddbmprinter", {TEAM_DRUG, TEAM_BlackMarketDealer})[/code]
Does anyone know how I can remove the sound of a player when he falls or when he's burning? I need this for a "ghost" spectating mode.
I have
[code]
local colorCircle = vgui.Create( "DColorCircle" )
colorCircle:SetPos( 35, 75 )
colorCircle:SetSize( 200, 200 )
colorCircle.PaintOver = function()
print(colorCircle:GetRGB());
end[/code]
The issue i'm facing is the fact that it's constantly printing the color to console, even though it's not actively being changed. Is there a way to make it so it only registers when the player actually changes the value?
I got 4 lua errors with my Money Printers, (Just Really Getting Started with coding so I'm not good right now, hope nobody minds) I think someone knows the answer.
Errors:
[code]
Timer Error: [@gamemodes\darkrp2\entities\entities\money_printer_helba4\init.lua:72] bad argument #2 to 'random' (interval is empty)
Timer Error: [@gamemodes\darkrp2\entities\entities\money_printer_helba5\init.lua:72] bad argument #2 to 'random' (interval is empty)
Timer Error: [@gamemodes\darkrp2\entities\entities\money_printer_helba4\init.lua:72] bad argument #2 to 'random' (interval is empty)
Timer Error: [@gamemodes\darkrp2\entities\entities\money_printer_helba4\init.lua:72] bad argument #2 to 'random' (interval is empty)[/code]
[QUOTE=walkmanguy;37226802]I got 4 lua errors with my Money Printers, (Just Really Getting Started with coding so I'm not good right now, hope nobody minds) I think someone knows the answer.
Errors:
[code]
Timer Error: [@gamemodes\darkrp2\entities\entities\money_printer_helba4\init.lua:72] bad argument #2 to 'random' (interval is empty)
Timer Error: [@gamemodes\darkrp2\entities\entities\money_printer_helba5\init.lua:72] bad argument #2 to 'random' (interval is empty)
Timer Error: [@gamemodes\darkrp2\entities\entities\money_printer_helba4\init.lua:72] bad argument #2 to 'random' (interval is empty)
Timer Error: [@gamemodes\darkrp2\entities\entities\money_printer_helba4\init.lua:72] bad argument #2 to 'random' (interval is empty)[/code][/QUOTE]
math.random( Number Start Range[, Number End Range] )
:eng101:
[QUOTE=brandonj4;37226852]math.random( Number Start Range[, Number End Range] )
:eng101:[/QUOTE]
Well this is what I got, doesn't seem to different.
[code]
timer.Simple(math.random(150, 150), PrintMore, self)
[/code]
[QUOTE=walkmanguy;37227102]Well this is what I got, doesn't seem to different.
[code]
timer.Simple(math.random(150, 150), PrintMore, self)
[/code][/QUOTE]
If it's the same number you would put:
timer.Simple(150, PrintMore, self)
[QUOTE=brandonj4;37227137]If it's the same number you would put:
timer.Simple(150, PrintMore, self)[/QUOTE]
Alright i'll try that
What seems to be a bit odd, it works on the Main SVN with that kind of Code
[Code]
timer.Simple(math.random(100, 350), PrintMore, self)[/code]
[QUOTE=walkmanguy;37227167]Alright i'll try that
What seems to be a bit odd, it works on the Main SVN with that kind of Code
[Code]
timer.Simple(math.random(100, 350), PrintMore, self)[/code][/QUOTE]
You didn't spot why it didn't work i'm assuming.
If it is math.random(100, 350), so math.random will grab a number between 100 and 350.
You on the other hand had it as math.random(150,150), so math.random was trying to grab a number between 150 and 150 since there was nothing it returned with an interval error.
So there's another problem that I had with these printers, they wouldn't continue printing, would this fix the problem?
Sorry, you need to Log In to post a reply to this thread.