How do I freeze an entity like the Physics Gun can?
All I found is this function, which only works on players;
[code]Player:Freeze( state )[/code]
Thanks in advance <3
[QUOTE=Yonnick19;37883530]How do I freeze an entity like the Physics Gun can?
All I found is this function, which only works on players;
[code]Player:Freeze( state )[/code]
Thanks in advance <3[/QUOTE]
ent:GetPhysicsObject():EnableMotion(bool)
[QUOTE=vexx21322;37883568]ent:GetPhysicsObject():EnableMotion(bool)[/QUOTE]
Wow, thanks for the fast reply, it works perfectly! :3
Speaking of not finding functions, I made this bookmarklet to help me search with the old, mirrored wiki.
javascript:(function(){var p=prompt("Maurits search:","");if(p){var win=window.open();win.document.location=encodeURI("https://www.google.com/search?num=20&q=site:maurits.tv "+p)}})()
I can't link it because the forum keeps adding http:// to the beginning.
What's wrong with the search inside the old wiki?
[QUOTE=Bletotum;37885525]What's wrong with the search inside the old wiki?[/QUOTE]
Doesn't work for me, and this is faster.
In GM13 I'm trying to use include() and AddCSLuaFile() from inside a function, but the file cannot be found. The file I'm trying to use is inside a folder relative to the file trying to access it. I am able to include it if I try from outside a function.
Is it possible to do it from inside a function?
[quote="Ziks;37887838"]In GM13 I'm trying to use include() and AddCSLuaFile() from inside a function, but the file cannot be found. The file I'm trying to use is inside a folder relative to the file trying to access it. I am able to include it if I try from outside a function.
Is it possible to do it from inside a function?[/quote]
If your function uses include() or AddCSLuaFile(), it'll add files with a path relative to where you actually [i]call[/i] the function, not where it's defined.
Assuming I'm not just repeating what you already know, and the function's legitimately broken.
In my gamemode, I want a player that dies while in team 2 to be moved to team 1.
I have set up the teams correctly, just unsure how to move teams on death.
Thanks.
[QUOTE=nick_9_8;37888997]In my gamemode, I want a player that dies while in team 2 to be moved to team 1.
I have set up the teams correctly, just unsure how to move teams on death.
Thanks.[/QUOTE]
[lua]function GM:PlayerDeath(ply, weapon, killer)
-- PARTY IN TEAM 1
-- AND EVERYONE'S INVITED
ply:SetTeam(1);
end[/lua]
Alternatively, if for whatever reason you need him to stay on team 2 until he respawns:
[lua]function GM:PlayerSpawn(ply)
-- Are we doing a team switch?
if (ply.SwitchToTeam)
ply:SetTeam(ply.SwitchToTeam);
ply.SwitchToTeam = nil;
end
end
function GM:PlayerDeath(ply, weapon, killer)
-- Set his team to switch to on respawn
if (ply:Team() == 2) then
ply.SwitchToTeam = 1;
end
end[/lua]
[QUOTE=nick_9_8;37888997]In my gamemode, I want a player that dies while in team 2 to be moved to team 1.
I have set up the teams correctly, just unsure how to move teams on death.
Thanks.[/QUOTE]
[code]function GM:DoPlayerDeath( ply, attacker, dmginfo )
if ply:Team() == 2 then
ply:SetTeam( 1 )
end
end[/code]
Would something like this work?
EDIT: Ninja'd by post above me, and explained better there.
How do I make it so when I kill a NPC using Entity:TakeDamageInfo(dmginfo) it body flys in a specified direction instead of just falling down or in the direction it was going?
Eg, if I kill a fast zombie while its jumping at me I want it to stop flying at me or atleast show that it was hit by a powerful shot?
Here is a video showing what I don't want happening:
[vid]http://puu.sh/1aT6c[/vid]
[editline]2nd October 2012[/editline]
Also, I'm getting a crash when creating an effect on the server in a entity and I have no idea whats causing it.
It used to be created clientside but since the entity is created in PrimaryFire of a SWEP its not being called on the client.
Change the direction of NPC velocity before actually killing it?
IIRC I think TTT takes the direction/velocity etc of a player as they die, then creates a ragdoll and applies the forces to that.
*EDIT*
Also I'm pretty awful at GUI stuff and I'd like to practice more, what would be the most effective way to quickly change and reload a GUI in say, GM13? Have the test GUI draw straight to the screen and bind something to reloading the file?
Having a little issue with my effect in GMod 13.
[lua]
local tMats = {}
tMats.Glow1 = Material("sprites/light_glow02")
tMats.Glow2 = Material("sprites/flare1")
for _,mat in pairs(tMats) do
mat:SetMaterialInt("$spriterendermode",9)
mat:SetMaterialInt("$ignorez",1)
mat:SetMaterialInt("$illumfactor",8)
end
[/lua]
Whenever i spawn on my server, i get this error:
[code]
[gamemodes/testgm/entities/effects/car_explode/init.lua:8] attempt to call method 'SetMaterialInt' (a nil value).
From this i would understand that this is something that has been changed in GMod 13, as it works perfectly fine in GMod 12. Can anyone enlighten me what i'm doing wrong here? Thank you.
The IMaterial functions had their Material part removed from their function's names, e.g. from "SetMaterialInt" to "SetInt".
I'm trying to check the position of all players in the server to see if they're in the "hill" radius (like a King of the Hill gamemode)
I realise "ply:EyePos() == ply:EyePos()" should always be true, this is just to try things out.
The problem I'm having though is that it somehow returns "ply" as a nil value, even though I thought it couldn't be... Could anybody point out what I did wrong?
Thanks in advance :3
[code]function GM:Think( ply )
if ply:EyePos() == ply:EyePos() then
PrintMessage( HUD_PRINTTALK , "You're in the Hill Radius bro!" )
end
end[/code]
Error: [gamemodes\pewpew\gamemode\init.lua:12] attempt to index local 'ply' (a nil value)(Hook: Think)
[QUOTE=Yonnick19;37896984]I'm trying to check the position of all players in the server to see if they're in the "hill" radius (like a King of the Hill gamemode)
I realise "ply:EyePos() == ply:EyePos()" should always be true, this is just to try things out.
The problem I'm having though is that it somehow returns "ply" as a nil value, even though I thought it couldn't be... Could anybody point out what I did wrong?
Thanks in advance :3
[code]function GM:Think( ply )
if ply:EyePos() == ply:EyePos() then
PrintMessage( HUD_PRINTTALK , "You're in the Hill Radius bro!" )
end
end[/code]
Error: [gamemodes\pewpew\gamemode\init.lua:12] attempt to index local 'ply' (a nil value)(Hook: Think)[/QUOTE]
Think doesn't have arguments.
[QUOTE=vexx21322;37897086]Think doesn't have arguments.[/QUOTE]
Even without it gives almost the same error:
[gamemodes\pewpew\gamemode\init.lua:13] attempt to index global 'ply' (a nil value)(Hook: Think)
EDIT: Getting "Dumb" ratings for being new to LUA and asking questions, sure makes me feel welcome here... >_>
ofcourse it will, because ply doesnt exist.
best bet is to loop through like:
[lua]
function GM:Think()
for _, ply in pairs(player.GetHumans()) do
// ply exists now :D
if (true) then
// also ply:EyePos() will always equal itself
// so if (true) will do the same thing
PrintMessage( HUD_PRINTTALK , "You're in the Hill Radius bro!" )
end
end
end
[/lua]
but remove the ply from Think(ply)
shit sorry i forgot that
edited :D
[QUOTE=G4MB!T;37897250]ofcourse it will, because ply doesnt exist.
best bet is to loop through like:
[lua]
function GM:Think()
for _, ply in pairs(player.GetHumans()) do
// ply exists now :D
if (true) then
// also ply:EyePos() will always equal itself
// so if (true) will do the same thing
PrintMessage( HUD_PRINTTALK , "You're in the Hill Radius bro!" )
end
end
end
[/lua][/QUOTE]
Thanks for solving the issue I was having, it works great! <3
glad i could help :P
if you have any other questions just add me on steam ill be happy to help out :)
Anyone know why I'm getting this error in GMOD13?
[lua][lua/autorun/client/dlisttest.lua:2] attempt to index local 'DermaPanel' (a nil value)[/lua]
[lua]local DermaPanel = vgui.Create( "DFrame" ) // Create the frame in a local variable
DermaPanel:SetPos( 100, 100 ) // Set the position to 100, 100 ( x, y )
DermaPanel:SetSize( 300, 200 ) // Set the size to 300, 200 pixels
DermaPanel:SetTitle( "Player Information Ticker" ) // Set the title
DermaPanel:SetVisible( true ) // Can you see it? ( Optional - default true )
DermaPanel:SetDraggable( true ) // Can you move/drag it? ( optional - default true )
DermaPanel:ShowCloseButton( true ) // Can you see the close button ( reccomended ) ( optional - default true )
DermaPanel:MakePopup() // Make it popup[/lua]
quick question: how do I init key values for an entity (custom), set them, and get them?
[QUOTE=Kidd;37898832]Anyone know why I'm getting this error in GMOD13?[/QUOTE]
remove the local. not the best fix or idea for that matter but it will work
[QUOTE=M0dSe7en;37899211]quick question: how do I init key values for an entity (custom), set them, and get them?[/QUOTE]
_R.Entity:SetKeyValue(strKey, value);
[QUOTE=G4MB!T;37899349]remove the local. not the best fix or idea for that matter but it will work
[/QUOTE]
Unfortunately that doesn't work. It just tells me the error is global 'DermaPanel' instead of local.
i did this up in the console
[code]
] lua_run_cl pnl = vgui.Create( "DFrame" )
] lua_run_cl print(pnl)
Panel: [name:EditablePanel][class:LuaEditablePanel][0,0,64,24]
[/code]
so it works.
could you show us more of your code?
That is the code. lol
Sorry, you need to Log In to post a reply to this thread.