[QUOTE=Mista Tea;46958170]The error can sound a bit misleading. Add a comma after [B]ply:GetNWString("usergroup")) end[/B][/QUOTE]
Thanks, it worked. Cheers.
nvm. Figured it out.
[code]function SWEP:CanPrimaryAttack( )
if self:GetNextPrimaryFire( ) < CurTime( ) then
return true
else
return false
end
end
function SWEP:PrimaryAttack( )
if !self:CanPrimaryAttack( ) then return end
if CLIENT then
print( CurTime( ) )
end
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
end[/code]
Are there any ideas why I'm seeing the same time printed over and over in console, possibly hinting to the function running multiple times? Is there any way to prevent this?
[QUOTE=wauterboi;46958383][code]function SWEP:CanPrimaryAttack( )
if self:GetNextPrimaryFire( ) < CurTime( ) then
return true
else
return false
end
end
function SWEP:PrimaryAttack( )
if !self:CanPrimaryAttack( ) then return end
if CLIENT then
print( CurTime( ) )
end
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
end[/code]
Are their any ideas why I'm seeing the same time printed over and over in console, possibly hinting to the function running multiple times? Is there any way to prevent this?[/QUOTE]
Read [URL="http://wiki.garrysmod.com/page/Prediction"]here[/URL] please.
Also [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Weapon/SetNextPrimaryFire]Weapon:SetNextPrimaryFire[/url] already prevents PrimaryAttack from running, your CanPrimaryAttack is useless there.
I deleted a lot of stuff from CanPrimaryAttack, but more stuff will be in there as I slowly reprogram my weapons. Thanks for the info, though!
Heh, I'm back again... lol :\ so I have an issue with 3D Car Dealer 2 by Rocketmania and I have set custom groups and teams for police cars but non-police and non-donors can buy these vehicles.
[CODE] local TB2Insert = {}
TB2Insert.VehicleName = 'hsvw427poltdm'
TB2Insert.CarName = 'Holden HSV W427 Police'
TB2Insert.CarPrice = 23750
TB2Insert.CarRefund = 9500
TB2Insert.Description = 'Holden HSV W427 Police Version - More vehicles to be added soon!'
TB2Insert.AvaliableTeam = { TEAM_SERGEANT, TEAM_POLICE }
table.insert(D3DCarConfig.Car,TB2Insert)
local TB2Insert = {}
TB2Insert.VehicleName = 'mitsuevoxpoltdm'
TB2Insert.CarName = 'Mitsubishi Evo X Police'
TB2Insert.CarPrice = 22250
TB2Insert.CarRefund = 9450
TB2Insert.Description = 'Mitsubishi Evo X Police Version - More vehicles to be added soon!'
TB2Insert.AvaliableTeam = {TEAM_SERGEANT, TEAM_POLICE}
TB2Insert.AvaliableGroup = {
"tier1", "tier2", "tier3", "tier4", "tier5",
"modtier1", "modtier2", "modtier3", "modtier4", "modtier5",
"admintier1", "admintier2", "admintier3", "admintier4", "admintier5",
"superadmin", "owner"
}
table.insert(D3DCarConfig.Car,TB2Insert) [/CODE]
I don't see anything wrong with the code...
[CODE] local TB2Insert = {}
TB2Insert.VehicleName = "VEHICLE NAME"
TB2Insert.CarName = "CAR PRINT NAME"
TB2Insert.CarPrice = 100
TB2Insert.CarRefund = 100
TB2Insert.IsSCar = true
TB2Insert.Description = "DESCRIPTIONS"
TB2Insert.AvaliableTeam = {TEAM_POLICE,TEAM_MOB}
TB2Insert.AvaliableGroup = {"superadmin","admin"}
table.insert(D3DCarConfig.Car,TB2Insert)[/CODE]
That's the template it says I should use but it doesn't work.. Any ideas?
Is there a way to prevent addon lua/autorun files from running on a server? I often run into the problem of wanting to use a Workshop addon for purely the models it contains (and the ease of having it hosted on Workshop), but having to put up with terrible code that's included which breaks other stuff on my server.
[QUOTE=TheBigS;46960169]Is there a way to prevent addon lua/autorun files from running on a server? I often run into the problem of wanting to use a Workshop addon for purely the models it contains (and the ease of having it hosted on Workshop), but having to put up with terrible code that's included which breaks other stuff on my server.[/QUOTE]
You could override its functions (if they are global). Thats what I always do when I just need to edit a few things from a workshop addon.
Okay, I'm not actually sure if this post warrants its own thread or not. I've been trying to get my player class working, and finally I've done it - but on the way, I've had to do some counter-intuitive things so I'm asking what they actually means.
It all boils down to DEFINE_BASECLASS - what is it?
The GMod wiki is [url=http://wiki.garrysmod.com/page/Category:baseclass]very unhelpful[/url] about this. Here's what I was thinking:
I'm deriving from sandbox, and sandbox is deriving from base. Therefore, I could use some of the sandbox code as reference, and replace occurrences of "base" with "sandbox". So for example, in player_vionit I had the line:[lua]DEFINE_BASECLASS( "player_sandbox" )[/lua]
And in init.lua, I had the line:[lua]DEFINE_BASECLASS( "gamemode_sandbox" )[/lua]
Now, this didn't work. What DID work is switching sandbox to base in both of these. Could someone explain what this function even means, and why it didn't work with sandbox parameters? Also, it would be amazing if someone could add this info to the wiki...
[QUOTE=Neat-Nit;46961483]It all boils down to DEFINE_BASECLASS - what is it?
[/QUOTE]
"The function DEFINE_BASECLASS translates into a call to this function: in the engine, DEFINE_BASECLASS is replaced with "local BaseClass = baseclass.Get"."
[URL]http://wiki.garrysmod.com/page/baseclass/Get[/URL]
To my understanding, after using DEFINE_BASECLASS at the top of your custom gamemode, you can then use any of the defined base class's functions without having to reimplement them, like so:
[CODE]
DEFINE_BASECLASS( "gamemode_sandbox" )
function GM:PlayerSpawn( ply )
BaseClass.PlayerSpawn( ply ) -- runs the Sandbox's GM:PlayerSpawn function
-- now your own custom stuff
end[/CODE]
Is it possible to grab all the acts a model is capable of?
i'm going into nextbot and I can't seem to find a working ACT other than ACT_RUN and ACT_WALK
Not directly. Iterate over [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetSequenceList]Entity:GetSequenceList[/url] and then use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetSequenceActivityName]Entity:GetSequenceActivityName[/url]
It will give you all the activities and show you if an activity has multiple sequences.
Ok that brings me to another question
I'm trying to make a bot from CSS but I'm really confused about getting some of the sequences to work
For example most of the sequences such as Run_Shoot_M4 and Run_Reload_M4 animate strangely.
Ie the turn around 90 degrees clockwise and do their animation strangely. I'm wondering how to make it work properly.
Those probably are gestures, not animations.
[QUOTE=Kogitsune;46961917]Those probably are gestures, not animations.[/QUOTE]
How would one apply those gestures to entities/nextbot?
[QUOTE=ROFLBURGER;46962076]How would one apply those gestures to entities/nextbot?[/QUOTE]
self:RestartGesture()
It is extremely limited and buggy.
[QUOTE=Kogitsune;46962121][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/RestartGesture]Entity:RestartGesture[/url] ?[/QUOTE]
Yeah I already looked that up and it requires an ACT, which most of the sequences don't have.
I can't get the OnLuaError hook to print something when a Lua error occurs and its confusing as to why it won't work
hook.Add( "OnLuaError", "Test", function( str, realm, addontitle, addonid )
print("ERROR")
end)
[QUOTE=Exho;46962432]I can't get the OnLuaError hook to print something when a Lua error occurs and its confusing as to why it won't work
hook.Add( "OnLuaError", "Test", function( str, realm, addontitle, addonid )
print("ERROR")
end)[/QUOTE]
Only works in the menu state right now. There's a request open to bring it to the other realms too.
[QUOTE=Exho;46962432]I can't get the OnLuaError hook to print something when a Lua error occurs and its confusing as to why it won't work
hook.Add( "OnLuaError", "Test", function( str, realm, addontitle, addonid )
print("ERROR")
end)[/QUOTE]
Related? [URL]https://github.com/Facepunch/garrysmod-issues/issues/1069[/URL] Only available in menu state
Ninja'd
How does one put elements outside the dframe, make them visible yet parented to the dframe?
You could use a DPanel, but there's another way that I can't think of right now
[QUOTE=RedNinja;46962452]How does one put elements outside the dframe, make them visible yet parented to the dframe?[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/NoClipping]Panel:NoClipping[/url]
[QUOTE=_FR_Starfox64;46960392]You could override its functions (if they are global). Thats what I always do when I just need to edit a few things from a workshop addon.[/QUOTE]
Unfortunately this particular addon's functions are all local, with a very annoying message loop that uses a timer simple. The best I've been able to do are remove a couple of hooks, but haven't been able to figure out a way to suppress the rest of the junk.
I wonder if I created "empty" autorun lua files with the same names as the ones created by the addon and placed them in the corresponding folder, if that would somehow prevent the real ones from running...
Any other ideas?
[QUOTE=Bo98;46962442]Only works in the menu state right now. There's a request open to bring it to the other realms too.[/QUOTE]
Well damn, because that would be really useful. If it calls the error() function maybe I could override it to call a hook and then the original function instead?
Edit: Nevermind, its probably in C... Damn
How are you supposed to set the position of ClientsideRagdolls?
[lua]
local rag = ClientsideRagdoll( "models/zombie/fast.mdl" )
rag:SetPos(LocalPlayer():GetPos())
rag:SetNoDraw(false)
[/lua]
Ragdoll will still appear at 0, 0, 0.
-- Nevermind, was able to move it by moving the bones individually.
[lua]
local num = rag:GetPhysicsObjectCount()-1
for i=0, num do
local bone = rag:GetPhysicsObjectNum(i)
if IsValid(bone) then
bone:SetPos(pos)
end
end
[/lua]
Maybe this will help someone.
I really don't expect anyone too look at almost 300 lines of code but it's worth a shot posting
[url]http://pastebin.com/6PfWJN2a[/url]
This is my attempted at a nextbot. I always crash when the bot kills me, it leaves no errors. I suspect it's something to do with the while loops (this is the first time ever using them) so if someone can figure out whats making me crash it would be greatly appreciated
[QUOTE=ROFLBURGER;46963539]I really don't expect anyone too look at almost 300 lines of code but it's worth a shot posting
[URL]http://pastebin.com/6PfWJN2a[/URL]
This is my attempted at a nextbot. I always crash when the bot kills me, it leaves no errors. I suspect it's something to do with the while loops (this is the first time ever using them) so if someone can figure out whats making me crash it would be greatly appreciated[/QUOTE]
300 lines is nothing, I've got some scripts that are nearing 2000 lines, but every bit of code has a purpose.
Lol, what is the point, line 169, "while true do"? That basically means, if this is running, then run it. It's redundant.
212: if ( !path:IsValid() ) then return "failed" end
214: while ( path:IsValid() ) do
261: if ( !path:IsValid() ) then return "failed" end
263: while ( path:IsValid() ) do
This is interesting to me. Is it necessary to return if the path is not valid? If the path isn't valid, then the while loop wouldn't run it. Maybe you want the while loop to continue running, only skipping the false paths? In which case, "continue" can do the job, I do believe, but the while loop will continue to continue indefinitely.
[QUOTE=WalkingZombie;46964040]300 lines is nothing, I've got some scripts that are nearing 2000 lines, but every bit of code has a purpose.
Lol, what is the point, line 169, "while true do"? That basically means, if this is running, then run it. It's redundant.
212: if ( !path:IsValid() ) then return "failed" end
214: while ( path:IsValid() ) do
yet another case of redundancy. You've already made sure that the path is valid, but you're doing it again. You also did this on lines 261 and 263.
If it has anything to do with you're while loops, those are the loops I found with ctrl+f search. Each one seems redundant.[/QUOTE]
I don't think you understand how nextbot works in gmod.
Sorry, you need to Log In to post a reply to this thread.