[QUOTE=Hyper Iguana;39022033][lua]
--serverside
local servers = {
[1] = {
cmd = "!ttt",
ip = "1.1.1.1:27015",
},
[2] = {
cmd = "!darkrp",
ip = "2.2.2.2:27015",
},
}
hook.Add("PlayerSay", "ChatHook", function(ply,text,public )
for _,v in pairs(servers) do
if string.lower(string.Trim(text)) == v.cmd then
ply:ConCommand("connect "..v.ip)
end
end
end)
[/lua][/QUOTE]
Thanks
I'm [I]fairly[/I] new to lua and I have a odd problem in a small gamemode I am working on from scratch.
For some reason no surface library element will draw at all on the screen, I've tested numerous co-ordinates and sizes - nothing draws no matter where I put it and in any case I have tested and the function is called properly without any errors. Any help with this would be greatly appreciated, been sitting here for ages trying to figure out what's wrong.
-snip-
EDIT:
Nevermind, forgot I need to hook it using HUDPaint.. Durr.
I have an issue with a NPC in a darkrp gamemode, its a car shop in darkrp that sells cars, I fixed it but it is in T position, how do i fix this from gmod 12 to gmod 13 i think is something about the bones :S Halp (help for grammar nazis, hail das dictionary)
I need to re-write the function that is called when a prop is USED.
The problem is that if the prop is too large then the AcceptInput/Use function doesn't even get called.
I'm doing this like so:
[lua]
local dropped = ents.Create("prop_physics")
dropped.realclass = v.name
dropped:SetModel(v.mdl)
dropped:SetPos(droppos)
dropped:Spawn()
dropped:Activate()
dropped.AcceptInput = function(name, activator, caller, data)
print("hi")
end
[/lua]
It works on smaller props but when you get to larger props such as fences or blast doors it doesn't even accept the input. How would I go by doing this?
I am trying to network a player entity but PVS keeps getting in the way. On the server it gives me the entity, on the client I get a NULL_ENTITY. Here is an example (I have tried it with net, and Entity(index) and got all the same results)
[lua]
client bit
usermessage.Hook("LevelsSet2",function(data)
print("umsg!!")
print(data:ReadEntity())
end)
server bit
umsg.Start("LevelsSet2",filter)
umsg.Entity(self)
umsg.End()
[/lua]
on the client we get NULL_ENTITY and on the server we get the player entity. Is there a workaround for this madness? I need a table of players on the client for networking and I can't build it if I keep getting this.
[QUOTE=Ylsid;39023556]I am trying to network a player entity but PVS keeps getting in the way. On the server it gives me the entity, on the client I get a NULL_ENTITY. Here is an example (I have tried it with net, and Entity(index) and got all the same results)
[lua]
client bit
usermessage.Hook("LevelsSet2",function(data)
print("umsg!!")
print(data:ReadEntity())
end)
server bit
umsg.Start("LevelsSet2",filter)
umsg.Entity(self)
umsg.End()
[/lua]
on the client we get NULL_ENTITY and on the server we get the player entity. Is there a workaround for this madness? I need a table of players on the client for networking and I can't build it if I keep getting this.[/QUOTE]
Player objects should always be networked, regardless of PVS, otherwise the scoreboard wouldn't work in games like TF2. The only thing that will happen if the player isn't in sight is GetPos() will be inaccurate.
Try using the net library instead, umsg is deprecated and that might be causing issues.
How would I draw Derma elements onto the world with 3D functions?
[B]An example would be this video:[/B]
[URL="http://www.youtube.com/watch?feature=player_detailpage&v=-UtgEghhAoY"]3D2D Derma Example by Overv[/URL]
Thanks!
[QUOTE=thomasfn;39024001]Player objects should always be networked, regardless of PVS, otherwise the scoreboard wouldn't work in games like TF2. The only thing that will happen if the player isn't in sight is GetPos() will be inaccurate.
Try using the net library instead, umsg is deprecated and that might be causing issues.[/QUOTE]
As I've said, net lib made no difference. I suppose I will need to store the entindex and compare it with the players index.
[QUOTE=brandonj4;39026336]How would I draw Derma elements onto the world with 3D functions?
[B]An example would be this video:[/B]
[URL="http://www.youtube.com/watch?feature=player_detailpage&v=-UtgEghhAoY"]3D2D Derma Example by Overv[/URL]
Thanks![/QUOTE]
You cant with the existing derma library, you need to either make your own version of derma, or copy the derma codebase and edit it so that it supports 2D3D.
I'm abandoning Mario's fire/ice balls, for now, but I want to know how to make his jump with a sweapon. I'm thinking I'll need a trace hull.
[editline]30 December 2012[/editline]
[code]ply = self.Owner()
local pos = ply:GetPos()
local ang = Angle(90,0,0)
local tracedata = {}
tracedata.start = pos
tracedata.endpos = pos + ( ang * 0.001) -- I just want JUST AFTER the bottom of the player.tracedata.filter
tracedata.mins=ply:OBBMins
tracedata.maxs=ply:OBBMaxs()
local trace=util.TraceHull(tracedata)
--[[ Insert Damage Data. Check if hit entity has health, then subtract 1 hit. ]][/code]
A quick question regarding the numeric for loop.
Is it possible to add incremental code when you declare the loop like in C#?
[code]
// c#
for (int i = 0; i < 10; i++) // the last thing done here is what I want in lua is it possible?
{
Console.WriteLine(i);
}
[/code]
Instead of
[lua]
for i = 1, 10 do
print(i);
i = i + 1; // I want this replaced.
end
[/lua]
[QUOTE=Christian;39030315]A quick question regarding the numeric for loop.
Is it possible to add incremental code when you declare the loop like in C#?
[code]
// c#
for (int i = 0; i < 10; i++) // the last thing done here is what I want in lua is it possible?
{
Console.WriteLine(i);
}
[/code]
Instead of
[lua]
for i = 1, 10 do
print(i);
i = i + 1; // I want this replaced.
end
[/lua][/QUOTE]
I'm not sure what you're asking, but if you need to loop by incrementing i by more than 1 you can do.
[code]for i = 1, 10, 2[/code]
which will increment i by 2 each iteration, while
[code]for i = 1, 10[/code]
defaults to increasing i by 1 each iteration
[b]Probably the actual answer: [/b]But no actual operator exists for increasing a number like you have shown
What? That can't be true... The default increment by one. I have several codes where i write i = i + 1 at the buttom to increment it...
But I'll look into it.
I was just asking if it was possible to increment the value like you just did where you incremented with two.
Edit:
Okay, I just looked at it.
[lua]
lua_run for i = 0, 10 do i = i + 1 print(i) end
[/lua]
Output:
[code]
1
2
3
4
5
6
7
8
9
10
11
// This is NOT correct.
[/code]
[lua]
lua_run for i = 0, 10 do print(i) end
[/lua]
Output:
[code]
1
2
3
4
5
6
7
8
9
10
// This is correct.
[/code]
You were right.
Thanks for giving me enough suspicion to check it out. :)
btw, [variable name]++; means increment the variable by this name with one.
Which VGUI element should I use to make a menu with tabs except DPropertySheet ? Because it's really buggy for me and requires to put stuff onto a panel.
I'm abandoning Mario's fire/ice balls, for now, but I want to know how to make his jump with a swep. I'm thinking I'll need a trace hull.
[editline]30 December 2012[/editline]
[code]ply = self.Owner()
local pos = ply:GetPos()
local ang = Angle(90,0,0)
local tracedata = {}
tracedata.start = pos
tracedata.endpos = pos + ( ang * 0.001) -- I just want JUST AFTER the bottom of the player.tracedata.filter
tracedata.mins=ply:OBBMins
tracedata.maxs=ply:OBBMaxs()
local trace=util.TraceHull(tracedata)
--[[ Insert Damage Data. Check if hit entity has health, then subtract 1 hit. ]][/code]
I can't do what the old headcrab sweps did, trace a line, because that won't relate properly to Mario. Please give me revised code if applicable.
Is it possible to change view model materials with Lua instead of using separate models for each?
Is the only way to debug server/client crashes to send crash dumps to certain people on these forums? If so, who?
Unrelated, but why does Garry use "L.U.A." in this board's name when the official Lua website has stated forever that it's incorrect?
[quote]Like most names, it should be written in lower case with an initial capital, that is, "Lua". Please do not write it as "LUA", which is both ugly and confusing, because then it becomes an acronym with different meanings for different people.[/quote]
[url]http://www.lua.org/about.html[/url]
Yes. You need skins, though. Then you just need to set the skin number with lua.
[QUOTE=luavirusfree;39031677]Yes. You need skins, though. Then you just need to set the skin number with lua.[/QUOTE]
To add different skins then you would have to decompile and recompile each model? Trying to avoid that.
Well, in that case, I'm not sure. If there is only one material, it is possible; the required command, however, is not known to me.
If you have GCF scape, open Garrysmod.gcf and open the materials LUA. I will figure out where that is... [editline]30 December 2012[/editline]
[code]
TOOL.Category = "Render"
TOOL.Name = "#tool.material.name"
TOOL.Command = nil
TOOL.ConfigName = ""
TOOL.ClientConVar[ "override" ] = "debug/env_cubemap_model"
local function SetMaterial( Player, Entity, Data )
if ( SERVER ) then
Entity:SetMaterial( Data.MaterialOverride )
duplicator.StoreEntityModifier( Entity, "material", Data )
end
return true
end
duplicator.RegisterEntityModifier( "material", SetMaterial )
function TOOL:LeftClick( trace )
if !( trace.Entity && -- Hit an entity
trace.Entity:IsValid() && -- And the entity is valid
trace.Entity:EntIndex() != 0 -- And isn't worldspawn
) then return end
local mat = self:GetClientInfo( "override" )
SetMaterial( self:GetOwner(), trace.Entity, { MaterialOverride = mat } )
return true
end
function TOOL:RightClick( trace )
if !( trace.Entity && -- Hit an entity
trace.Entity:IsValid() && -- And the entity is valid
trace.Entity:EntIndex() != 0 -- And isn't worldspawn
) then return end
SetMaterial( self:GetOwner(), trace.Entity, { MaterialOverride = "" } )
return true
end
list.Add( "OverrideMaterials", "models/wireframe" )
list.Add( "OverrideMaterials", "debug/env_cubemap_model" )
list.Add( "OverrideMaterials", "models/shadertest/shader3" )
list.Add( "OverrideMaterials", "models/shadertest/shader4" )
list.Add( "OverrideMaterials", "models/shadertest/shader5" )
list.Add( "OverrideMaterials", "models/shiny" )
list.Add( "OverrideMaterials", "models/debug/debugwhite" )
list.Add( "OverrideMaterials", "Models/effects/comball_sphere" )
list.Add( "OverrideMaterials", "Models/effects/comball_tape" )
list.Add( "OverrideMaterials", "Models/effects/splodearc_sheet" )
list.Add( "OverrideMaterials", "Models/effects/vol_light001" )
list.Add( "OverrideMaterials", "models/props_combine/stasisshield_sheet" )
list.Add( "OverrideMaterials", "models/props_combine/portalball001_sheet" )
list.Add( "OverrideMaterials", "models/props_combine/com_shield001a" )
list.Add( "OverrideMaterials", "models/props_c17/frostedglass_01a" )
list.Add( "OverrideMaterials", "models/props_lab/Tank_Glass001" )
list.Add( "OverrideMaterials", "models/props_combine/tprings_globe" )
list.Add( "OverrideMaterials", "models/rendertarget" )
list.Add( "OverrideMaterials", "models/screenspace" )
list.Add( "OverrideMaterials", "brick/brick_model" )
list.Add( "OverrideMaterials", "models/props_pipes/GutterMetal01a" )
list.Add( "OverrideMaterials", "models/props_pipes/Pipesystem01a_skin3" )
list.Add( "OverrideMaterials", "models/props_wasteland/wood_fence01a" )
list.Add( "OverrideMaterials", "models/props_foliage/tree_deciduous_01a_trunk" )
list.Add( "OverrideMaterials", "models/props_c17/FurnitureFabric003a" )
list.Add( "OverrideMaterials", "models/props_c17/FurnitureMetal001a" )
list.Add( "OverrideMaterials", "models/props_c17/paper01" )
list.Add( "OverrideMaterials", "models/flesh" )
-- phx
list.Add( "OverrideMaterials", "phoenix_storms/metalset_1-2" )
list.Add( "OverrideMaterials", "phoenix_storms/metalfloor_2-3" )
list.Add( "OverrideMaterials", "phoenix_storms/plastic" )
list.Add( "OverrideMaterials", "phoenix_storms/wood" )
list.Add( "OverrideMaterials", "phoenix_storms/bluemetal" )
list.Add( "OverrideMaterials", "phoenix_storms/cube" )
list.Add( "OverrideMaterials", "phoenix_storms/dome" )
list.Add( "OverrideMaterials", "phoenix_storms/gear" )
list.Add( "OverrideMaterials", "phoenix_storms/stripes" )
list.Add( "OverrideMaterials", "phoenix_storms/wire/pcb_green" )
list.Add( "OverrideMaterials", "phoenix_storms/wire/pcb_red" )
list.Add( "OverrideMaterials", "phoenix_storms/wire/pcb_blue" )
list.Add( "OverrideMaterials", "hunter/myplastic" )
function TOOL.BuildCPanel( CPanel )
-- HEADER
CPanel:SetTooltip( "#tool.material.desc" )
CPanel:MatSelect( "material_override", list.Get( "OverrideMaterials" ), true, 0.33, 0.33 )
end
[/code]
Locale: gmod/gmod/gamemodes/sandbox/entities/weapons/gmod_tool/stools/materials.lua
The command? Entity:SetMaterials... so you just need to find the view/world model entities.
you must do this, though: [code]if (SERVER) then
<weapon>:SetMaterial(X)
<Viewmodel>:SetMaterial(Y)
end[/code]
That WILL remove the player's hands, though. (or rather, re-texture them)
As far as my search says, there is no way to replace a single individual material without skins.
[editline]30 Dec 2012[/editline]
But I would still like some help...
I'm abandoning Mario's fire/ice balls, for now, but I want to know how to make his jump with a swep. I'm thinking I'll need a trace hull.
[code]ply = self.Owner()
local pos = ply:GetPos()
local ang = Angle(90,0,0)
local tracedata = {}
tracedata.start = pos
tracedata.endpos = pos + ( ang * 0.001) -- I just want JUST AFTER the bottom of the player.tracedata.filter
tracedata.mins=ply:OBBMins
tracedata.maxs=ply:OBBMaxs()
local trace=util.TraceHull(tracedata)
--[[ Insert Damage Data. Check if hit entity has health, then subtract 1 hit. ]][/code]
I can't do what the old headcrab sweps did, trace a line, because that won't relate properly to Mario. Please give me revised code if applicable.
For that matter, more specifically, what is the best way to check if anything is below the player, without checking EVERY FRAME... but also without errors (IE: Dying when you hit the head)?
It's easier to do in a gamemode, as I can control when it is, and isn't thinking... but I want to make this separate, for individual case use.
My SWEP Base started acting all weird. The fire sounds just keep looping in a chain. Any ideas of what is causing this?
[media]http://www.youtube.com/watch?v=WpPMFAp3iSU[/media]
[QUOTE='[POR]Shoterxx;39032224']My SWEP Base started acting all weird. The fire sounds just keep looping in a chain. Any ideas of what is causing this?
[B]Video[/B][/QUOTE]
Might want to post some code if you want some help.
[QUOTE=CrashLemon;39032589]Might want to post some code if you want some help.[/QUOTE]
Well, the problem is not the code itself, its a sound issue.
Happened when I changed from:
SWEP.Primary.Sound = Sound( "Clash_M92.Single" )
To:
SWEP.Primary.Sound = Sound( "Clash_M92.Single_Sil" )
One is just a rename from the other with a diferent sound file. That's why I need help, I'm way confused right now.
I need help for this thread: [url]http://facepunch.com/showthread.php?t=1236124[/url] No one has been able to tell me what the problem is.
[QUOTE=brandonj4;39026336]How would I draw Derma elements onto the world with 3D functions?
[B]An example would be this video:[/B]
[URL="http://www.youtube.com/watch?feature=player_detailpage&v=-UtgEghhAoY"]3D2D Derma Example by Overv[/URL]
Thanks![/QUOTE]
Overv released that with some other scripts he made. His post can be found [url=http://www.facepunch.com/showthread.php?p=29643752#post29643752]here[/url], though you'll have to fix it to work with GM13.
[QUOTE=.\\Shadow};39034059]Overv released that with some other scripts he made. His post can be found [url=http://www.facepunch.com/showthread.php?p=29643752#post29643752]here[/url], though you'll have to fix it to work with GM13.[/QUOTE]
Thanks, I probably would have never found that.
I only found a Pastebin of functions used for the process but no actual code, but thank you.
[editline]30th December 2012[/editline]
[QUOTE='[POR]Shoterxx;39032647']Well, the problem is not the code itself, its a sound issue.
Happened when I changed from:
SWEP.Primary.Sound = Sound( "Clash_M92.Single" )
To:
SWEP.Primary.Sound = Sound( "Clash_M92.Single_Sil" )
One is just a rename from the other with a diferent sound file. That's why I need help, I'm way confused right now.[/QUOTE]
When you Emit the sound, be sure to use:
[code]
if (SERVER) or (CLIENT) then
self:EmitSound("mysound")
end
[/code]
This will make sure that it doesn't emit clientside [B]and [/B]serverside. Makes sense?
How do I call self.Owner:SetJumpPower( "1000" ) in a SWEP?? It returned an error the first time.
Remove the double quotes, SetJumpPower accepts a number not a string.
I didn't have the quotes... it still caused an error.
[QUOTE=luavirusfree;39034612]How do I call self.Owner:SetJumpPower( "1000" ) in a SWEP?? It returned an error the first time.[/QUOTE]
posting the error generally helps
Not a problem now. I want to know how to give a swep to the player without errors. self.Owner:Give(swep) errors... (Giving a swep, with a swep).
Also, ents.Create returned an error. Both errors happen in both server and client.
[php]
[ERROR] lua/weapons/smallmario/shared.lua:87: attempt to call field 'Create' (a nil value) 1. unknown - lua/weapons/smallmario/shared.lua:87
[/php] Color: Yellow.
Sorry, you need to Log In to post a reply to this thread.