Jesus fucking christ, I figured it out. My function has 'file' as an argument because obviously its going to load a file right? Well using 'file' means that 'file.Read' tries to call the function 'Read' on my string. Basically I am a moron and need to use different variable names
If I have a material for instance, How can I repeat it horizontally without having to draw it multiple times?
[QUOTE=_Entity;46580741]If I have a material for instance, How can I repeat it horizontally without having to draw it multiple times?[/QUOTE]
surface.DrawTexturedRectUV
if you choose u/v > 1 the texture will repeat
I'm still deathly confused on callbacks. Could someone correct my code?
[lua]
function CSSAskForCommand(command,callback)
local value = -1
net.Start("CSSAskForCommand")
net.WriteString(command)
net.SendToServer()
net.Receive("CSSGetCommand", callback )
if value == -1 then
print("[CLIENT]: Asking what the value of " .. command .. " is..." )
else
print("[CLIENT]: The value of the server's " .. command .. " is " .. value .. "." )
end
if callback == nil then
CSSAskForCommand(command,1)
value = net.ReadFloat()
end
return value
end[/lua]
[QUOTE=Ott;46580551]GMOD Prone Back 2014 in Nutscript.: [url]http://youtu.be/WfhtkY-wQ7g[/url][/QUOTE]
Well I have seen that I was trying to get the name of the prone animation for the models though. What I wanted to do is on spawn is set all models to a invisible DOD:S model and then bone-merge their original model back onto it so that I can simply set the prone animations at will on the player model.
Edit------------------------
I think I found the names: [url]https://github.com/Chessnut/NSPlugins/blob/master/prone.zip[/url]
Putting it there if anyone else is looking for the name of the animations.
[QUOTE=Exho;46580707]Jesus fucking christ, I figured it out. My function has 'file' as an argument because obviously its going to load a file right? Well using 'file' means that 'file.Read' tries to call the function 'Read' on my string. Basically I am a moron and need to use different variable names[/QUOTE]
[QUOTE=zerf;46579866]Also be careful.
[t]http://i.imgur.com/43oX2mG.png[/t][/QUOTE]
I warned you...
I'm using ENT:Touch() to remove an entity and add money (DarkRP) to a player's wallet. How can I get the player who is gravity gunning the entity? Is there a certain function for this? (Tell me if I need to put this in more depth)
[B]nevermind, found the function[/B]
how to delete player smooth (velocity) movement?
i want no smooth player movement.
i use move function but has no ideas...
help me!
[QUOTE=kjh0105;46583039]how to delete player smooth (velocity) movement?
i want no smooth player movement.
i use move function but has no ideas...
help me![/QUOTE]
sv_stopspeed and sv_accelerate? Setting these to your player's max ground speed should disable movement smoothing
[QUOTE=Crayz;46583446]sv_stopspeed and sv_accelerate? Setting these to your player's max ground speed should disable movement smoothing[/QUOTE]
thank you it's works.
Hmm i was wondering, is ipars faster then pairs?
Trying to squeeze as much performance out of my gamemode as i can soo...
Or is this even faster then both of them:
[lua]
local pl = player.GetAll ();
for i =0, #pl do
If !pl[ i ] || !IsValid ( pl [ i ] ) then continue; end
pl [ i ]:Kill ();
end
[/lua]
Is there a way to tell gmod to unload a dll module? So that I can replace it without it telling me the file is already in use? (Restarting constantly is not fun)
Edit: Never mind, decided to just run a batch file to kill HL2, move files over and start it up again. It works good enough. >_>
I think Acecool made something like that a while back, or maybe it was someone else
How would I make a DTextEntry like a password field with only having the characters visibly not shown as their true characters but keep the data being sent the right characters?
[QUOTE=ROFLBURGER;46581499]I'm still deathly confused on callbacks. Could someone correct my code?
[/QUOTE]
A callback is simply a function which a called function calls with specific arguments to make things easier.
So, for example, hook.Add( name, id, callback ) and concommand.Add( name, callback ) are both instances where a callback is used. For hook.Add, the arguments that are passed to callback vary depending on the name. For concommand.Add the commands are always the same ( Player, string, table ).
Those are basic examples. Things that may be more confusing would be database query callbacks. As the queries take time to execute, it is not a good decision to force the server to wait until the query executes before running other code. So, in the context of database queries, a callback ( depending on which module ) can be for a successful query, or unsuccessful query, etc.. The results can be modified within but instead of returning a value ( you can't return a value in a database query unless you force the server to stop ) we use a callback in the form of a function, or hook.Call, etc.. in order to continue the chain of events for that specific query.
-snip- Didn't realize this post was that long. Here's a link to the full version: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/forum_posts/callbacks.lua.html[/url]
[QUOTE=LUModder;46588121]How would I make a DTextEntry like a password field with only having the characters visibly not shown as their true characters but keep the data being sent the right characters?[/QUOTE]
in DTextEntry.Paint, just draw string.rep('•', #self:GetText()) or self:GetText():gsub('.', '•')
[editline]27th November 2014[/editline]
you could also keep a variable for the real value, and use OnChange to update the variable and replace the actual text with bullets
In what file is the ply:Setrunspeed() and ply:Setgravity() in the sandbox gamemode?
I want to change how fast I run in the gamemode.
Thanks.
edit: got it
[QUOTE=mlgrdm;46590429]In what file is the ply:Setrunspeed() and ply:Setgravity() in the sandbox gamemode?
I want to change how fast I run in the gamemode.
Thanks.[/QUOTE]
This player function placed in base gamemode, If you want change your speed, use console. If you hoster: "lua_run Entity(1):SetRunSpeed(1337) Entity(1):SetGravity(0.5)". Or use special addons.
[vid]http://puu.sh/d8pGI/04f90c9fc6.webm[/vid]
I'm making a car-park script, where when a player locks their car it'll place the car neatly accordingly.
I'm using the onKeysLocked hook, and all is well but for some reason it keeps teleporting the car back to where it was as you can see.
[CODE]hook.Add("onKeysLocked", "CarSnap", function( car )
for k, v in pairs( LeftPark ) do
for _, l in pairs( ents.FindInSphere( v, 30 ) ) do
if car == l then
car:SetPos( v + Vector(0,0,30) )
car:SetAngles( Angle(0,90, 0) )
end
end
end
for k, v in pairs( RightPark ) do
for _, l in pairs( ents.FindInSphere( v, 30 ) ) do
if car == l then
car:SetPos( v + Vector(0,0,30) )
car:SetAngles( Angle(0,-90,0) )
end
end
end
end)[/CODE]
Hi,
I'm trying to figure out how to access a function from outside the file it was declared in.
My situation is this:
In "addon/lua/autorun/server/sv.lua" I have:
[LUA]function GetColor(ent)
return Color(coltbl[ent:EntIndex()].r, coltbl[ent:EntIndex()].g, coltbl[ent:EntIndex()].b)
end[/LUA]
When I try to access it for my STool in "addon/lua/weapons/gmod_tool/stools/tool.lua":
[LUA]function TOOL:LeftClick(trace)
trace.Entity:SetColor(GetColor(trace.Entity))
end[/LUA]
I get
[LUA][ERROR] addons/addon/lua/weapons/gmod_tool/stools/tool.lua:30: attempt to call global 'GetColor' (a nil value)
1. LeftClick - addons/addon/lua/weapons/gmod_tool/stools/tool.lua:30
2. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:254
[/LUA]
Autorun probably runs after the STOOLs are loaded. Try using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/include]Global.include[/url] instead
Hi,
Thanks for the help, I put
[LUA]include([[autorun/server/sv.lua]])[/LUA]
in "addon/lua/weapons/gmod_tool/stools/tool.lua" and it seems as if I can now access the GetColor() function from the STool, but when I try
[LUA]trace.Entity:SetColor(GetColor(trace.Entity))[/LUA]
from inside the STool, GetColor() is returning nil.
[LUA]function GetColor(ent)
return coltbl[ent:EntIndex()]
end[/LUA]
coltbl is being populated by
[LUA]coltbl[ent:EntIndex()] = ent:GetColor()[/LUA]
I am sure that coltbl is being populated correctly, it's not empty.
Thanks so much for the help!
Edit: Another question, when I shoot my STool at anything, I saw that if I did [LUA]return true[/LUA] it would play the unholster animation, but returning false or nothing doesnt shoot the blue toolbeam. How do I get it to make the blue beam effect without it playing the unholster animation? Thanks!
SOLVED
[QUOTE=Minteh Fresh;46590662][vid]http://puu.sh/d8pGI/04f90c9fc6.webm[/vid]
I'm making a car-park script, where when a player locks their car it'll place the car neatly accordingly.
I'm using the onKeysLocked hook, and all is well but for some reason it keeps teleporting the car back to where it was as you can see.
[CODE]hook.Add("onKeysLocked", "CarSnap", function( car )
for k, v in pairs( LeftPark ) do
for _, l in pairs( ents.FindInSphere( v, 30 ) ) do
if car == l then
car:SetPos( v + Vector(0,0,30) )
car:SetAngles( Angle(0,90, 0) )
end
end
end
for k, v in pairs( RightPark ) do
for _, l in pairs( ents.FindInSphere( v, 30 ) ) do
if car == l then
car:SetPos( v + Vector(0,0,30) )
car:SetAngles( Angle(0,-90,0) )
end
end
end
end)[/CODE][/QUOTE]
It's a bug with the game AFAIK. You can't do setpos on cars.
-Solved-
You (or one of your addons) has set Model to a string. Try printing it.
How can I get a tool to display a tooltip/window when I hover over or click on a prop, like when you hover over a thruster? I tried to look at the thruster code, but I don't understand it.
[QUOTE=olivec;46594929]How can I get a tool to display a tooltip/window when I hover over or click on a prop, like when you hover over a thruster? I tried to look at the thruster code, but I don't understand it.[/QUOTE]
If you did something like: local _button = vgui.Create( "DButton", self );
Then, to add a tooltip you'd use: _button:SetTooltip( "This is a tooltip!" );
There is also another function where you can specify a custom tooltip panel instead of the default one.
I'm looking for something like this:
[IMG]http://cloud-2.steampowered.com/ugc/633039646705569841/50BACB65733EC2B2EC07EE627C5F9EF3034F61B0/[/IMG]
but only when I hover over the prop with the tool.
If your entity derives from base_gmodentity, just do:
[code]self:SetOverlayText( "What you want?" )[/code]
If you are using something else as the base, do this:
[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() ) then
AddWorldTip( self:EntIndex(), "What you want?", 0.5, self:GetPos(), self )
halo.Add( { self }, Color( 255, 255, 255, 255 ), 1, 1, 1, true, true )
end
end
[/code]
That's how sandbox does it.
Sorry, you need to Log In to post a reply to this thread.