[QUOTE=Robotboy655;47374711]You are trying to run clientside functions on server.[/QUOTE]
The code is in cl_init.lua
Would this have something to do with it?
Couldn't include file 'shared.lua' (File not found) (@addons/simple hud/lua/autorun/cl_init.lua (line 1))
The autorun folder is loaded on both client and server. Prefixes are stylistic and affect nothing (except in the case of sweps/entities/gamemodes)
[QUOTE=zerf;47374743]The autorun folder is loaded on both client and server. Prefixes are stylistic and affect nothing (except in the case of sweps/entities/gamemodes)[/QUOTE]
What?
Sorry Im New to Lua
Since you put your code in the autorun folder, it is loaded on both client and server even though you wrote cl_ at the beginning of the file's name.
[QUOTE=CreeperMoon2;47374757]What?
Sorry Im New to Lua[/QUOTE]
File name doesn't affect anything. It should always be unique so that your script won't be overridden any another addon. The only exceptions are SWEPs, ENTs, Lua Effects and game modes.
Files in lua/autorun are included/loaded on both, server and client side. To fix that you want either move your file to lua/autorun/client/ or use if ( CLIENT ) then end statements to separate clientside code from serverside.
Keep in mind that you must mark your script for download so that other players will get the HUD/script when they join a server with your script.
My recommendation is to format your script like this and leave it in lua/autorun/:
[code]
AddCSLuaFile() -- On server this marks this script to be sent to clients, on client it does nothing.
if ( CLIENT ) then
-- Some code to be executed on client only
end
if ( SERVER ) then
-- Some code to be executed on server only
end
-- return outside of any functions will stop the script from loading any lines after this
if ( SERVER ) then return end -- If the script is loaded on server, do not execute further
-- Put all clientside code here
[/code]
Oh, and rename your file to something unique, like [B]creepermoon2_hud.lua[/B].
[editline]22nd March 2015[/editline]
Garry's Mod wiki link: [URL]http://wiki.garrysmod.com/page/Main_Page[/URL]
It contains list of all functions and what they do.
Each function page tells you where you can use the function:
Clientside function:
[img]http://i.imgur.com/lvGlM3K.png[/img]
[IMG]http://i.imgur.com/JEQI7sO.png[/IMG]
Shared function: ( Available both on client AND server )
[IMG]http://i.imgur.com/Cpf1e9R.png[/IMG]
-snip, fixed-
[QUOTE=RedNinja;47373249]How could i call the spectate function from FAdmin in my menu?[/QUOTE]
[lua]RunConsoleCommand("_FAdmin", "Spectate", ply:UserID())[/lua]
- [url]https://github.com/FPtje/DarkRP/blob/master/gamemode/modules/fadmin/fadmin/playeractions/spectate/cl_init.lua#L26[/url]
[QUOTE=Robotboy655;47374799]File name doesn't affect anything. It should always be unique so that your script won't be overridden any another addon. The only exceptions are SWEPs, ENTs, Lua Effects and game modes.
Files in lua/autorun are included/loaded on both, server and client side. To fix that you want either move your file to lua/autorun/client/ or use if ( CLIENT ) then end statements to separate clientside code from serverside.
Keep in mind that you must mark your script for download so that other players will get the HUD/script when they join a server with your script.
My recommendation is to format your script like this and leave it in lua/autorun/:
[code]
AddCSLuaFile() -- On server this marks this script to be sent to clients, on client it does nothing.
if ( CLIENT ) then
-- Some code to be executed on client only
end
if ( SERVER ) then
-- Some code to be executed on server only
end
-- return outside of any functions will stop the script from loading any lines after this
if ( SERVER ) then return end -- If the script is loaded on server, do not execute further
-- Put all clientside code here
[/code]
Oh, and rename your file to something unique, like [B]creepermoon2_hud.lua[/B].
[editline]22nd March 2015[/editline]
Garry's Mod wiki link: [URL]http://wiki.garrysmod.com/page/Main_Page[/URL]
It contains list of all functions and what they do.
Each function page tells you where you can use the function:
Clientside function:
[img]http://i.imgur.com/lvGlM3K.png[/img]
[IMG]http://i.imgur.com/JEQI7sO.png[/IMG]
Shared function: ( Available both on client AND server )
[IMG]http://i.imgur.com/Cpf1e9R.png[/IMG][/QUOTE]
Thanks It Worked
Making an inventory and getting this error:
[CODE]
[ERROR] gamemodes/towerdefense/gamemode/cl_inventory.lua:128: attempt to call method 'Stop' (a nil value)
1. Call - gamemodes/towerdefense/gamemode/cl_inventory.lua:128
2. unknown - gamemodes/base/gamemode/cl_spawnmenu.lua:56
3. unknown - lua/includes/modules/concommand.lua:54
[ERROR] gamemodes/towerdefense/gamemode/cl_inventory.lua:136: attempt to index field 'ItemInfo' (a nil value)
1. Call - gamemodes/towerdefense/gamemode/cl_inventory.lua:136
2. unknown - gamemodes/base/gamemode/cl_spawnmenu.lua:57
3. unknown - lua/includes/modules/concommand.lua:54
[/CODE]
Full Code here:
[url]http://pastebin.com/Hx0jK0SH[/url]
[QUOTE=Aeternal;47375586]Making an inventory and getting this error:
[CODE]
[ERROR] gamemodes/towerdefense/gamemode/cl_inventory.lua:128: attempt to call method 'Stop' (a nil value)
1. Call - gamemodes/towerdefense/gamemode/cl_inventory.lua:128
2. unknown - gamemodes/base/gamemode/cl_spawnmenu.lua:56
3. unknown - lua/includes/modules/concommand.lua:54
[ERROR] gamemodes/towerdefense/gamemode/cl_inventory.lua:136: attempt to index field 'ItemInfo' (a nil value)
1. Call - gamemodes/towerdefense/gamemode/cl_inventory.lua:136
2. unknown - gamemodes/base/gamemode/cl_spawnmenu.lua:57
3. unknown - lua/includes/modules/concommand.lua:54
[/CODE]
Full Code here:
[url]http://pastebin.com/Hx0jK0SH[/url][/QUOTE]
Apparently DFrames don't have the method Stop. I've never done gui creation before, but hopefully that should be helpful.
Also, on line 136 you're trying to reference the variable QMenu, which is undefined in that function's scope.
Will people hate me if I use goto to exit nested for loops?
People will hate you if you use goto at all, unless you are using Basic in which case you have no alternative.
Break your loops into functions, that way you can use recursion.
Just wondering, is there a 'SwitchTo' (or the equivalent) command for DFrames? I have a 'Next' button on a DFrame, that at the moment has to delete itself when pressed, and put a 'Back' button where it used to be. Extremely dodgy, I know, there must be a better way, since making the 'Back' button delete itself and put back a 'Next' button would just be ridiculous considering all the other elements on the DFrame. I got the idea from Garry's DFrame example- self.ContentPanel:SwitchToName( name )
[QUOTE=Aeternal;47375586]Making an inventory and getting this error:
[CODE]
[ERROR] gamemodes/towerdefense/gamemode/cl_inventory.lua:128: attempt to call method 'Stop' (a nil value)
1. Call - gamemodes/towerdefense/gamemode/cl_inventory.lua:128
2. unknown - gamemodes/base/gamemode/cl_spawnmenu.lua:56
3. unknown - lua/includes/modules/concommand.lua:54
[ERROR] gamemodes/towerdefense/gamemode/cl_inventory.lua:136: attempt to index field 'ItemInfo' (a nil value)
1. Call - gamemodes/towerdefense/gamemode/cl_inventory.lua:136
2. unknown - gamemodes/base/gamemode/cl_spawnmenu.lua:57
3. unknown - lua/includes/modules/concommand.lua:54
[/CODE]
Full Code here:
[url]http://pastebin.com/Hx0jK0SH[/url][/QUOTE]
At the top of the file you define QMenu.
Inside OnSpawnMenuOpen you check if QMenu doesn't exist yet (!QMenu). It will [B]always[/B] exist/be not nil since you've defined it at the start - so your panel will never get created.
Your ItemInfo and Stop errors are related, you are trying to index QMenu thinking its a panel you created but QMenu is only what you defined at the top (an empty table).
[editline]23rd March 2015[/editline]
[QUOTE=Maurdekye;47377612]Apparently DFrames don't have the method Stop. I've never done gui creation before, but hopefully that should be helpful.
Also, on line 136 you're trying to reference the variable QMenu, which is undefined in that function's scope.[/QUOTE]
[URL="http://wiki.garrysmod.com/page/Panel/Stop"]Stop[/URL] is defined on Panel so DFrame should inherit it.
QMenu is defined at the top of the file so it is indeed in scope on 136.
The issue is QMenu is an empty table / not a vgui element because of the code.
[code]
[ERROR] addons/cw2/lua/cw/shared/cw_attachmentpossession.lua:14: Tried to use a NULL entity!
1. __newindex - [C]:-1
2. initCWVariables - addons/cw2/lua/cw/shared/cw_attachmentpossession.lua:14
3. postSpawn - addons/cw2/lua/cw/shared/cw_attachmentpossession.lua:53
4. unknown - addons/cw2/lua/cw/server/cw_hooks.lua:3
Timer Failed! [Simple][@addons/cw2/lua/cw/server/cw_hooks.lua (line 2)][/code]
How can i save data spesific to a player ? i mean like i take a police test if im succesfull i wont need to do the cp test again.
[QUOTE=shootbysteve;47378760]How can i save data spesific to a player ? i mean like i take a police test if im succesfull i wont need to do the cp test again.[/QUOTE]
Look into some sort of SQL data basing, if that is too much than use a basic txt document with the file library and the util.TableToJSON and util.JSONToTable functions.
[QUOTE=shootbysteve;47378760]How can i save data spesific to a player ? i mean like i take a police test if im succesfull i wont need to do the cp test again.[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetPData]Player:GetPData[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/SetPData]Player:SetPData[/url] if you want simple data that persists over game sessions.
[QUOTE=Lixquid;47379111][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetPData]Player:GetPData[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/SetPData]Player:SetPData[/url] if you want simple data that persists over game sessions.[/QUOTE]
Thanks thats what i was looking for !!
How would you parent a CLuaEmitter to a view model?
How can i check wether i have a open vgui element or not?
What's up with util.PixelVisible not wanting to run multiple times per frame? This is especially troublesome if the scene is being rendered twice (e.g. render.RenderView etc)
[QUOTE=MattJeanes;47380617]What's up with util.PixelVisible not wanting to run multiple times per frame? This is especially troublesome if the scene is being rendered twice (e.g. render.RenderView etc)[/QUOTE]
how are you getting around the render.RenderView bug?
([url]https://github.com/Facepunch/garrysmod-issues/issues/1850[/url])
I never got that bug after the update. I assume it's because I'm drawing in RenderScene, but here's the rendering code used:
[url]https://github.com/MattJeanes/world-portals/blob/teleport-beta/lua/worldportals/render_cl.lua[/url]
[t]http://i.imgur.com/F342syd.jpg[/t]
I'd appreciate if someone could shed some light on why my entities don't draw themselves after I look away.
[video=youtube;YUkG_T_QbaM]http://www.youtube.com/watch?v=VSA_pRA2dt8[/video]
For several reasons, I copied base_gmodentity and made it into my own. It has the exact same code with a single exception (see below) and just like the original, it is derived from base_anim.
[CODE]DEFINE_BASECLASS( "base_anim" )[/CODE]
The only code I took out from the original ("base_gmodentity.lua") is the following functions:
[CODE]if ( CLIENT ) then
ENT.LabelColor = Color( 255, 255, 255, 255 )
function ENT:BeingLookedAtByLocalPlayer()
if ( LocalPlayer():GetEyeTrace().Entity != self ) then return false end
if ( EyePos():Distance( self:GetPos() ) > 256 ) then return false end
return true
end
end
function ENT:Think()
if ( CLIENT && self:BeingLookedAtByLocalPlayer() && self:GetOverlayText() != "" ) then
AddWorldTip( self:EntIndex(), self:GetOverlayText(), 0.5, self:GetPos(), self.Entity )
halo.Add( { self }, Color( 255, 255, 255, 255 ), 1, 1, 1, true, true )
end
end
function ENT:SetOverlayText( text )
self:SetNetworkedString( "GModOverlayText", text )
end
function ENT:GetOverlayText()
local txt = self:GetNetworkedString( "GModOverlayText" )
if ( txt == "" ) then
return ""
end
if ( game.SinglePlayer() ) then
return txt
end
local PlayerName = self:GetPlayerName()
return txt .. "\n(" .. PlayerName .. ")"
end
[/CODE]
I tested it, and this happens with the above code or without it. I have to admit I'm confuzzled.
e: The balloon and light show up because they are constrained to the ground via rope and Source/Gmod is weird like that
I'm having trouble drawing a sprite to attach to my entity, this is my current code:
[lua]
cam.Start3D(EyePos(), EyeAngles())
render.SetMaterial( Material( "sprites/gmdm_pickups/light" ) )
render.DrawSprite( self.Entity:GetPos() + Vector(-7,-19,15), 10, 10, col)
cam.End3D()
[/lua]
This works, and it draws in the correct position but only if my entity is facing one way, as soon as it's rotated and the angles change it doesn't stay in place as expected.
Setting [lua]cam.Start3D(EyePos(), EyeAngles())[/lua] to [lua]cam.Start3D(self:GetPos(), self:GetAngles())[/lua] causes it to be drawn somewhere in the skybox, I've even tried worldtolocal() but with no success?
Use self:LocalToWorld(Vector(-7,-19,15)), not self:GetPos() + Vector(-7,-19,15).
DO NOT use self.Entity inside ENTs!!!
[QUOTE=Robotboy655;47381899]Use self:LocalToWorld(Vector(-7,-19,15)), not self:GetPos() + Vector(-7,-19,15).
DO NOT use self.Entity inside ENTs!!![/QUOTE]
Sorry yeah, I never use self.Entity normally but I copied the start3D code part from the wiki which had it.
Any idea what is causing this corruption of my data? I switched from using net.WriteTable to sending each individually and I ran into issues. 1 Vector doesn't get sent, a table isn't sent, and 2 strings are mutilated/removed.
[quote]
SERVER:
aAng = 0.000 58.938 0.000
aCol:
a = 255
b = 255
g = 255
r = 255
aPos = 242.943268 -234.710052 -147.968750
hitgroup = 0
mdl = models/combine_soldier_prisonguard.mdl
nick = an NPC
shooterPos = 242.201309 -247.334610 -105.228882
snapshots:
1:
1 = 242.943268 -234.710052 -147.968750
2 = 0.000 58.938 0.000
victimAng = 0.000 -121.182 0.000
victimPos = 291.064911 -138.566803 -147.978485
CLIENT:
aAng = 0.000 58.938 0.000
aCol:
a = 255
b = 255
g = 255
r = 255
hitgroup = -1
mdl = ���{I��=�������ͽ�������}ͽ�����}�ɥͽ��Յɑ�������8A
nick =
snapshots:
victimAng = 0.000 -121.156 0.000
victimPos = 291.062500 -138.562500 -147.968750
[/quote]
Server
[code]
net.WriteAngle( tbl.aAng )
net.WriteAngle( tbl.victimAng )
if type( tbl.aCol ):lower() == "color" then
net.WriteColor( tbl.aCol )
else
net.WriteColor( Color( tbl.aCol.r, tbl.aCol.g, tbl.aCol.b, tbl.aCol.a ) )
end
net.WriteVector( tbl.victimPos )
net.WriteVector( tbl.aPos )
net.WriteVector( tbl.shooterPos )
net.WriteInt( tbl.hitgroup, 3 )
net.WriteString( tbl.mdl )
net.WriteString( tbl.nick )
net.WriteTable( tbl.snapshots )
PrintTable( tbl )
[/code]
Client
[code]
local data = {}
data.aAng = net.ReadAngle()
data.victimAng = net.ReadAngle()
data.aCol = net.ReadColor()
data.victimPos = net.ReadVector()
data.aPos = net.WriteVector()
data.shooterPos = net.WriteVector()
data.hitgroup = net.ReadInt( 3 )
data.mdl = net.ReadString()
data.nick = net.ReadString()
data.snapshots = net.ReadTable()
PrintTable( data )
[/code]
[QUOTE=Exho;47382741]
Client
[code]
data.aPos = net.WriteVector()
data.shooterPos = net.WriteVector()[/code][/QUOTE]
also, you're still sending a table?
Sorry, you need to Log In to post a reply to this thread.