[QUOTE=skullorz;36639656]Is there any way to draw tilted text on the screen? Say, a health bar that is angled like /.[/QUOTE]
[lua]
local sSetTextPos = surface.SetTextPos;
local sDrawText = surface.DrawText;
local cPushModelMatrix = cam.PushModelMatrix;
local cPopModelMatrix = cam.PopModelMatrix;
local mat = Matrix();
local matAng = Angle(0, 0, 0);
local matTrans = Vector(0, 0, 0);
local matScale = Vector(0, 0, 0);
local function drawSpecialText(txt, posX, posY, scaleX, scaleY, ang)
matAng.y = ang;
mat:SetAngle(matAng);
matTrans.x = posX;
matTrans.y = posY;
mat:SetTranslation(matTrans);
matScale.x = scaleX;
matScale.y = scaleY;
mat:Scale(matScale);
sSetTextPos(0, 0);
cPushModelMatrix(mat);
sDrawText(txt);
cPopModelMatrix();
end
hook.Add("HUDPaint","RotatedTextTest", function()
surface.SetTextColor(255, 0, 0, 255);
surface.SetFont("HUDNumber5");
drawSpecialText("TEST", 150, 150, 1, 1, RealTime()*128)
surface.SetDrawColor(255, 0, 0, 255);
surface.DrawRect(150, 150, 2, 2);
end);
[/lua]
[QUOTE=Wizard of Ass;36639959][lua]
local sSetTextPos = surface.SetTextPos;
local sDrawText = surface.DrawText;
local cPushModelMatrix = cam.PushModelMatrix;
local cPopModelMatrix = cam.PopModelMatrix;
local mat = Matrix();
local matAng = Angle(0, 0, 0);
local matTrans = Vector(0, 0, 0);
local matScale = Vector(0, 0, 0);
local function drawSpecialText(txt, posX, posY, scaleX, scaleY, ang)
matAng.y = ang;
mat:SetAngle(matAng);
matTrans.x = posX;
matTrans.y = posY;
mat:SetTranslation(matTrans);
matScale.x = scaleX;
matScale.y = scaleY;
mat:Scale(matScale);
sSetTextPos(0, 0);
cPushModelMatrix(mat);
sDrawText(txt);
cPopModelMatrix();
end
hook.Add("HUDPaint","RotatedTextTest", function()
surface.SetTextColor(255, 0, 0, 255);
surface.SetFont("HUDNumber5");
drawSpecialText("TEST", 150, 150, 1, 1, RealTime()*128)
surface.SetDrawColor(255, 0, 0, 255);
surface.DrawRect(150, 150, 2, 2);
end);
[/lua][/QUOTE]
I'll see how it goes, thanks.
[lua]
if t ~= TEAM_POLICE and t ~= TEAM_CHIEF then
local Police = "models/tdmcars/hsvw247_pol.mdl"
for _, Value in pairs( Police ) do
if string.find( Model, Value ) then
Value:Remove
end
end
end
[/lua]
Can't make it remove the model on job change, I've also tried
[lua]
if t ~= TEAM_POLICE and t ~= TEAM_CHIEF then
local Police = "models/tdmcars/hsvw247_pol.mdl"
for _, v in pairs( Police ) do
if string.find( Model, v ) then
v:Remove
end
end
end
[/lua]
Why are you trying to loop through a string?
I think you mean:
[lua]
local Police = { "models/tdmcars/hsvw247_pol.mdl" }
[/lua]
[QUOTE=Drakehawke;36649608]Why are you trying to loop through a string?
I think you mean:
[lua]
local Police = { "models/tdmcars/hsvw247_pol.mdl" }
[/lua][/QUOTE]
Didn't think of that and still doesn't work.
[lua]
if t ~= TEAM_POLICE and t ~= TEAM_CHIEF then
local Police = { "models/tdmcars/hsvw247_pol.mdl" }
for k, v in pairs( Police ) do
if string.find( Model, v ) then
v:Remove
end
end
end
[/lua]
Where is Model defined?
v:Remove needs brackets after it (v:Remove())
v is a string in this case, so calling Remove on it will error. You can't remove a model, you have to change the players model to a different one.
v:SetModel("model/you/want/instead.mdl")
Well we are trying to make it so when you leave your job your car will go away.
How would i go about auto including files in the game mode folder on garrys mod 13.
e.g. I would have gamemode/sh_modules/ and all files in it would be included and AddCSLuaFile inside of the shared file.
Thanks
[QUOTE=Jamies;36650889]How would i go about auto including files in the game mode folder on garrys mod 13.
e.g. I would have gamemode/sh_modules/ and all files in it would be included and AddCSLuaFile inside of the shared file.
Thanks[/QUOTE]
[lua]
for k,v in pairs(file.Find("GM_FOLDER/gamemode/sh_modules/*.lua", LUA_PATH)) do
if SERVER then
AddCSLuaFile("GM_FOLDER/gamemode/sh_modules/"..v)
end
include("GM_FOLDER/gamemode/sh_modules/"..v)
end
[/lua]
Not tested, but should work fine.
Hello, my server recently opened up a online radio, i was wondering is there any way i could make it stream directly into the gmod server to a radio entity ?
So I'm trying to replace the HL2 grenade with a bird
[img]http://puu.sh/GosL[/img]
DONT ASK QUESTIONS JUST GET IN THE VAN! THERE'S NO TIME!
Anyway, I'm setting its position to the position of the grenade's bone BEFORE i move said bone, yet for some reason it's reading much farther forward than it should. The bone SHOULD be in the middle of the fingers, like where the grenade SHOULD be, not farther past the fingers.
Not only is the position of but no matter what hook I put this in the bird ALWAYS draws AFTER the viewmodel. Anyone have any ideas?
Le code:
[lua]
local gone_forever = Vector( -4096, -8192, 8192 )
SWEP.BonesToHide = { "ValveBiped.Grenade_body",
"ValveBiped.Pin"}
function SWEP:HideNade( vm )
local bone, matrix, k, v, oPos, oAng
vm:SetupBones( )
oPos, oAng = vm:GetBonePosition(vm:LookupBone("ValveBiped.Grenade_body"))
for k, v in ipairs( self.BonesToHide ) do
bone = vm:LookupBone( v )
if bone and bone > 0 then
matrix = vm:GetBoneMatrix( bone )
if matrix then
matrix:Translate( gone_forever * 10 )
vm:SetBoneMatrix( bone, matrix )
end
end
end
if self.BirdMod and ValidEntity(self.BirdMod) then
oAng:RotateAroundAxis(oAng:Up(), 270)
oAng:RotateAroundAxis(oAng:Forward(), 180)
oAng:RotateAroundAxis(oAng:Right(), 45)
self.BirdMod:SetPos(oPos)
self.BirdMod:SetAngles(oAng)
end
end
function SWEP:PostDrawTranslucentRenderables( )
self:HideNade( self.Owner:GetViewModel( ) )
end
local function PostDrawTranslucentRenderables( )
local pl = LocalPlayer( )
if not pl:IsValid( ) then return end
local wep = pl:GetActiveWeapon( )
if not wep:IsValid( ) then return end
if not wep.PostDrawTranslucentRenderables then return end
wep:PostDrawTranslucentRenderables( )
end
hook.Add( "PostDrawTranslucentRenderables", "SetupBirdNade", PostDrawTranslucentRenderables )
[/lua]
I'm thinking of hosting my own dedicated server, and I've got it working, but entity physics for things likee RPG rockets and grenades dont work, they just float and eventually disappear. Same with sweps.
[QUOTE=a1steaksa;36654736]I'm thinking of hosting my own dedicated server, and I've got it working, but entity physics for things likee RPG rockets and grenades dont work, they just float and eventually disappear. Same with sweps.[/QUOTE]
What operating system are you hosting the server on? I don't think that should really matter though. Make sure that you've downloaded all the required content and followed the guide you used properly, or if you didn't use a guide, just use one.
Is there anyway to freeze the animation of a viewmodel, just wondering.
Fixed my previous problem, but now I have a new one.
Is there anyway to get CLuaParticle's to be lit probably with the light in the map?
Any shader I use on the material for them either flickers, doesnt work, or is always fully lit.
[QUOTE=connorclockwise;36665358]Is there anyway to freeze the animation of a viewmodel, just wondering.[/QUOTE]
vm:SetPlaybackRate( 0 ) perhaps
[QUOTE=Feihc;36666524]
Any shader I use on the material for them either flickers, doesnt work, or is always fully lit.[/QUOTE]
I had this problem for custom vgui .vtfs, try using UnlitGeneric.
[editline]8th July 2012[/editline]
[QUOTE=Kogitsune;36666850]vm:SetPlaybackRate( 0 ) perhaps[/QUOTE]
I did give that a shot, I'll try it again, but last time I remember it didn't not work quite right.
Is there a way to translate the surface drawing origin, like in Panel:Paint() where 0,0 represents the top-left of the panel?
edit: Nevermind, Found it. Just need to add render.SetViewPort(x, y, w, h)
[QUOTE=connorclockwise;36669572]I had this problem for custom vgui .vtfs, try using UnlitGeneric.
[/QUOTE]
I am using UnlitGeneric - that's the problem, they're UNLIT - they're always at full brightness. I want the particles to obey lighting.
I am curious how DTVars work - do they work the same as usermessages?
For an item type ID, would it be more optimized to have a table of entity indexes with IDs sent via usermessages, or would it be more optimized to use a DTVar on the entity storing the ID?
Is it bad if you use a lot of metatables, player metatable to be specific? I have a feeling it's extremely inefficient but I'm not too sure.
[QUOTE=jackool;36672596]I am curious how DTVars work - do they work the same as usermessages?
For an item type ID, would it be more optimized to have a table of entity indexes with IDs sent via usermessages, or would it be more optimized to use a DTVar on the entity storing the ID?[/QUOTE]
It's part of the entity's data frame / save table and is networked automagically by the engine.
At the [b][url=wiki.garrysmod.com/?title=Gamemode.PlayerCanHearPlayersVoice]Gamemode.PlayerCanHearPlayersVoice [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b], what is the difference between the first return and the second one?
I've been trying to spot a difference, but I failed, and both wiki and glua.me do not show what one is and what the other is.
I'm trying to make a gamemode for Garry's Mod 13, and when I load a map, I get this:
[QUOTE]Error loading gamemode: !IsValidGamemode[bitlmatch][/QUOTE]
How do I fix this?
EDIT: Never mind.
I'd really need some help with [URL="http://www.facepunch.com/showthread.php?t=1195316&p=36608680#post36608680"]thisone[/URL]. :(
[QUOTE=Kogitsune;36675471]It's part of the entity's data frame / save table and is networked automagically by the engine.[/QUOTE]
So I assume DTVars would be more optimized? You didn't exactly answer my question, heh.
[QUOTE=jackool;36686538]So I assume DTVars would be more optimized? You didn't exactly answer my question, heh.[/QUOTE]
Yeah
HL2:RP isn't showing the /textadd text.
What do I do? Tried everything
How do I make properties of an entity persist through a duplication?
Here's how the material tool does it:
[lua]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 )[/lua]
Here's what I'm doing:
[lua]local function SetStuff( Player, Entity, Data )
print("test")
if Data.apple then
Entity.apple = Data.apple
end
duplicator.StoreEntityModifier(Entity,"stuff",Data)
end
duplicator.RegisterEntityModifier("stuff", SetStuff)[/lua]
The print never runs. What am I not doing, or doing wrong?
Nevermind, I didn't realize that I had to put the variables onto the entities from within the function, rather than at any time.
Sorry, you need to Log In to post a reply to this thread.