WTF is this.
[code]
[ERROR] gamemodes/requiem/gamemode/cl_init.lua:50: attempt to call method 'StripWeapons' (a nil value)
1. DoClick - gamemodes/requiem/gamemode/cl_init.lua:50
2. unknown - lua/vgui/dlabel.lua:206
[/code]
Code beign used:
[code]local function OpenF3Menu( _p )
local _panel = vgui.Create( "DFrame" );
_panel:SetSize( 400, 200 );
_panel:Center( );
_panel:SetTitle( "test elredlachupa1" );
_panel:MakePopup( );
local button1 = vgui.Create( "DButton", _panel);
button1:SetText( "Go Heavy" );
button1:SetPos( 25, 50 );
button1:SetSize( 150, 40 );
button1.DoClick = function( )
ply:StripWeapons()
ply:Give("weapon_m249")
ply:Give("cw_deagle")
ply:Give("weapon_oic_knife")
ply:Armor(100)
end;
local button2 = vgui.Create( "DButton", _panel );
button2:SetText( "Go Assault" );
button2:SetPos( 225, 50 );
button2:SetSize( 150, 40 );
button2.DoClick = function( )
ply:StripWeapons()
ply:Give("cw_g3a3")
ply:Give("cw_deagle")
ply:Give("weapon_oic_knife")
ply:Armor(100)
end;
local button3 = vgui.Create( "DButton", _panel );
button3:SetText( "Get equipment" );
button3:SetPos( 25, 100 );
button3:SetSize( 150, 40 );
button3.DoClick = function( )
local menu1 = vgui.Create( "DMenu", button3 );
menu1:AddOption( "test0" );
menu1:AddOption( "test1" );
menu1:AddOption( "test2" );
menu1:AddOption( "test3" );
menu1:AddOption( "test4" );
menu1:AddSpacer( );
local submenu1 = menu1:AddSubMenu( "attachments" );
submenu1:AddOption( "test5" );
submenu1:AddOption( "test6" );
menu1:Open( );
end;
end[/code]
Everything else works just fine, but whenever I click on the "Go Assault" button, then this comes out :/
stripweapons is serverside
[editline]a[/editline]
so is give and armor
[editline]a[/editline]
armor is shared, but you can't use armor to set armor, you use setarmor, which is serverside
[QUOTE=GreenGold;46743263]What could be causing that in ttt frame rate is dropping after every round.
Example if i start on 120fps after 10 rounds i am down on 30fps.[/QUOTE]
Question, do you have Atmos installed? you know, that weather mod causes some frame rate drops after a couple minutes on some gamemodes/maps
[editline]18th December 2014[/editline]
[QUOTE=PortalGod;46743504]stripweapons is serverside[/QUOTE]
Any way to take a player's weapons on clientside? all the code there is on clientside files :/
[QUOTE=Scarface3353;46743506]Question, do you have Atmos installed? you know, that weather mod causes some frame rate drops after a couple minutes on some gamemodes/maps
[editline]18th December 2014[/editline]
Any way to take a player's weapons on clientside? all the code there is on clientside files :/[/QUOTE]
you can use a concommand or a net message to let the server know you want to do all that
[QUOTE=Scarface3353;46743506]Question, do you have Atmos installed? you know, that weather mod causes some frame rate drops after a couple minutes on some gamemodes/maps
[editline]18th December 2014[/editline]
Any way to take a player's weapons on clientside? all the code there is on clientside files :/[/QUOTE]
No i dont have that, i have end round slow motion
another error, now it's with Net
[code]
SERVER: Net message recieved from Client!
TEST [lua/includes/modules/momo.lua][lua/includes/modules/net.lua]
TEST [lua/includes/modules/pk_pills.lua][lua/includes/modules/net.lua]
[ERROR] gamemodes/requiem/gamemode/init.lua:99: attempt to index local 'ply' (a number value)
1. func - gamemodes/requiem/gamemode/init.lua:99
2. unknown - lua/includes/modules/net.lua:32
[/code]
Serverside
[code]function NetAssault1()
net.Receive( "AssaultButtonPressed", function( ply )
print( "SERVER: Net message recieved from Client!" )
LocalPlayer():StripWeapons( )
ply:Give( "cw_g3a3" )
ply:Give( "cw_deagle" )
ply:Give( "weapon_oic_knife" )
ply:SetArmor(100)
end )
end[/code]
Clientside:
[code] local button2 = vgui.Create( "DButton", _panel );
button2:SetText( "Go Assault" );
button2:SetPos( 225, 50 );
button2:SetSize( 150, 40 );
button2.DoClick = function( )
net.Start( "AssaultButtonPressed" )
net.SendToServer()
end;
[/code]
[QUOTE=Scarface3353;46743887]another error, now it's with Net
-snip snap snoop-[/QUOTE]
[url]http://wiki.garrysmod.com/page/net/Receive[/url]
[code]
net.Receive(string, function(len, ply)
end)
[/code]
not just...
[code]
net.Receive(string, function(ply)
end)
[/code]
also not sure why you have the receive inside another function, but, what do I know?
[QUOTE=MadkillerMax;46743923][url]http://wiki.garrysmod.com/page/net/Receive[/url]
[code]
net.Receive(string, function(len, ply)
end)
[/code]
not just...
[code]
net.Receive(string, function(ply)
end)
[/code]
also not sure why you have the receive inside another function, but, what do I know?[/QUOTE]
first time using net library, confused sending and receiving (when sending, it's inside a function, but when receiving, it's not)
works perfectly :D
[QUOTE=Scarface3353;46743973]first time using net library, confused sending and receiving (when sending, it's inside a function, but when receiving, it's not)
works perfectly :D[/QUOTE]
When it receives a net call, it is equal to a hook, except coming from the client to the server and vice versa.
Therefore, no need to have the receive itself inside a function. Ever.
[QUOTE=GreenGold;46743263]What could be causing that in ttt frame rate is dropping after every round.
Example if i start on 120fps after 10 rounds i am down on 30fps.[/QUOTE]
Any ideas?
GM:ContextMenuOpen( ) doesn't work, same goes for the spawn menu. These hooks are called running DarkRP. What's the issue?
[QUOTE=RedNinja;46744054]GM:ContextMenuOpen( ) doesn't work, same goes for the spawn menu. These hooks are called running DarkRP. What's the issue?[/QUOTE]
What are you trying to do?
[QUOTE=Robotboy655;46744151]What are you trying to do?[/QUOTE]
just returning false
[code]
hook.Add("ContextMenuOpen", "", function() return false end )[/code]
Should do the trick, unless DarkDP does not support this hook.
Quick question, how to, using net., make something only buyable (does that word even exist) once per round-player respawn
I have a script below that forces the player's mic on to see if they're ghosting in TTT. Originally, it only forced the player's mic on, but spammed console with +voicerecord and the voice bubble stayed in the top right. It's now modified so that it doesn't spam +voicerecord in the console and the voice bubble doesn't appear. Thing is, since I can only test this in singleplayer, I don't know if anyone else can see the voice bubble of that person, and if the person affected can see anyone else's voice bubble. Can anyone confirm this for me and tell me how to fix it if it's a problem?
Additionally, the voice bubble reappears and stays as it normally would if the player presses their talk button, instead of hiding it like it normally would.
[lua]function ulx.micon(calling_ply, target_ply)
target_ply:SendLua([[
timer.Create("mictoggle", 0.2, 0, function()
RunConsoleCommand("+voicerecord")
end)
hook.Add("HUDShouldDraw", "HideVoice", function(name)
if (name == "CHudVoiceSelfStatus") then
return false
end
end)
]])
ulx.fancyLogAdmin(calling_ply, true, "#A Toggled +voicerecord on #T", target_ply)
end
local micon = ulx.command("Chat", "ulx micon", ulx.micon, "!micon")
micon:addParam{ type=ULib.cmds.PlayerArg }
micon:defaultAccess(ULib.ACCESS_SUPERADMIN)
micon:help("Force microphone on.")
function ulx.micoff(calling_ply, target_ply)
target_ply:SendLua([[
timer.Destroy("mictoggle")
RunConsoleCommand("-voicerecord")
hook.Remove("HUDShouldDraw", "HideVoice")
]])
ulx.fancyLogAdmin(calling_ply, true, "#A Toggled -voicerecord on #T", target_ply)
end
local micoff = ulx.command("Chat", "ulx micoff", ulx.micoff, "!micoff")
micoff:addParam{ type=ULib.cmds.PlayerArg }
micoff:defaultAccess(ULib.ACCESS_SUPERADMIN)
micoff:help("Force microphone off.")[/lua]
(And no, I don't want to discuss the legality of this. I already know that it's a violation of the 4th amendment unless it's stated that it's possible upon entering the server, and we're handling that.)
Open up a second Garry's Mod using this .bat file ( lower resolution because it doesn't matter since it is a dummy but can still be played ): [code]cd C:/Program Files (x86)/Steam/steamapps/common/garrysmod/
hl2.exe -dxlevel 81 -multirun -steam -windowed -w 640 -h 480 -x 0 -y 0 +mat_bumpmap 0 +mat_picmip 2 -exec autoexec.cfg +exec autoexec.cfg
exit[/code]
You may want to remove the dxlevel as it will reset graphics.. I'd recommend creating a different .bat to start in dxlevel 110 or whatever and use this graphic setting file autoexec.cfg: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/__documentation/autoexec.cfg[/url] that way your main gmod launches in high video settings while the secondary launches using low.
Add to server config: sv_lan 1
Then you can join with more than 1 gmod on your server. Also, never test code using a Listen Server ( server started by gmod client ) because you may get unreliable results. Create a local SRCDS, it's easy and here's how: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/setting_up_a_server_with_steamcmd.lua.html[/url]
So why can you does pcall require a function to be within a function
[code]
s, e = pcall( function() print("Hi") end)
//RETURNS
true nil
[/code]
Where if you call it outside of a function it fails
[code]
s, e = pcall( print("Hi") )
//RETURNS
false attempt to call a nil value
[/code]
The wiki [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/pcall]Global.pcall[/url]
doesn't mention anything about a value, even though this error is printed when the second example is used.
[code]
[ERROR] lua_run:1: bad argument #1 to 'pcall' (value expected)
1. pcall - [C]:-1
2. unknown - lua_run:1
[/code]
You can run it many ways...
[url]http://www.lua.org/cgi-bin/demo[/url]
[code]local function test( arg )
print( arg );
end
// This passes a function by reference and passes in one arg
local _r, _err = pcall( test, true )
print( _r, _err )
// This defines a function within pcall and hard-codes the args
local _r, _err = pcall( function( ) test( true ) end );
print( _r, _err )
// This defines a function inside of pcall and forwards all args by pcall into function then into test via ...
local _r, _err = pcall( function( ... ) test( ... ) end, true );
print( _r, _err )[/code]
So, it expects a function as the first argument; when you create a function it returns the reference meaning the following function declarations are identical:
[code]local test = function( arg ) print( arg ); end
local function test( arg ) print( arg ); end[/code]
So, because declaring a function returns the reference and because pcall needs a function reference to be the first argument, it works by either passing the reference or creating one in pcall ( works like this for many other methods too ).
Now, for how it passes in arguments, it uses ...; Anything after ( ... ) is then passed into the function that was given in the first argument. ... means any and all arguments from that point on, and you can pass ... into a function easily.
So, if you wanted to write pcall out as a function you're creating, you'd do something like this:
[code]function pcall( _func, ... )
local _errors = false;
local _err = "";
if ( !_func ) then
_errors = true;
_err = _err .. "No function reference was passed in!\n";
end
if ( !isfunction( _func ) then
_errors = true;
_err = _err .. "Expecting function as first argument.. received " .. type( _func ) .. " instead!\n";
end
// If errors exist, return false with the error message
if ( _errors ) then
return false, _err;
end
// Call the function
_func( ... );
// Because it was successful we return true and nil, it might make sense to return the function instead in case it had its own arguments...
return true, nil;
end[/code]
would be similar but not quite it.
-snip-
Do you want to rotate the hull? I don't think it's possible to rotate the hull, but you can change what direction you're tracing. I guess you can do some pretty radical math using OBBMins and OBBMaxs, scaling the hitbox based on the direction you're tracing, and the original size. It's hard for me to explain what I mean.
[editline]19th December 2014[/editline]
Or you could just do 4 or 5 traces. One trace for each corner, maybe one in the middle as well. The math there would be a lot easier.
[editline]19th December 2014[/editline]
If you want to change the HULL of an object itself, then the only way would be some radical math based on what direction you're flying.
[QUOTE=Scarface3353;46743887]another error, now it's with Net
[code]
SERVER: Net message recieved from Client!
TEST [lua/includes/modules/momo.lua][lua/includes/modules/net.lua]
TEST [lua/includes/modules/pk_pills.lua][lua/includes/modules/net.lua]
[ERROR] gamemodes/requiem/gamemode/init.lua:99: attempt to index local 'ply' (a number value)
1. func - gamemodes/requiem/gamemode/init.lua:99
2. unknown - lua/includes/modules/net.lua:32
[/code]
Serverside
[code]function NetAssault1()
net.Receive( "AssaultButtonPressed", function( ply )
print( "SERVER: Net message recieved from Client!" )
LocalPlayer():StripWeapons( )
ply:Give( "cw_g3a3" )
ply:Give( "cw_deagle" )
ply:Give( "weapon_oic_knife" )
ply:SetArmor(100)
end )
end[/code]
[/QUOTE]
Firstly you're calling LocalPlayer() serverside. LocalPlayer is clientside, secondly the first parameter in a net receive is always the len, ply is second. Let me fix that serverside code for you. And thirdly you probably shouldn't put net.Receive inside a function in the way you do, no point. I wouldn't at least idk.
[code]net.Receive( "AssaultButtonPressed", function( len, ply )
print( "SERVER: Net message recieved from Client!" )
ply:StripWeapons( )
ply:Give( "cw_g3a3" )
ply:Give( "cw_deagle" )
ply:Give( "weapon_oic_knife" )
ply:SetArmor(100)
end )[/code]
How do I set a color to an entity on DModelPanel if the model is a playermodel?
[CODE] local icon = vgui.Create( "DModelPanel", plypan )
icon:SetSize( 500,690 )
icon:SetPos( -150, -40 )
icon:SetModel( ply:GetModel() )
function icon:LayoutEntity( Entity ) return end -- disables default rotation
local DColorPalette = vgui.Create( "DColorPalette", pan )
DColorPalette:SetPos( 370,545 )
DColorPalette:SetSize( 200, 25 )
DColorPalette.DoClick = function(b)
icon:SetColor(DColorPalette:GetConVarR(),DColorPalette:GetConVarG(),DColorPalette:GetConVarB(),255)
end
[/CODE]
[CODE]
[ERROR] lua/vgui/dmodelpanel.lua:133: attempt to index field 'colColor' (a nil value)
1. unknown - lua/vgui/dmodelpanel.lua:133
[/CODE]
[img]http://i.imgur.com/vd8SBlB.png[/img]
How the hell do i even find the source of this? :v:
[QUOTE=Giraffen93;46750627][img]http://i.imgur.com/vd8SBlB.png[/img]
How the hell do i even find the source of this? :v:[/QUOTE]
All I can suggest is to temporarily modify the hook library to use pcall and to print more detailed errors with debug.getinfo and the likes.
How to use Entity/SetNWInt() and how to use it to make something once per player spawn
Does anyone know if there's a snow particle in Garry's Mod? [url]https://privatepaste.com/1709700079[/url] Where bday_confetti is, change it out with snow.
is there a way to have multiple lines in dlabel?
edit: im just using dtextentry but thx anyways
[QUOTE=Lolm4te;46752513]is there a way to have multiple lines in dlabel?
edit: im just using dtextentry but thx anyways[/QUOTE]
Use \n in the text to go down by a line.
For some reason, it takes a second to render my sniper scope and errors.
Code:
[code]
function SWEP:Initialize()
if (SERVER) then
// Fucking NPCs
self:SetNPCMinBurst(30)
self:SetNPCMaxBurst(30)
self:SetNPCFireRate(self.Primary.Delay)
end
self:SetHoldType(self.HoldType)
if (CLIENT) then
local iScreenWidth = surface.ScreenWidth()
local iScreenHeight = surface.ScreenHeight()
self.ScopeTable = {}
self.ScopeTable.l = iScreenHeight * self.ScopeScale
self.ScopeTable.x1 = 0.5 * (iScreenWidth + self.ScopeTable.l)
self.ScopeTable.y1 = 0.5 * (iScreenHeight - self.ScopeTable.l)
self.ScopeTable.x2 = self.ScopeTable.x1
self.ScopeTable.y2 = 0.5 * (iScreenHeight + self.ScopeTable.l)
self.ScopeTable.x3 = 0.5 * (iScreenWidth - self.ScopeTable.l)
self.ScopeTable.y3 = self.ScopeTable.y2
self.ScopeTable.x4 = self.ScopeTable.x3
self.ScopeTable.y4 = self.ScopeTable.y1
self.ParaScopeTable = {}
self.ParaScopeTable.x = 0.5 * iScreenWidth - self.ScopeTable.l
self.ParaScopeTable.y = 0.5 * iScreenHeight - self.ScopeTable.l
self.ParaScopeTable.w = 2 * self.ScopeTable.l
self.ParaScopeTable.h = 2 * self.ScopeTable.l
self.ScopeTable.l = (iScreenHeight + 1) * self.ScopeScale
self.QuadTable = {}
self.QuadTable.x1 = 0
self.QuadTable.y1 = 0
self.QuadTable.w1 = iScreenWidth
self.QuadTable.h1 = 0.5 * iScreenHeight - self.ScopeTable.l
self.QuadTable.x2 = 0
self.QuadTable.y2 = 0.5 * iScreenHeight + self.ScopeTable.l
self.QuadTable.w2 = self.QuadTable.w1
self.QuadTable.h2 = self.QuadTable.h1
self.QuadTable.x3 = 0
self.QuadTable.y3 = 0
self.QuadTable.w3 = 0.5 * iScreenWidth - self.ScopeTable.l
self.QuadTable.h3 = iScreenHeight
self.QuadTable.x4 = 0.5 * iScreenWidth + self.ScopeTable.l
self.QuadTable.y4 = 0
self.QuadTable.w4 = self.QuadTable.w3
self.QuadTable.h4 = self.QuadTable.h3
self.LensTable = {}
self.LensTable.x = self.QuadTable.w3
self.LensTable.y = self.QuadTable.h1
self.LensTable.w = 2 * self.ScopeTable.l
self.LensTable.h = 2 * self.ScopeTable.l
self.CrossHairTable = {}
self.CrossHairTable.x11 = 0
self.CrossHairTable.y11 = 0.5 * iScreenHeight
self.CrossHairTable.x12 = iScreenWidth
self.CrossHairTable.y12 = self.CrossHairTable.y11
self.CrossHairTable.x21 = 0.5 * iScreenWidth
self.CrossHairTable.y21 = 0
self.CrossHairTable.x22 = 0.5 * iScreenWidth
self.CrossHairTable.y22 = iScreenHeight
end
self.ScopeZooms = self.ScopeZooms or {5}
self.CurScopeZoom = 1
self:ResetVariables()
if CLIENT then
// Create a new table for every weapon instance
self.VElements = table.FullCopy( self.VElements )
self.WElements = table.FullCopy( self.WElements )
self.ViewModelBoneMods = table.FullCopy( self.ViewModelBoneMods )
self:CreateModels(self.VElements) // create viewmodels
self:CreateModels(self.WElements) // create worldmodels
// init view model bone build function
if IsValid(self.Owner) then
local vm = self.Owner:GetViewModel()
if IsValid(vm) then
self:ResetBonePositions(vm)
// Init viewmodel visibility
if (self.ShowViewModel == nil or self.ShowViewModel) then
vm:SetColor(Color(255,255,255,255))
else
// we set the alpha to 1 instead of 0 because else ViewModelDrawn stops being called
vm:SetColor(Color(255,255,255,1))
// ^ stopped working in GMod 13 because you have to do Entity:SetRenderMode(1) for translucency to kick in
// however for some reason the view model resets to render mode 0 every frame so we just apply a debug material to prevent it from drawing
vm:SetMaterial("Debug/hsv")
end
if self.Golden then vm:SetSkin(9) end
end
end
end
end
if CLIENT then
local iScreenWidth = surface.ScreenWidth()
local iScreenHeight = surface.ScreenHeight()
end
local SCOPEFADE_TIME = 0.4
local dot=Material("scope/scope_reddot.png")
local scope=Material("scope/scope_normal.png")
function SWEP:DrawHUD()
self:SecondDrawHUD()
self:DrawFuelHUD()
if (self.Sniper) then
local bScope = self.Weapon:GetDTBool(2)
if bScope ~= self.bLastScope then // Are we turning the scope off/on?
self.bLastScope = bScope
self.fScopeTime = CurTime()
elseif bScope then
local fScopeZoom = self.Weapon:GetNetworkedFloat("ScopeZoom")
if fScopeZoom ~= self.fLastScopeZoom then // Are we changing the scope zoom level?
self.fLastScopeZoom = fScopeZoom
self.fScopeTime = CurTime()
end
end
local fScopeTime = self.fScopeTime or 0
if fScopeTime > CurTime() - SCOPEFADE_TIME then
local Mul = 1.0 -- This scales the alpha
Mul = 1 - math.Clamp((CurTime() - fScopeTime) / SCOPEFADE_TIME, 0, 1)
surface.SetDrawColor(0, 0, 0, 255 * Mul) // Draw a black rect over everything and scale the alpha for a neat fadein effect
surface.DrawRect(0, 0, iScreenWidth,iScreenHeight)
end
if (bScope) then
// Draw the crosshair
if not (self.RedDot) then
surface.SetDrawColor(0, 0, 0, 255)
surface.DrawLine(self.CrossHairTable.x11, self.CrossHairTable.y11, self.CrossHairTable.x12, self.CrossHairTable.y12)
surface.DrawLine(self.CrossHairTable.x21, self.CrossHairTable.y21, self.CrossHairTable.x22, self.CrossHairTable.y22)
end
// Put the texture
surface.SetDrawColor(255, 255, 255, 255)
if (self.RedDot) then
surface.SetMaterial(dot)
else
surface.SetMaterial(scope)
end
surface.DrawTexturedRect(self.LensTable.x, self.LensTable.y, self.LensTable.w, self.LensTable.h)
// Fill in everything else
surface.SetDrawColor(0, 0, 0, 255)
surface.DrawRect(self.QuadTable.x1 - 2.5, self.QuadTable.y1 - 2.5, self.QuadTable.w1 + 5, self.QuadTable.h1 + 5)
surface.DrawRect(self.QuadTable.x2 - 2.5, self.QuadTable.y2 - 2.5, self.QuadTable.w2 + 5, self.QuadTable.h2 + 5)
surface.DrawRect(self.QuadTable.x3 - 2.5, self.QuadTable.y3 - 2.5, self.QuadTable.w3 + 5, self.QuadTable.h3 + 5)
surface.DrawRect(self.QuadTable.x4 - 2.5, self.QuadTable.y4 - 2.5, self.QuadTable.w4 + 5, self.QuadTable.h4 + 5)
end
end
if (self.Weapon:GetDTBool(1) and not self.Weapon:GetNetworkedBool("Suppressor")) or (cl_crosshair_t:GetBool() == false) or (LocalPlayer():InVehicle()) then return end
local hitpos = util.TraceLine ({
start = LocalPlayer():GetShootPos(),
endpos = LocalPlayer():GetShootPos() + LocalPlayer():GetAimVector() * 4096,
filter = LocalPlayer(),
mask = MASK_SHOT
}).HitPos
local screenpos = hitpos:ToScreen()
local x = screenpos.x
local y = screenpos.y
if self.Primary.Cone < 0.005 then
self.Primary.Cone = 0.005
end
local gap = ((self.Primary.Cone * 275) + (((self.Primary.Cone * 275) * (ScrH() / 720))) * (1 / self:CrosshairAccuracy())) * 0.75
gap = math.Clamp(gap, 0, (ScrH() / 2) - 100)
local length = cl_crosshair_l:GetInt()
self:DrawCrosshairHUD(x - gap - length, y - 1, length, 3) // Left
self:DrawCrosshairHUD(x + gap + 1, y - 1, length, 3) // Right
self:DrawCrosshairHUD(x - 1, y - gap - length, 3, length) // Top
self:DrawCrosshairHUD(x - 1, y + gap + 1, 3, length) // Bottom
end
[/code]
Sorry, you need to Log In to post a reply to this thread.