• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=TrippleT;46201230]hey i have a text screen above my npc but it seems to far to the right and idk how to change the y all i can change is the x [CODE]cam.Start3D2D(ent:GetPos() + ent:GetAngles:Right() * -75, TextAng, 0.2) draw.WordBox(2, -TextWidth*0.5 + 5, -30, text, "HUDNumber5", Color(50, 0, 0, 50), Color(255,255,255,255)) cam.End3D2D()[/CODE][/QUOTE] How the documentation on WordBox says: [lua] draw.WordBox( number bordersize, number x, number y, string text, string font, table boxcolor, table textcolor ) [/lua] So change the third number
[QUOTE=Agent766;46201199]any recommendations for working around this then?[/QUOTE] Depends what you're trying to do I guess.. You could create a function that saves stuff then runs the shutdown command?
Is there a simple session variable serverside that stays the same the whole uptime?
Any code snippets for drawing a rectangle over players on a minimap (renderview)?
How would I go about using a pointshop item to change a weapon's model? I mean: [lua] ITEM.Name = 'Example' ITEM.Price = 1 ITEM.Model = 'models/weapons/examplemodel.mdl' ITEM.WeaponClass = 'weapon_example' ITEM.SingleUse = false function ITEM:OnEquip(ply) ply:StripWeapon('weapon_zm_improvised') ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) -- code that sets the weapon's model to the model set in ITEM.Model end function ITEM:OnHolster(ply) ply:StripWeapon(self.WeaponClass) ply:Give('weapon_zm_improvised') ply:SelectWeapon('weapon_zm_improvised') end [/lua]
[QUOTE=nubskrub;46204088]How would I go about using a pointshop item to change a weapon's model? I mean: [lua] function ITEM:OnEquip(ply,weapon) ply:StripWeapon('weapon_zm_improvised') ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) weapon.WorldModel = "models/weapons/w_weapon.mdl" weapon.ViewModel = "models/weapons/v_weapon.mdl" end [/lua][/QUOTE] Untested. ---- Now for a question: How would I convert a color into a vector because Garry apparently wants to use vectors for his colors
[QUOTE=LUModder;46204378]Untested. ---- Now for a question: How would I convert a color into a vector because Garry apparently wants to use vectors for his colors[/QUOTE] A vector between 0 and 1? Divide by 255
Vector( color.r / 255, color.g / 255, color.b / 255 )
Really dumb math noob question: So I have this XP bar. I have a reqxp (required xp) and xp (xp...). Now what I want to do is make the xp/reqxp be scaled. This is where I have a problem. I've tried +,-,* and / and I can't seem to get it to scale. say I have 200 XP and I require 500. I want it to all be drawn as progress on a 180 pixel (width) area, and I'm using draw.RoundedBox. I can't seem to do it. I know about translating it to a scale of 0/1, but not to a bigger kind of scale. I'm stumped here, it's probably super simple. [editline]edit[/EDITLINE] I assume it's fractions, but I'm also tired... You know how it goes...
math.Clamp( current / max, 0, 1 ) * some_value [code]width = math.Clamp( pl:Xp( ) / pl:NeededXP( ), 0, 1 ) * 180[/code] Pretty straight forward.
[QUOTE=Kogitsune;46204733]math.Clamp( current / max, 0, 1 ) * some_value [code]width = math.Clamp( pl:Xp( ) / pl:NeededXP( ), 0, 1 ) * 180[/code] Pretty straight forward.[/QUOTE] Tried math.Clamp, although I put 1.8 instead of 180... :suicide: Well, it worked, so thanks.
Why does [code] util.Effect( "SMOKE", effectdata) [/code] Always go to the right? Why cant I set the direction with [code] effectdata:SetAngles( Angle (Up)) [/code]
I'm making a basic script which, when a prop is broken, records who broke it and what prop it was. I'm using the PropBreak hook and everything seems to be working fine except PropBreak doesn't get triggered for some props. Why could this be and what could I do to fix it?
[QUOTE=BlackMadd;46205748]Why does [code] util.Effect( "SMOKE", effectdata) [/code] Always go to the right? Why cant I set the direction with [code] effectdata:SetAngles( Angle (Up)) [/code][/QUOTE] Try with [url]http://wiki.garrysmod.com/page/CEffectData/SetNormal[/url] [QUOTE=Sereni;46205763]I'm making a basic script which, when a prop is broken, records who broke it and what prop it was. I'm using the PropBreak hook and everything seems to be working fine except PropBreak doesn't get triggered for some props. Why could this be and what could I do to fix it?[/QUOTE] Not sure, but maybe you can use this hook instead? [url]http://wiki.garrysmod.com/page/GM/EntityTakeDamage[/url] Someone know how can I "reload" a surface? When I use physenv.AddSurfaceData to override an existing surface, it will only work the first time, then if I override again, I must restart gmod (disconnecting from server and reconnecting, isn't enough)... How to avoid having to restart ?
I have this code on server side: [code]if ( SERVER ) then TAUNT_DELAY = 3 //Menu Page 1 //Button1 util.AddNetworkString("send_p1_B1") net.Receive( "send_p1_B1", function( ply ) if SoundDuration(net.ReadString()) + TAUNT_DELAY <= CurTime() then for _,ply in pairs(player.GetAll()) do ply:EmitSound(net.ReadString()) end else print("Wait until the taunt is finished.") end end ) )[/code] Now the client side menu sends a string for the ply.EmitSound() to play, the string is the location of the file. Now I want to limit the players so they won't be able to spam sounds often and will have to wait until the sound finished playing. This code should do it but when I try to call it from the menu, no sound plays nor errors show. Please help.
[QUOTE=VashBaldeus;46206230]I have this code on server side: [code]if ( SERVER ) then TAUNT_DELAY = 3 //Menu Page 1 //Button1 util.AddNetworkString("send_p1_B1") net.Receive( "send_p1_B1", function( ply ) if SoundDuration(net.ReadString()) + TAUNT_DELAY <= CurTime() then for _,ply in pairs(player.GetAll()) do ply:EmitSound(net.ReadString()) end else print("Wait until the taunt is finished.") end end ) )[/code] Now the client side menu sends a string for the ply.EmitSound() to play, the string is the location of the file. Now I want to limit the players so they won't be able to spam sounds often and will have to wait until the sound finished playing. This code should do it but when I try to call it from the menu, no sound plays nor errors show. Please help.[/QUOTE] One problem in your code, is that when you do net.ReadSomething, it will remove it from the queue. In your code, you call it twice because you expect it to return the same thing twice, but it's wrong. You have to store it in a variable. Another problem is that your delay calculation is wrong, CurTime return a time in seconds since server started. So your condition will most likely always be true Do something like this instead: [code] if ( SERVER ) then local TAUNT_DELAY = 3 local lastTauntTime = 0 util.AddNetworkString("send_p1_B1") net.Receive( "send_p1_B1", function( ply ) local sound = net.ReadString() local curTime = CurTime() if curTime - lastTauntTime >= TAUNT_DELAY then lastTauntTime = curTime + SoundDuration( sound ) for _, ply in pairs( player.GetAll() ) do ply:EmitSound( sound ) end else print("Wait until the taunt is finished.") end end ) )[/code] Also the message will be printed in server console, is that really what you want?
[QUOTE=DEFCON1;46206968]One problem in your code, is that when you do net.ReadSomething, it will remove it from the queue. In your code, you call it twice because you expect it to return the same thing twice, but it's wrong. You have to store it in a variable.[/QUOTE] If understood you, you are talking about doing the following: [code]local NewVariable = net.ReadString()[/code] and then using it as much as I want?
Yes look I edited my previous post
[QUOTE=DEFCON1;46207022]Yes look I edited my previous post[/QUOTE] Tried your method, still plays a second one after you play the 1st.
Probably because I made a typing mistake in "TAUNT_DLEAY", no? Copy again it should work
Hey does anybody know how i would implement the Garry's mod logo onto a HUD? Thanks in advance.
-snip-
[QUOTE=DEFCON1;46207068]Probably because I made a typing mistake in "TAUNT_DLEAY", no? Copy again it should work[/QUOTE] I semi-works. But for long taunts which are 5-10 seconds long it allows to play it again in the middle of it. [code] local TAUNT_DELAY = 3 local lastTauntTime = 0 //Menu Page 1 //Button1 util.AddNetworkString("send_p1_B1") net.Receive( "send_p1_B1", function( ply ) local tSound = net.ReadString() local curTime = CurTime() if curTime - lastTauntTime >= TAUNT_DELAY then lastTauntTime = curTime + SoundDuration( tSound ) for _,ply in pairs(player.GetAll()) do ply:EmitSound(tSound) print("Should Play sound") end else print("Wait until the taunt is finished.") end end )[/code]
Couldn't you set the timer to be equal or relative to the taunt's duration? Perhaps using :SequenceDuration() on the player?
[QUOTE=vontiagaming;46207133]Hey does anybody know how i would implement the Garry's mod logo onto a HUD? Thanks in advance.[/QUOTE] [url]http://wiki.garrysmod.com/page/surface/DrawTexturedRect[/url]
[QUOTE=WalkingZombie;46207232]Couldn't you set the timer to be equal or relative to the taunt's duration? Perhaps using :SequenceDuration() on the player?[/QUOTE] Thanks for the idea, though I am having some trouble using ply:SequenceDuration().. gives this: [code] [ERROR] lua/autorun/server/ph_tmenu.lua:9: attempt to index local 'ply' (a number value) 1. func - lua/autorun/server/ph_tmenu.lua:9 2. unknown - lua/includes/modules/net.lua:32 [/code] code: [code]if ( SERVER ) then local TAUNT_DELAY = 1 local lastTauntTime = 0 //Menu Page 1 //Button1 util.AddNetworkString("send_p1_B1") net.Receive( "send_p1_B1", function( ply ) local tSound = net.ReadString() local tString = ply:SequenceDuration(SoundDuration(tSound))// This is the line the error is speaking about. local tLength = ply:SequenceDuration(tString) if tLength >= TAUNT_DELAY then for _,ply in pairs(player.GetAll()) do ply:EmitSound(tSound) print("Should Play sound") end else print("Wait until the taunt is finished.") end end ) end[/code]
The first arg in net.receive's callback is length in bits; second is the player
[QUOTE=zerf;46207606]The first arg in net.receive's callback is length in bits; second is the player[/QUOTE] So if I understood correctly you are talking about: [code]local sLength=ply:SequenceDuration(net.ReadBit())[/code] Which then I compare to the Taunt Delay variable & if the duration is lower than the Taunt Delay then it will play if higher it won't.
I mean you need to change [lua]net.Receive( "send_p1_B1", function( ply )[/lua] to [lua]net.Receive( "send_p1_B1", function( len, ply )[/lua]
What would be the most efficient way to code a double-kill kind of system? Naturally the first candidate would be [b]time[/b]rs, but they activate a function after a certain amount of time, not detect something within a time frame.
Sorry, you need to Log In to post a reply to this thread.