[QUOTE=droidekafan;39305594]Is there any way that I could get this code to remove the entity 5 seconds after the original countdown has finished?:
[CODE]if ignite then
v:Ignite( 10, 10 )
timer.Simple( 9, function() if v:IsValid() then v:SetMaterial( "models/props_debris/plasterwall009d.vmt" ) end end )
end[/CODE][/QUOTE]
After creating your timer, do this:
SafeRemoveEntityDelayed( v, 14 )
So it'd be removed 5 seconds later.
How does one use SKIN:PaintFrame without getting errors? Not sure how it works and apparently all the SKIN hooks are null on the maurites.tv thingo.
[QUOTE=Kogitsune;39306845]After creating your timer, do this:
SafeRemoveEntityDelayed( v, 14 )
So it'd be removed 5 seconds later.[/QUOTE]
Many thanks, it works perfectly :)
[B]PEOPLE, I NEED HELP![/B]
How can I allow certain steam ids in a txt file be able to have access to donator privelages, without being in the donator group? (Because some admins on the server i work on are donators and some are not)
I made a txt file in the data folder, so in game I could add steam ids to it using a derma menu and the file.Write function. I just need to know how a Lua file can read that txt file (using file.read) and then give those steam ids permissions.
Perhaps I could make a ulx donator group which nobody is in, and then let the steam ids inherit from that (but let them still be in anotherulx group in game)
Another method could be this method:
[lua] local a = CTeam.admin
if a > 0 and not ply:IsAdmin()
or a > 1 and not ply:IsSuperAdmin()
or a > 3 and not ply:SteamID() == file.read("file.txt")
then
Notify(ply, 1, 4, string.format(LANGUAGE.need_admin, CTeam.name))
return ""
end
[/lua]
Would this even work?
[QUOTE=xjokerx9;39306270]I am trying to make a script that takes the damage you do to an entity and gives it back to you. Here is what I have I right now and it is probably off by a lot, but if someone could help me that would be great!
init
[lua]
util.AddNetworkString( "LifeStealer" )
net.Start("LifeSteal")
net.Receive( "LifeStealer", function( len, ply )
local life = ( net.ReadUInt( 2 ) )
local health = LocalPlayer():Health()
health = health + life
end)
[/lua]
Right now I am getting an error for [B]calling net.Start with unpooled message name[/B], but I am calling [B]util.AddNetworkString( "LifeStealer" )[/B] at the beginning of my init file.[/QUOTE]
It's because LifeStealer and LifeSteal are two different network strings.
Anyone know a good tutorial for vehicles? (Specifically flyable) I don't think their are many tutorials (at least that I can find). I know it has to do with entity But, I don't think I can go through trial and error until I get nowhere. So I'm asking here first before I fail just to see what direction to go towards. Thanks guys.
Silly String Question.
Suppose i wanted to extract an unknown value from a string, How would i go about doing it?
EX:
(class = 1, weapons = weapon_1,weapon_2)
how would i get the script to return "weapon_1,weapon_2" ? the weapons section is of variable value?
Anybody know the answer?
Hi guys, I'm trying to find a good SWEP base for use with a "realistic" rocket launcher. I've already got the code laid out for launching the missile but I understand that bases exist which handle recoil, dynamic accuracy, reload time etc.
If there's a good one in GM13 then I'd rather not re-invent the wheel :v: Can someone point me towards an appropriate one?
Customizable weaponry had a good system, but it's been dismantled. Maybe you could find a recent copy somewhere.
Hey guys. So this is my first attempt at a gamemode, please excuse my noobery. I'm try to play my gamemode, but when I join, at first it's fine but then my CPU turns to being way to high.
And then eventually I either get that 'hl2.exe has stopped working' or I get an error I've never seen before but I get what it's saying 'LUA is out of memory' or something.
I realize my computer is running out of memory when it runs this gamemode, but how can I fix it?
I am running a dedicated server, Notepad++, and GMod at the same time but if I change the gamemode to DarkRP or Sandbox, it's perfectly fine. I even tried other servers, perfectly fine also.
My specs are:
- Windows 7 64-Bit
- 4 GB of RAM
- Intel Core i3 CPU Processor
- And just in-case, it is an activated copy of Windows.
shared.lua:
DeriveGamemode("sandbox")
GM.Name = "Basewars"
GM.Author = "Ryan Grab AKA Team Cyan"
GM.Email = "ryan_grab@ymail.com"
GM.Website = "nope"
//////////Teams
team.SetUp(1, "Guest", Color(204, 255, 51, 255))
team.SetUp(2, "Admin", Color(255, 0, 10, 255))
team.SetUp(3, "Owner", Color(0, 255, 255, 255))init.lua
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')
function GM:PlayerInitialSpawn(ply)
ply:SetGravity(1)
ply:SetHealth(100)
if ply:SteamID() == rfgrab then
ply:SetTeam(3)
elseif ply:IsSuperAdmin() then
ply:SetTeam(2)
else
ply:SetTeam(1)
end
end
function GM:PlayerLoadout(ply)
if ply:Team() == 1 then
ply:Give("weapon_physgun")
ply:Give("weapon_physcannon")
ply:Give("gmod_tool")
elseif ply:Team() == 2 then
ply:Give("weapon_physgun")
ply:Give("weapon_physcannon")
ply:Give("gmod_tool")
ply:Give("weapon_pistol")
ply:Give("weapon_crowbar")
elseif ply:Team() == 3 then
ply:Give("weapon_physgun")
ply:Give("weapon_physcannon")
ply:Give("gmod_tool")
ply:Give("weapon_pistol")
ply:Give("weapon_crowbar")
end
endcl_init.lua
include('shared.lua')
function HUDHide(myhud)
for k, v in pairs{"CHudHealth","CHudBattery"} do
if myhud == v then return false end
end
end
hook.Add("HUDShouldDraw", "HUDHide", HUDHide)
function GM:HUDPaint()
self.BaseClass:HUDPaint()
local ply = LocalPlayer()
local HP = LocalPlayer():Health()
local ARM = LocalPlayer():Armor()
//Health
surface.CreateFont("HUDFont",
{
font = "ScoreboardText",
size = 25,
weight = 200,
antialias = false,
shadow = false
})
draw.SimpleText(HP, "HUDFont", 10, ScrH() - 15 - 40, Color(255,255,255,255))
end
Thanks, help would be much appreciated!
[QUOTE=Archemyde;39309541]Silly String Question.
Suppose i wanted to extract an unknown value from a string, How would i go about doing it?
EX:
(class = 1, weapons = weapon_1,weapon_2)
how would i get the script to return "weapon_1,weapon_2" ? the weapons section is of variable value?
Anybody know the answer?[/QUOTE]
This looks like a good candidate for regexp. Try lua patterns, they're good at extracting data from well-formed strings; [url]http://www.lua.org/pil/20.2.html[/url]
Though if you need to store data like that you should probably look at JSON or vON because I wasn't able to make a lua pattern work for that particular example.
[QUOTE=Archemyde;39309541]Silly String Question.
Suppose i wanted to extract an unknown value from a string, How would i go about doing it?
EX:
(class = 1, weapons = weapon_1,weapon_2)
how would i get the script to return "weapon_1,weapon_2" ? the weapons section is of variable value?
Anybody know the answer?[/QUOTE]
the pattern would probably look something like
[lua][^%s]+%s?=%s?([^,)]+)([^,)]+)[/lua]
which would be
"[^%s]+": anything other than a space for as long as possible
"%s?=%s?": an equals sign surrounded by optional spaces
"([^,)]+)": anything other than a comma or right parenthesis, the parenthesis around it means it'll return that match
(Repost, first one got ignored)
Can someone explain to me how to make a 3D2D panel that you can interact with?
[QUOTE=Archemyde;39311906](Repost, first one got ignored)
Can someone explain to me how to make a 3D2D panel that you can interact with?[/QUOTE]
[URL="http://www.facepunch.com/showthread.php?t=1160598&p=39034059&viewfull=1#post39034059"]http://www.facepunch.com/showthread.php?t=1160598&p=39034059&viewfull=1#post39034059[/URL]
Here's something which has me tearing hair out. I've got the following SWEP code in shared.lua;
[lua]function SWEP:PrimaryAttack()
if self:CanPrimaryAttack() then
if SERVER then self:FireRocket() return end
self.Weapon:TakePrimaryAmmo(1)
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
self.Owner:SetAnimation( PLAYER_ATTACK1 )
else
self.Weapon:EmitSound( self.EmptySound )
end
self.Weapon:SetNextPrimaryFire(CurTime() + 3)
end[/lua]
When I fire the weapon, it doesn't animate properly (jerks downwards as if to reload). Also, no ammo is removed and the weapon has no fire delay. Are SWEPs broken or something because I've got no clue what's going wrong here? I've made sure that SWEP.Base is set to "weapon_base".
[url=https://dl.dropbox.com/u/902553/Misc%20Files/weapon_acf_atgl.zip]Here's[/url] the full SWEP code folder if needed.
[QUOTE=brandonj4;39311914][URL="http://www.facepunch.com/showthread.php?t=1160598&p=39034059&viewfull=1#post39034059"]http://www.facepunch.com/showthread.php?t=1160598&p=39034059&viewfull=1#post39034059[/URL][/QUOTE]
thank you, i totally overlooked that post.
On a second note, have any idea what's wrong with it to boot - Besides the obvious copy/replace work?
Uhm, what is the best way to make a swep shoot Combine's Balls while still giving the player credit?
[editline]22nd January 2013[/editline]
The entity name is prop_combine_ball , but there are multiple versions of it. If I create it with the Hammer entity, it won't set the owner to the Player.
[QUOTE=Archemyde;39309541]Silly String Question.
Suppose i wanted to extract an unknown value from a string, How would i go about doing it?
EX:
(class = 1, weapons = weapon_1,weapon_2)
how would i get the script to return "weapon_1,weapon_2" ? the weapons section is of variable value?
Anybody know the answer?[/QUOTE]
Getting a value from a string ?
Do you know how to code ?
I guess your confusing strings with tables or values with variable names.
If I get you right you are creating a variable name that references to another variable, that's stupid because you would have 2 variables doing the same thing.
But if you mean how to get keys from tables, PrintTable(tbl).
Or if you want to get the value tbl["key"].
I want to make a tab based menu, is there anything else I can use besides DPropertySheet ?
Is it possible to set the owner of the entity im spawing in this example?
[LUA] function SpawnCar(ply, ent)
local Car = ents.Create("sent_sakarias_car_junker1")
Car:SetPos(table.Random(CarSpawn))
Car:SetAngles(carang[1].ang)
Car.Owner = (ply)
Car:Own(ply)
Car:Spawn()
Car:Activate()[/LUA]
Yes, this is SCars. Im trying to make a Vehicle Terminal where you can buy cars. I just wanted to know if there is a way to make the vehicle spawn in the name of the person spawning it through the function.
[QUOTE=Splambob;39311949]Here's something which has me tearing hair out. I've got the following SWEP code in shared.lua;
function SWEP:PrimaryAttack() if self:CanPrimaryAttack() then if SERVER then self:FireRocket() return end self.Weapon:TakePrimaryAmmo(1) self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) self.Owner:SetAnimation( PLAYER_ATTACK1 ) else self.Weapon:EmitSound( self.EmptySound ) end self.Weapon:SetNextPrimaryFire(CurTime() + 3)end
When I fire the weapon, it doesn't animate properly (jerks downwards as if to reload). Also, no ammo is removed and the weapon has no fire delay. Are SWEPs broken or something because I've got no clue what's going wrong here? I've made sure that SWEP.Base is set to "weapon_base".
[URL="https://dl.dropbox.com/u/902553/Misc Files/weapon_acf_atgl.zip"]Here's[/URL] the full SWEP code folder if needed.[/QUOTE]
Because you "return" right after the "self:FireRocket()" when it's the server. Essentially, you're not doing the rest of the code server side. Just remove the "return".
How would i go about picking up a prop_physics using lua?
data[1]:Input("Use",ply,ply)
Seems to pick it up, and drop it immediately, any help?
How do I make a Combine Ball (Prop_combine_ball) that has the owner of the player who holds the swep, and make it look and act like the ones shot from the AR2? Also, how do I get the view punch angle added to your aim vector without getting bullets that go in completely ridiculous directions?
Okay, I wasn't sure if I should make a thread on it's own about this, or put it in here.
Over the past week I've been stressing the fuck out over a plan gone wrong. I submitted a group of sweps to the workshop, and expected them to work perfectly like they did in single player. This was my second batch, so I wouldn't expect anything to go wrong. I was wrong however, as I've gotten waves of complaints saying "It doesn't work" or "It doesn't shoot" and other stuff related to that. From the information I gathered from users, it seemed as if there was something wrong with the weapon base that I include with every swep of mine. It's as if it wasn't there at all, though.
The weird thing is, that when people uninstalled certain things, they suddenly worked. Currently I'm sitting in the dark until I noticed Garry posted this on a swep I recently re-publicized to see if I would get complains from one single swep: [url]http://errors.garrysmod.com/addon/121466102/?minutes=43200[/url]
Apologies if I seem verbose; I'm just trying to explain this. I have no idea how to fix it, and I have no idea what's causing it, seeing how it SHOULD be reading from the files I put in the addon. I really need help.
Does anybody know what render.SetColorMaterial does? It doesn't appear to be documented anywhere...
No one has replied to this in over a day so I think its acceptable to repost it
[QUOTE=scrubtactics;39306185]Can anyone give me an example of how to use CUserCmd:GetMouseX() and CUserCmd:GetMouseY()? When I try to use those two methods in a CreateMove hook it always returns 0 even after moving the mouse quite a bit.
e.g.:
[lua]
function Foo(cmd)
print(cmd:GetMouseY())
print(cmd:GetMouseX())
end
hook.Add("CreateMove", "Foo", Foo)
[/lua][/QUOTE]
All the above code does is print "0" in the console even after I move the mouse a lot
Ok my first post got ignored so:
Hey guys. So this is my first attempt at a gamemode, please excuse my noobery. I'm try to play my gamemode, but when I join, at first it's fine but then my CPU turns to being way to high.
And then eventually I either get that 'hl2.exe has stopped working' or I get an error I've never seen before but I get what it's saying 'LUA is out of memory' or something.
I realize my computer is running out of memory when it runs this gamemode, but how can I fix it?
I am running a dedicated server, Notepad++, and GMod at the same time but if I change the gamemode to DarkRP or Sandbox, it's perfectly fine. I even tried other servers, perfectly fine also.
[b]shared.lua:[/b]
DeriveGamemode("sandbox")
GM.Name = "Basewars"
GM.Author = "Ryan Grab AKA Team Cyan"
GM.Email = "ryan_grab@ymail.com"
GM.Website = "nope"
//////////Teams
team.SetUp(1, "Guest", Color(204, 255, 51, 255))
team.SetUp(2, "Admin", Color(255, 0, 10, 255))
team.SetUp(3, "Owner", Color(0, 255, 255, 255))
[b]init.lua:[/b]
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')
function GM:PlayerInitialSpawn(ply)
ply:SetGravity(1)
ply:SetHealth(100)
if ply:SteamID() == rfgrab then
ply:SetTeam(3)
elseif ply:IsSuperAdmin() then
ply:SetTeam(2)
else
ply:SetTeam(1)
end
end
function GM:PlayerLoadout(ply)
if ply:Team() == 1 then
ply:Give("weapon_physgun")
ply:Give("weapon_physcannon")
ply:Give("gmod_tool")
elseif ply:Team() == 2 then
ply:Give("weapon_physgun")
ply:Give("weapon_physcannon")
ply:Give("gmod_tool")
ply:Give("weapon_pistol")
ply:Give("weapon_crowbar")
elseif ply:Team() == 3 then
ply:Give("weapon_physgun")
ply:Give("weapon_physcannon")
ply:Give("gmod_tool")
ply:Give("weapon_pistol")
ply:Give("weapon_crowbar")
end
end
[b]cl_init.lua[/b]
include('shared.lua')
function HUDHide(myhud)
for k, v in pairs{"CHudHealth","CHudBattery"} do
if myhud == v then return false end
end
end
hook.Add("HUDShouldDraw", "HUDHide", HUDHide)
function GM:HUDPaint()
self.BaseClass:HUDPaint()
local ply = LocalPlayer()
local HP = LocalPlayer():Health()
local ARM = LocalPlayer():Armor()
//Health
surface.CreateFont("HUDFont",
{
font = "ScoreboardText",
size = 25,
weight = 200,
antialias = false,
shadow = false
})
draw.SimpleText(HP, "HUDFont", 10, ScrH() - 15 - 40, Color(255,255,255,255))
end
[QUOTE=Science;39317427]How would i go about picking up a prop_physics using lua?
data[1]:Input("Use",ply,ply)
Seems to pick it up, and drop it immediately, any help?[/QUOTE]
ply:PickupObject( data[ 1 ] )
Maybe a silly question. But, why is it that I cannot find models such as the APC. It says models/combine_apc_wheelcollision.mdl but, like all buzz kills out their...it's not there. Any area I'm not looking in? Any help would be awesome.
Why is it that we are getting a million questions, but next to no answers?
Sorry, you need to Log In to post a reply to this thread.