[QUOTE=Bletotum;37768042]You cannot use ENT in gamemodes. You appear to not understand the code structure of the modding environment. If you are going to use ENT: in something, it needs to be part of an entity's code, not the gamemode's.
[editline]23rd September 2012[/editline]
whoops late[/QUOTE]
Thanks Bletotum, I'm still pretty lost, all I have are two partially valid wikis, a forum and a quiet #gmod irc.
[QUOTE=Middo;37768063]Thanks Bletotum, I'm still pretty lost, all I have are two partially valid wikis, a forum and a quiet #gmod irc.[/QUOTE]
this site may be of help: [url]http://glua.me[/url]
same with [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4875.html[/url]
they are both for GMod 12 but a lot of the information on both sites is still valid (well, some of it is anyway)
[QUOTE=Banana Lord.;37768110]this site may be of help: [url]http://glua.me[/url]
same with [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4875.html[/url]
they are both for GMod 12 but a lot of the information on both sites is still valid (well, some of it is anyway)[/QUOTE]
<3 That first link is immensely helpful, I've been working off that old 12 wiki for a while, it seems to be the primary resource for learning. I wish I could say it was comprehensive.
Moving along -- Okay I understand SENTs now and that makes a lot of sense, however I've already hit a snag. In this game mode I'm piecing together in GMod13Beta, I've got my folder structure for this simple entity (the "outlined" tub tutorial to be specific).
gmod13beta/gamemodes/odaat/gamemode/entities/entities/prop_test/*.lua
But if I do "ent_create prop_test" I just get told it's an unknown entity. I verified that I'm not doing it stupid by double-checking how other mods in 12 do it. It seems 13 has a new filesystem trick for packaging mods into archive files (.gma "garrys mod archive"?? files), so I can't/don't know how to inspect existing 13 mods yet for reference.
Sorry for the handholding guys :( I'm a high level programmer, 'ah promise.
Once I get comprehensive and dangerous in GMod I'm inclined to put together a "Welcome to GMod -- Let's go over what you need to know" tutorial, since I'm used to game engines and programming, because goddamn.
edit: Figured out how to extract .gma files using the gmadconv.exe tool, found it in this thread here [url]http://www.facepunch.com/showthread.php?t=1208166[/url]
edit 2: Haha okay, the full mods are visible in the GMOD 13 Beta .gcfs, yay for gcfscape
edit 3: Okay I'm a huge idiot, I had the path wrong after all, it's just gmod13beta/gamemodes/game_mode_name/entities, I had an extra gamemode in there which is where the "GM" scope *.lua files rest. DURRRRR
edit 4: Alright, the TTT gamemode in GMod13 should give me enough supplies for the winter. I'll try to ask less stupid questions.
How can I make a weapon that you can:
Remove the magazine AND put bullets manually into it
Put the magazine back into the gun
Load the gun with the slide
and then remove safety and shoot
EVERYTHING action with keys, I know i need models, but were do i start of?
Thank you in advance
This is a c++ question, so I hope one of the module-creating wizards find this. I didn't think it was really appropriate of me to post so many "HELP ME!" threads, so I thought I would post in here. Anyway...
Can anyone help me with sigscanning? I know (somewhat, I think I might be doing it wrong) how to find a function with Ida, get a function's signature, mask, and size, but I am kind of confused about how you would reverse the parameters of the function. I am also confused on how one would use the function once you found its address.
Thanks!
edit:
Oh yes, and before I forget, I have read [URL="http://wiki.alliedmods.net/Signature_Scanning"]this page[/URL].
[QUOTE=SashaWolf;37771298]This is a c++ question, so I hope one of the module-creating wizards find this. I didn't think it was really appropriate of me to post so many "HELP ME!" threads, so I thought I would post in here. Anyway...
Can anyone help me with sigscanning? I know (somewhat, I think I might be doing it wrong) how to find a function with Ida, get a function's signature, mask, and size, but I am kind of confused about how you would reverse the parameters of the function. I am also confused on how one would use the function once you found its address.
Thanks!
edit:
Oh yes, and before I forget, I have read [URL="http://wiki.alliedmods.net/Signature_Scanning"]this page[/URL].[/QUOTE]
You'll probably get a better answer if you ask in the section where the C++ gurus hang out: [url]http://www.facepunch.com/showthread.php?t=1167392[/url]
[QUOTE=Divran;37771708]You'll probably get a better answer if you ask in the section where the C++ gurus hang out: [URL]http://www.facepunch.com/showthread.php?t=1167392[/URL][/QUOTE]
Okay, sounds good. I will post there. Thanks!
hey guys, I'm coding a gamemode!
I'm trying to use team.SetClass but it does nothing at all!
class file is included at shared.lua
[U][B]shared.lua[/B][/U]
team.SetClass( TEAM_Blue, "player_blue" )
the name is registered here:
[B][U]player_blue.lua[/U][/B]
player_manager.RegisterClass( "player_blue", PLAYER, "player_default" )
so what's wrong?
Trying to make a third person thingie, but I can't figure out why this happens:
[url]http://puu.sh/17WDT[/url]
[lua]
function ShouldDrawLocalPlayer(ply)
if thirdperson:GetInt() == 0 then return false end
return true
end
hook.Add("ShouldDrawLocalPlayer", "ThirdPerson.ShouldDrawLocalPlayer", ShouldDrawLocalPlayer)
[/lua]
[QUOTE=Persious;37774709]Trying to make a third person thingie, but I can't figure out why this happens:
[url]http://puu.sh/17WDT[/url]
[lua]
function ShouldDrawLocalPlayer(ply)
if thirdperson:GetInt() == 0 then return false end
return true
end
hook.Add("ShouldDrawLocalPlayer", "ThirdPerson.ShouldDrawLocalPlayer", ShouldDrawLocalPlayer)
[/lua][/QUOTE]
ShouldDrawLocalPlayer is broken in Gmod 13: [url]http://facepunch.com/showthread.php?t=1213399[/url]
asdasjjbvhd thank you.
[QUOTE=Persious;37774709]Trying to make a third person thingie, but I can't figure out why this happens:
[URL]http://puu.sh/17WDT[/URL]
function ShouldDrawLocalPlayer(ply) if thirdperson:GetInt() == 0 then return false end return trueendhook.Add("ShouldDrawLocalPlayer", "ThirdPerson.ShouldDrawLocalPlayer", ShouldDrawLocalPlayer)[/QUOTE]
Why not use calcview? The wiki even has an example you could modify to be a third person thing. :D
[QUOTE=SashaWolf;37776050]Why not use calcview? The wiki even has an example you could modify to be a third person thing. :D[/QUOTE]
You will still have to return [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexa5ae.html"]ShouldDrawLocalPlayer [/URL]as true.
Something I could use some help with --
I'd like to control an entity, as in, my camera code latches itself to the entity (like npc_civilian), and your WASD inputs (or +forward impulses etc), command the entity to move around as if it was just a player. But I don't see/know of simple "Move" functions on entity's, I was digging through the wiki but I'm wondering if I'm missing something obvious. SetVelocity and such don't seem to be good solutions since there are important elements of the C++ movecode that consider whether or not you're attached to the ground.
Any advice?
I'm currently trying to write something that will replace the default "X has joined!" message with
"X has joined! [STEAMID]" but what I have will print it AFTER they joined, not over-writing the default message.
[code]hook.Add("PlayerInitialSpawn","JoinAlert", function(ply)
for k,v in pairs(player.GetAll()) do
if (v:IsAdmin() || v:IsSuperAdmin() || !(ply:IsAdmin() || ply:IsSuperAdmin())) then
v:PrintMessage(3,ply:Nick().." has joined the server! ["..ply:SteamID().."]")
end
end
end)
[/code]
Any help with this?
you have to make a new gamemode and completely overwrite the function
hook.Add does what it says, and adds the function you made to the defined gamemode function
so no, you cant replace functions with hook.Add()
[QUOTE=comet1337;37777256]you have to make a new gamemode and completely overwrite the function
hook.Add does what it says, and adds the function you made to the defined gamemode function
so no, you cant replace functions with hook.Add()[/QUOTE]
This is implemented into TTT. Is it possible to over-write the default inside of TTT's gamemode if I make it so?
[QUOTE=zerothefallen;37776987]I'm currently trying to write something that will replace the default "X has joined!" message with
"X has joined! [STEAMID]" but what I have will print it AFTER they joined, not over-writing the default message.
[code]code[/code]
Any help with this?[/QUOTE]
I apologize ahead of time if I'm wrong, I don't completely understand what you're asking to replace:
So you're trying to replace "Player <name> has connected"? Hook [url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index50f8.html]ChatText[/url] clientside instead of PlayerInitialSpawn serverside, and check if the message type is "joinleave". Should work, but I've never tried it, so I'm not sure.
I'm making a quicky wallhack to learn how to use stencils.
This is what I have so far... but I'm totally stumped. How do I get rid of these white flecks?
[thumb]http://cloud.steampowered.com/ugc/541813398738490808/600D343F4BC0ECCF9F145E3B7F6B4711E81B8111/[/thumb]
[lua]local solid = CreateMaterial("AIM_Solid", "Wireframe", {["$basetexture"] = "models/debug/debugwhite"})
hook.Add("PostDrawOpaqueRenderables", "AIM_Wallhack", function()
//if GetConVarNumber("AIM_Enabled") == 0 then return end
cam.Start3D(EyePos(), EyeAngles())
render.SuppressEngineLighting(true)
render.ClearStencil()
render.SetStencilEnable(true)
render.SetStencilFailOperation(STENCILOPERATION_DECR)
render.SetStencilZFailOperation(STENCILOPERATION_REPLACE)
render.SetStencilPassOperation(STENCILOPERATION_DECR)
render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_GREATEREQUAL)
render.SetStencilReferenceValue(1)
for k, v in pairs(player.GetAll()) do
if v:Alive() then
local col = v.aim_viscolor or Color(0, 255, 0, 255)
render.SetColorModulation(col.r/255, col.g/255, col.b/255)
v:DrawModel()
pcall(function() v:GetActiveWeapon():DrawModel() end) // I'm lazy.
render.SetColorModulation(1, 1, 1)
end
end
render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_EQUAL)
render.SetMaterial(solid)
render.DrawScreenQuad()
render.SetStencilEnable(false)
render.SuppressEngineLighting(false)
cam.End3D()
end)
[/lua]
The white parts is where the models are "overlapping"
To resolve this you have to draw them in a separate pass where they are invisible (so they don't write anything to the depth buffer) before you draw them visible like so
[lua]
render.SetBlend(0) --0 alpha
for k, v in pairs(player.GetAll()) do --first pass
if v:Alive() then
v:DrawModel()
pcall(function() v:GetActiveWeapon():DrawModel() end) // I'm lazy.
end
end
render.SetBlend(1) --full alpha again
render.SetStencilZFailOperation(STENCIL_KEEP) --no stenciling for this part
for k, v in pairs(player.GetAll()) do --second pass
if v:Alive() then
local col = v.aim_viscolor or Color(0, 255, 0, 255)
render.SetColorModulation(col.r/255, col.g/255, col.b/255)
v:DrawModel()
pcall(function() v:GetActiveWeapon():DrawModel() end) // I'm lazy.
render.SetColorModulation(1, 1, 1)
end
end
[/lua]
[thumb]http://cloud.steampowered.com/ugc/541813398739956998/0EAC912D9E6185C2B0AF3F5267C63A939765AFDE/[/thumb]
It works, just... the colors... broke, I guess...
Any idea why?
Also thank you very much.
[b][RESOLVED][/b]
After not coding for a while I decided to start porting my UT2K4 stuff over to the beta, but none of my weapons are showing up in the menu. After looking around in the .gcf I noticed that SWEPs and entities seem to no longer use the "shared.lua", "init.lua" and "cl_init.lua" system anymore and that is was replaced by having a single file in the weapons folder with the name of the swep.
I haven't found any information on how this new system works in comparison to the old one and was wondering if someone can shed some light on it for me.
[thumb]http://cloud.steampowered.com/ugc/541813398740679377/BAB1C6F36ED3343A53E01BDA1A161CD62CD56156/[/thumb]
It works. Thanks!
-snip-
figured it out.
I'm having a hard time removing items from some maps. On a couple maps, items go away like they're supposed to, on some others, they still show up.
here's the code I'm using. Any ideas? What am I doing wrong?
[lua]function GM:PreSlaughterCleanUp()
for k, v in pairs ( ents.FindByClass( "item*") ) do
v:Remove()
end
for k, v in pairs ( ents.FindByClass( "weapon*") ) do
v:Remove()
end
end
hook.Add ("RoundStart", "CheatingIsFrownedUpon", PreSlaughterCleanUp);[/lua]
[QUOTE=SashaWolf;37776050]Why not use calcview? The wiki even has an example you could modify to be a third person thing. :D[/QUOTE]
I do use it, but as brandon said, you need to return it as true.
[QUOTE=me-name-bob;37781907]I'm having a hard time removing items from some maps. On a couple maps, items go away like they're supposed to, on some others, they still show up.
here's the code I'm using. Any ideas? What am I doing wrong?
[lua]function GM:PreSlaughterCleanUp()
for k, v in pairs ( ents.FindByClass( "item*") ) do
v:Remove()
end
for k, v in pairs ( ents.FindByClass( "weapon*") ) do
v:Remove()
end
end
hook.Add ("RoundStart", "CheatingIsFrownedUpon", PreSlaughterCleanUp);[/lua][/QUOTE]
My guess is that they're spawned after RoundStart. By some trigger or some shit.
[QUOTE=me-name-bob;37781907]I'm having a hard time removing items from some maps. On a couple maps, items go away like they're supposed to, on some others, they still show up.
here's the code I'm using. Any ideas? What am I doing wrong?
[lua]function GM:PreSlaughterCleanUp()
for k, v in pairs ( ents.FindByClass( "item*") ) do
v:Remove()
end
for k, v in pairs ( ents.FindByClass( "weapon*") ) do
v:Remove()
end
end
hook.Add ("RoundStart", "CheatingIsFrownedUpon", PreSlaughterCleanUp);[/lua][/QUOTE]
Use this
[lua]
for k, v in pairs( ents.GetAll() ) do
if v:IsWeapon() && !ValidEntity( v:GetOwner() ) then
--if the entity is a weapon and does not have a valid owner/does not have an owner then remove it
v:Remove()
end
end
[/lua]
Now, as for your item classes...I'm not sure how to check it's an item in Lua, perhaps someone could help there
PS ValidEntity is removed in GM13, use IsValid
I've been trying to make a reload function that automatically lowers your weapon whenever you reload, a.k.a goldeneye, but I just have no fucking clue how to do that. Could anyone make me a reload function with that feature and explain how it works?
Thanks!
IncludePlayerClasses() gives me
[gamemodes/*******/gamemode/shared.lua:41] attempt to call global 'IncludePlayerClasses' (a nil value)
can anyone tell me how to use it the right way?
Sorry, you need to Log In to post a reply to this thread.