[QUOTE=Bandit Kitteh;38844892]How can I change the voice chat indicator's color based on teams?
Currently the default looks like this when somebody is talking
[img]http://puu.sh/1Bl0P[/img][/QUOTE]
Take a look at this file: [url]http://glua.me/bin/?path=/gamemodes/base/gamemode/cl_voice.lua[/url]
[QUOTE=Stiveno;38836086]I cant seem to get my code to spawn entities automatically working correctly. For some reason, it spawns all the entities twice in the same spot. Any ideas?
[URL="http://pastebin.com/n3SWuakr"]sv_entstartup.lua[/URL]
[URL="http://pastebin.com/yk61SX8s"]Map file[/URL][/QUOTE]
Anybody have a clue?
I have a hud in my Lua/autorun folder and I need to include in it files from just the lua folder, how do I do it without creating lua errors?
[QUOTE=vegasx;38846072]I have a hud in my Lua/autorun folder and I need to include in it files from just the lua folder, how do I do it without creating lua errors?[/QUOTE]
You can go 'up' a directory with ../
For example:
folder_one/folder_two/../ is the same as folder_one/
That means you'd have to do ../file.lua
[QUOTE=Darkwater124;38846154]You can go 'up' a directory with ../
For example:
folder_one/folder_two/../ is the same as folder_one/
That means you'd have to do ../file.lua[/QUOTE]
I don't think you've ever had to do that with include,. Only with file operations and that was removed probably close to a year ago.
[QUOTE=Darkwater124;38846154]You can go 'up' a directory with ../
For example:
folder_one/folder_two/../ is the same as folder_one/
That means you'd have to do ../file.lua[/QUOTE]
So
include("garrysmod/lua/gf_shared.lua")?
I was wondering how to add extra tabs and also remove tabs similar to the ones here:
[img]http://gyazo.com/8827a73bafa697f206744bc594801a39.png?1355633897[/img]
For example a Rules tab where theres a list of basic rules and a Donator tab that has donator entities?
1. open the file the menu is coded in.
2. ctrl f and search for "AddSheet"
3. delete the line that has the tab you don't want
if you want to add tabs you do it the same way as the other ones, but you have to make a panel to parent to the tab.
you can learn about vgui basics here:
[URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexe102.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexe102.html[/URL]
also, here's a page for painting the vgui:
[URL="http://wiki.garrysmod.com/page/surface"]http://wiki.garrysmod.com/page/surface[/URL]
-snip-
[editline]16th December 2012[/editline]
Why in hell can't I find any documentation on NPC scripting? The only thing I could find is the shitty tutorial in the old wiki.
I keep coming up with the same error from this armor regeneration script,
[CODE][ERROR] lua/autorun/armorregen.lua:28: attempt to call method 'SetArmor' (a nil value)
[/CODE]
I've tried a wide variety of different things, any help?
Script that causes the error:
[CODE]local function Think()
local enabled = GetConVarNumber( "armorregen_enabled" ) > 0
local speed = 1 / GetConVarNumber( "armorregen_speed" )
local max = GetConVarNumber( "armorregen_maxarmor" )
local time = FrameTime()
for _, ply in pairs( player.GetAll() ) do
if ( ply:Alive() ) then
local armor = ply:Armor()
if ( armor < ( ply.LastArmor or 0 ) ) then
ply.ArmorRegenNext = CurTime() + GetConVarNumber( "armorregen_delay" )
end
if ( CurTime() > ( ply.ArmorRegenNext or 0 ) && enabled ) then
ply.ArmorRegen = ( ply.ArmorRegen or 0 ) + time
if ( ply.ArmorRegen >= speed ) then
local add = math.floor( ply.ArmorRegen / speed )
ply.ArmorRegen = ply.ArmorRegen - ( add * speed )
if ( armor < max || speed < 0 ) then
ply:SetArmor(ply:Armor() + add, max)
end
end
end
ply.LastArmor = ply:Armor()
end
end
end
hook.Add( "Think", "ArmorRegen.Think", Think )[/CODE]
Allright I need help with a idea,
I have a list of 5 player models, and I want to make it so when a player joins the team math.random will just randomly choose one of the 5 player models but I am a bit confused on how to do it soo Help please :D
[QUOTE=Par3210;38839825]How do I make a console command in init.lua that changes the value of a local variable in cl_init.lua? (I am a beginner LUA coder, so sorry if this is a n00b question)[/QUOTE]
Could anyone help me with this question? Still not answered fully
@Above do something like this (might be wrong because i wrote it off the top of my head
[CODE]local Random = math.random(1,5)
ply.SetTeam(Random)
if Random == 1 then
(do the first model set here)
elseif Random == 2 then
[U]... and so on[/U]
[/CODE]
Probrably a horrible way of doing it but it works.
[QUOTE=vegasx;38849158]I keep coming up with the same error from this armor regeneration script,
[CODE][ERROR] lua/autorun/armorregen.lua:28: attempt to call method 'SetArmor' (a nil value)
[/CODE]
I've tried a wide variety of different things, any help?
Script that causes the error:
[CODE]local function Think()
local enabled = GetConVarNumber( "armorregen_enabled" ) > 0
local speed = 1 / GetConVarNumber( "armorregen_speed" )
local max = GetConVarNumber( "armorregen_maxarmor" )
local time = FrameTime()
for _, ply in pairs( player.GetAll() ) do
if ( ply:Alive() ) then
local armor = ply:Armor()
if ( armor < ( ply.LastArmor or 0 ) ) then
ply.ArmorRegenNext = CurTime() + GetConVarNumber( "armorregen_delay" )
end
if ( CurTime() > ( ply.ArmorRegenNext or 0 ) && enabled ) then
ply.ArmorRegen = ( ply.ArmorRegen or 0 ) + time
if ( ply.ArmorRegen >= speed ) then
local add = math.floor( ply.ArmorRegen / speed )
ply.ArmorRegen = ply.ArmorRegen - ( add * speed )
if ( armor < max || speed < 0 ) then
ply:SetArmor(ply:Armor() + add, max)
end
end
end
ply.LastArmor = ply:Armor()
end
end
end
hook.Add( "Think", "ArmorRegen.Think", Think )[/CODE][/QUOTE]
Call it server side i'm guessing it's trying to call it clientside, lua/autorun/server/armorregen.lua
[QUOTE=Par3210;38849942]Could anyone help me with this question? Still not answered fully
@Above do something like this (might be wrong because i wrote it off the top of my head
[CODE]local Random = math.random(1,5)
ply.SetTeam(Random)
if Random == 1 then
(do the first model set here)
elseif Random == 2 then
[U]... and so on[/U]
[/CODE]
Probrably a horrible way of doing it but it works.[/QUOTE]
[QUOTE=Gmremie;38849432]Allright I need help with a idea,
I have a list of 5 player models, and I want to make it so when a player joins the team math.random will just randomly choose one of the 5 player models but I am a bit confused on how to do it soo Help please :D[/QUOTE]
[lua]local ModelList = { "path/to/model1.mdl", "path/to/model2.mdl", "path/to/model3.mdl", "path/to/model4.mdl", "path/to/model5.mdl" }[/lua]
Then where you want to actually set the model..
[lua]Player:SetModel( table.Random( ModelList ) )[/lua]
.. 2 birds.. 1 stone.. Done.
[lua] if CLIENT then
concommand.add("Donate",function(pl, cmd, args)
local Frame = vgui.Create("DFrame")
Frame:SetSize(ScrW() - 20, ScrH() - 20)
Frame:Center()
Frame:SetTitle("Donate")
Frame:MakePopup()
Frame:SetMouseInputEnabled(true)
local html = vgui.Create("DHTML", Frame)
html:SetPos(5,25)
html:SetSize(ScrW() - 30, ScrH() - 30)
html:OpenURL("http://forum.ammgaming.com/index.php?page=Donate")
end)
end
if SERVER then
hook.Add("PlayerSay", "ChatHook", function(Player, Text, Public)
if Text[1] == "!" then
Text = Text:lower()
if Text == "!donate" then
Player:ConCommand("Donate")
return ""
end
end
end)
end
[/lua]
Getting the error
[ERROR] lua/autorun/donate.lua:20: '=' expected near 'Text'
1. unknown - lua/autorun/donate.lua:0
can some1 please tell me what im doing wrong?
[code]
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
[/code]
Anyone have any idea what this means?
[QUOTE=Drakehawke;38851688][code]
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
Bad sequence (11 out of 9 max) in GetSequenceLinearMotion() for model 'Weapons/v_crowbar.mdl'!
[/code]
Anyone have any idea what this means?[/QUOTE]
[url]http://forums.eventscripts.com/viewtopic.php?p=226493[/url] Skin error probably
-snip-
I'm trying to write an xp system.
I'm using the net library and I'm wondering how I should use net.WriteUInt().
I'm learning c++ and I know an unsigned int has more range than the default int range. However, the second argument for net.WriteUInt() requires the size of the message.
How would i find the size of the message?
Hello, Could anyone please help me add ranks to TTT scoreboard?
Kind Regards.
This'll sound a bit stupid, but how can I replace the default sounds for a weapon with custom sounds (ex. A hexed mp5 swep has a custom deploy sound, but always uses the default sound)? the most likely way to do it would be scripts, but either they don't work or I don't know how to use them. Anyone have any ideas?
[B]edit:[/B]
Nevermind. I found out you can use net.BytesWritten() to automate the size of the message, however I apparently can't use that to read the int, which for some reason also requires the message's size (bits). Any ideas?
Anyways, here's my code if anyone can point out what I'm doing wrong..
SERVER:
[lua]
util.AddNetworkString("addXP")
local Player = FindMetaTable("Player")
function Player:AddXP( int )
if !self.XP then self.XP = 0 end
self.XP = self.XP + int
net.Start( "addXP" )
net.WriteInt( int, net.BytesWritten() )
print(self:Nick().." --> "..int.." | "..net.BytesWritten())
net.Send( self )
end
[/lua]
CLIENT:
[lua]
if (CLIENT) then
net.Receive("addXP", function (length, client)
local int = net.ReadInt()
local ply = LocalPlayer()
print(ply:Nick().." <-- "..int.." | "..net.BytesWritten())
if !ply.XP then ply.XP = 0 end
ply.XP = ply.XP + int
end)
end
[/lua]
Lastly here's how I've been calling it
SERVER:
[lua]
ply:AddXP(30)
[/lua]
I'm still a little skeptical of using net.BytesWritten() am i using that correctly also? I read the page on using the net library on the wiki, but they never demonstrated how to write and read ints/uints.
[editline]16th December 2012[/editline]
the error I'm getting says
[lua] gamemodes/xxxxxxxx/gamemode/sh_xp.lua:52: bad argument #1 to 'ReadInt' (number expected, got no value)[/lua]
which is the line that says local int = net.ReadInt()
[QUOTE=M0dSe7en;38854822]*stuff*[/QUOTE]
Write/ReadInt doesn't take the size of the entire message. I suggest you take a look here: [url]http://wiki.garrysmod.com/page/Libraries/net/WriteInt[/url]
Is there a way of clipping textures on surface.DrawRect?
So I could just draw the bottom half of my image.
[QUOTE=ollie;38857400]Is there a way of clipping textures on surface.DrawRect?
So I could just draw the bottom half of my image.[/QUOTE]
[url]http://wiki.garrysmod.com/page/Libraries/surface/DrawTexturedRectUV[/url]
[editline]16th December 2012[/editline]
Last four arguments
Problem solved, move along.
[QUOTE=M0dSe7en;38854822]Any ideas?[/QUOTE]
You need to specify the amount of bits to use in Int and UInt. For example, net.WriteInt(xp, 8) would write an integer that's valid between -127 and 127. If you used a UInt (unsigned) then it would be 0 - 255. If you used 16 bits then you could get from 0 - 65535 in an unsigned integer (which is what it looks like you want since you can't have negative XP). If you use 32 bits you shouldn't ever have a problem with overflow.
signed:
net.WriteInt(data, numbits)
net.ReadInt(numbits)
unsigned:
net.WriteUInt(data, numbits)
net.ReadUInt(numbits)
This should help choosing: [url]http://en.wikipedia.org/wiki/Integer_(computer_science)[/url]
[QUOTE=JetBoom;38858992]This should help choosing: [url]http://en.wikipedia.org/wiki/Integer_(computer_science)[/url][/QUOTE]
Thanks, that really helped.
Does anyone know if any of the new Derma controls allow for laying out panels in a row? I would use DPanelList, but as it's effectively deprecated I'd rather not use it (or I can just make my own solution, but figured it's worth asking first).
[editline]17th December 2012[/editline]
Whoops, should mention I've looked into DLineLayout, however the file containing the information for this element seems to be missing from my install and there's no wiki documentation on it.
[editline]17th December 2012[/editline]
Seems DIconLayout is what I'm after.
How can I freeze the gameplay clientside for a few seconds? Is that possible?
Sorry, you need to Log In to post a reply to this thread.