I'm using the SourceSDK (mp, [url]https://github.com/ValveSoftware/source-sdk-2013/tree/master/mp/src/public[/url]) and loading this module on my server. I have the tier0 and tier1 libs, and I've added them and have no compilation errors, but the server variable is NULL.
[cpp]#include "Lua/Interface.h"
#include "eiface.h"
IVEngineServer* server;
GMOD_MODULE_OPEN()
{
CreateInterfaceFn engineFactory = Sys_GetFactory("engine.dll");
server = (IVEngineServer*)engineFactory(INTERFACEVERSION_VENGINESERVER, NULL); // server variable is NULL
return 0;
}
GMOD_MODULE_CLOSE()
{
return 0;
}[/cpp]
I have no idea why it's NULL. What am I doing wrong?
[QUOTE=man with hat;46766485]I'm using the SourceSDK (mp, [url]https://github.com/ValveSoftware/source-sdk-2013/tree/master/mp/src/public[/url]) and loading this module on my server. I have the tier0 and tier1 libs, and I've added them and have no compilation errors, but the server variable is NULL.
[cpp]#include "Lua/Interface.h"
#include "eiface.h"
IVEngineServer* server;
GMOD_MODULE_OPEN()
{
CreateInterfaceFn engineFactory = Sys_GetFactory("engine.dll");
server = (IVEngineServer*)engineFactory(INTERFACEVERSION_VENGINESERVER, NULL); // server variable is NULL
return 0;
}
GMOD_MODULE_CLOSE()
{
return 0;
}[/cpp]
I have no idea why it's NULL. What am I doing wrong?[/QUOTE]
Garrysmod is on an older engine than the source-sdk use INTERFACEVERSION_VENGINESERVER_VERSION_21.
[QUOTE=mcd1992;46767094]Garrysmod is on an older engine than the source-sdk use INTERFACEVERSION_VENGINESERVER_VERSION_21.[/QUOTE]
Thanks, that definitely fixed it. Another problem I'm running into is using server->GetIServer(). The program crashes whenever I call that. Is it because of gmod's engine being outdated?
[QUOTE=man with hat;46767170]Thanks, that definitely fixed it. Another problem I'm running into is using server->GetIServer(). The program crashes whenever I call that. Is it because of gmod's engine being outdated?[/QUOTE]
Try VEngineServerV21 as your class.
I'm trying to add trails to my server's pointshop. All of the lua files are in the correct item folder in pointshop(pointshop/items/trails/trail.lua). For example, one of them is a trollface trail. This is what the code is.
[CODE]ITEM.Name = 'Troll'
ITEM.Price = 150
ITEM.Material = 'trails/troll.vmt'
function ITEM:OnEquip(ply, modifications)
ply.TrollTrail = util.SpriteTrail(ply, 0, modifications.color, false, 15, 1, 4, 0.125, self.Material)
end
function ITEM:OnHolster(ply)
SafeRemoveEntity(ply.TrollTrail)
end
function ITEM:Modify(modifications)
PS:ShowColorChooser(self, modifications)
end
function ITEM:OnModify(ply, modifications)
SafeRemoveEntity(ply.TrollTrail)
self:OnEquip(ply, modifications)
end[/CODE]
I don't see whats wrong with the script, but nobody has been able to see them. They show up as the classic purple/black squares and nobody can see them. The two vmt/vtf's are in the correct folder. (materials/trails/troll.vmt, and .vtf). I also have a duplicate folder of the vtfs/vmts in the trail addon itself. Also, yes, the trails are in the forced downloads file. People are downloading them, but are still not able to see them. I don't see what i'm doing wrong here. Can anyone help? (also same thing happened with my playermodels)
[QUOTE=Willox;46767232]Try VEngineServerV21 as your class.[/QUOTE]
I tried that and it didn't work out, but I saw eifacev21.h and replaced eiface.h with that. VEngineServerV21 is there but it isn't defined as a class, but a namespace. The only thing in the namespace is IVEngineServer and that version of it does not have GetIServer(). There is IVEngineServer021 in eiface.h and I've tried that as well but it crashes just like IVEngineServer.
To summarize:
• IVEngineServer and IVEngineServer021 in eiface.h crash when called.
• VEngineServerV21::IVEngineServer in eifacev21.h does not have GetIServer().
I can use other functions just fine. It seems to be only GetIServer().
Is it possible to enable physics with entities created by ClientsideModel() or is physics a serverside only function.
I'm basically just creating my own debris
Either LUA is shit or I'm really stupid.
[CODE]
self.clown = 5
self.mime = 6
self.clown = self.clown + self.mime (returns 5)
self.clown = self.mime (returns 5)
self.clown = self.mime + 10 (returns 5)[/CODE]
Am I doing something horribly wrong here or is setting a integer variable to the contents of a different integer variable impossible, or adding 2 integer variables together is impossible?
Make sure self is defined. Also, what is self mime? Also, use comments, either // or --
Ok I'm really confused right now because I'm familiar with how to scale a player's damage and how to add hooks but for some reason this isn't working
this is located in autorun/server
[lua]
function TeamDamageMod(ply,hitgroup,dmginfo)
local victim = ply
local attacker = dmginfo:GetAttacker()
print("anus")
print(victim:Team())
print(attacker:Team())
if victim:Team() == attacker:Team() and victim:Team() ~= 1001 then
dmginfo:ScaleDamage(0)
end
end
hook.Add("ScalePlayerDamage","Scale Team Damage", TeamDamageMod )
[/lua]
it's not even printing anus, what am I doing wrong?
[editline]22nd December 2014[/editline]
Really confused did. Printtable(hook.GetTable()) and it picks up
[code]
ScalePlayerDamage:
UT Damage = function: 0x196270c0
TeamDamageMod = function: 0x36c71818
JackaScaleDamageHook = function: 0x196059a0
CSS Detect Headshots = function: 0x340dde38
[/code]
Is it possible to print the full contents of a function?
[QUOTE=ROFLBURGER;46768545]Ok I'm really confused right now because I'm familiar with how to scale a player's damage and how to add hooks but for some reason this isn't working
this is located in autorun/server
it's not even printing anus, what am I doing wrong?
[editline]22nd December 2014[/editline]
Really confused did. Printtable(hook.GetTable()) and it picks up
[code]
ScalePlayerDamage:
UT Damage = function: 0x196270c0
TeamDamageMod = function: 0x36c71818
JackaScaleDamageHook = function: 0x196059a0
CSS Detect Headshots = function: 0x340dde38
[/code]
Is it possible to print the full contents of a function?[/QUOTE]
Take a look at my dev base... More specifically these few files. Combined, they'll let you print pretty much anything out in print, and even concatenate them too..
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/core/ext_string.lua[/url]
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/_definitions/__metatables.lua?at=master[/url]
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/_definitions/__metatables__tostring.lua?at=master[/url]
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/core/toprint.lua?at=master[/url]
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/core/print.lua?at=master[/url]
Or download as addon: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/addons/acecooldev_printall_addon.rar[/url]
Hopefully this helps...
Alright, with the damage... Aren't you supposed to return the dmginfo??? I can't recall but I think I've seen people doing that.
[editline]22nd December 2014[/editline]
[QUOTE=DarthTealc;46768686]I think I've figured out my problem, I believe it's a bug with the TTT gamemode. Anyone want to double-check my logic before I report the bug so I don't make a fool of myself if I'm missing something obvious? :P
On a server running TTT I'm unable to set playermodel colours using the [URL="http://www.troubleinterroristtown.com/guides/hooks"]documented "TTTPlayerColor" hook[/URL] which says you need to "Return a Color object".
I'm doing this in a file that runs serverside
[code]hook.Add( "TTTPlayerColor", "dtTTTPlayerColor", function( )
return COLOR_PINK
end )[/code]
I also tried Color(255,0,255) instead of COLOR_PINK, and I tried a couple different colours not just pink.
That should set players to pink but they're spawning blue every time. I echo'd the GAMEMODE.playercolor value and it comes back as 255 0 255 255 as expected, but they still always spawn blue.[/QUOTE]
It seems to hook.Call init.lua:479 and in SHARED it has another hook that needs to be called:
shared.lua:150 hook.Call("TTTShouldColorModel", GAMEMODE, model)
[editline]22nd December 2014[/editline]
[QUOTE=ROFLBURGER;46768545]Ok I'm really confused right now because I'm familiar with how to scale a player's damage and how to add hooks but for some reason this isn't working
this is located in autorun/server
it's not even printing anus, what am I doing wrong?
[editline]22nd December 2014[/editline]
Really confused did. Printtable(hook.GetTable()) and it picks up
Is it possible to print the full contents of a function?[/QUOTE]
Wait, are you wanting to print the actual Lua from a function? That can be done... Here:
[code]fileio = fileio || { };
fileio.__filecache = fileio.__filecache || { };
//
// Output Lua function data - Josh 'Acecool' Moser
//
function fileio:ReadFunction( _func )
if( isfunction( _func ) ) then
local _data = debug.getinfo( _func );
local _file = _data.short_src;
// Make sure we can read the function
local _bLua = ( _data.what == "Lua" );
local _bC = ( _data.what == "C" );
if ( !_bLua ) then return false; end
// Does the function contain ...?
local _tripledot = _data.isvararg;
// How many arguments does the function have?
local _args = _data.nparams;
// ??
local _namewhat = _data.namewhat;
// ??
local _wtf = _data.nups;
local _current_line = _data.currentline; -- currentline gives the current line where a given function is executing; if the function was pre-compiled with debug info 4.8 http://www.lua.org/manual/2.4/node12.html#pragma
local _start_line = _data.linedefined;
local _last_line = _data.lastlinedefined;
local _lines = _last_line - _start_line;
local _cache = self.__filecache[ _file ];
if ( !self.__filecache[ _file ] ) then
self.__filecache[ _file ] = file.Read( _file, "GAME" );
self.__filecache[ _file ] = string.gsub( self.__filecache[ _file ] || "", "\r\n", "\n" );
self.__filecache[ _file ] = string.gsub( self.__filecache[ _file ] || "", "\n\r", "\n" );
self.__filecache[ _file ] = string.Explode( "\n", self.__filecache[ _file ] );
_cache = self.__filecache[ _file ];
end
local _output = "";
if ( _last_line - _start_line > 0 ) then
for i = _start_line, _last_line do
_output = _output .. ( _cache[ i ] || "" ) .. "\n";
end
end
return _output;
end
end
if ( SERVER ) then
networking:SendToClient( "CopyToClipboard", Entity( 1 ), fileio:ReadFunction( fileio.ReadFunction ) )
end
[/code]
[code]**************************************************
GameMode loaded 712 files!
**************************************************
[AcecoolDev]-GameMode Refreshed. You've been here for [00:00:00].
Data copied to clipboard!
Data copied to clipboard: function fileio:ReadFunction( _func )
if( isfunction( _func ) ) then
local _data = debug.getinfo( _func );
local _file = _data.short_src;
// Make sure we can read the function
local _bLua = ( _data.what == "Lua" );
local _bC = ( _data.what == "C" );
if ( !_bLua ) then return false; end
// Does the function contain ...?
local _tripledot = _data.isvararg;
// How many arguments does the function have?
local _args = _data.nparams;
// ??
local _namewhat = _data.namewhat;
// ??
local _wtf = _data.nups;
local _current_line = _data.currentline; -- currentline gives the current line where a given function is executing; if the function was pre-compiled with debug info 4.8 [url]http://www.lua.org/manual/2.4/node12.html#pragma[/url]
local _start_line = _data.linedefined;
local _last_line = _data.lastlinedefined;
local _lines = _last_line - _start_line;
local _cache = self.__filecache[ _file ];
if ( !self.__filecache[ _file ] ) then
self.__filecache[ _file ] = file.Read( _file, "GAME" );
self.__filecache[ _file ] = string.gsub( self.__filecache[ _file ] || "", "\r\n", "\n" );
self.__filecache[ _file ] = string.gsub( self.__filecache[ _file ] || "", "\n\r", "\n" );
self.__filecache[ _file ] = string.Explode( "\n", self.__filecache[ _file ] );
_cache = self.__filecache[ _file ];
end
local _output = "";
if ( _last_line - _start_line > 0 ) then
for i = _start_line, _last_line do
_output = _output .. ( _cache[ i ] || "" ) .. "\n";
end
end
return _output;
end
end
[/code]
-snip-
How can I remove the "player killed player with weapon" and the connect/disconnect messages?
I can't get bullet.Spread to work in my weapon. It's been bothering me for a while, and I've looked for help where I could. It's still not working, which is why I've come here, which is now my last resort. What could cause bullet.Spread not to work? I've made sure that I have it written correctly, and I've debugged it to reveal that bullet.Spread is not 0 when the gun fires.
[lua] local bullet = {}
bullet.Num = self.Primary.ShotCount
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = VectorToUse
bullet.Spread = 0.1 -- Doesn't seem to work?..
----------------------------------------------------------------------------------------------
print( bullet.Spread )
self.Owner:FireBullets( bullet )[/lua]
Console:
[code]Giving Blood Lord™ a cx_pwbase
Blood Lord™ Firing Index 40
Spread To Use: 0.010222830818481
Spread Before: 0.1
Spread (shot): 0.1
PAO: -1.0774908545265
Recoil Base: 1.4255086990989
Recoil Scalar: 0.06435[/code]
Firing Index = weapon's EntIndex
Spread To Use was what I used to use for spread... but for testing, I just forced it to 0.1
The rest is just print lines I have other places in the document.
[editline]22nd December 2014[/editline]
I used the line to replace the rest of the bullet parameters, like bullet.Damage, bullet.Callback, etc.
[QUOTE=Author.;46770371]How can I remove the "player killed player with weapon" and the connect/disconnect messages?[/QUOTE]
I'm not sure about the connect/disconnect messages but I think [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/HUDShouldDraw]GM/HUDShouldDraw[/url] is what you're looking for to hide the kill messages in the top right?
To remove the kill icons in the top right you use GM/DrawDeathNotice.
I need help on how to add or edit ranks that can access the pointshop admin tab. So in the config file it's really straight forward.
[CODE]PS.Config.HeadAdminCanAccessAdminTab = true -- Head Admin rank
PS.Config.SuperAdminCanAccessAdminTab = true -- Super Admin rank[/CODE]
Before of course, it was just Admin/SuperAdmin. It's just my guess but I think it's impossible to use spaces, as the script does not agree with that and I can't find anyway to fix that.
So that's in the config. Now for the actual access part.
[CODE]if (PS.Config.AdminCanAccessAdminTab and LocalPlayer():IsAdmin()) or (PS.Config.SuperAdminCanAccessAdminTab and LocalPlayer():IsSuperAdmin()) then[/CODE]
I removed the HeadAdmin part from where you see AdminCanAccessAdminTab. The one with just admin is the default, and superadmin is also default.
Any time I try to change these strings, the menu completely explodes and refuses to work. Just by simply adding Head infront of the part that says Admin. Now obviously I'm doing this because the top rank is HeadAdmin, and the one below that is SuperAdmin. Now you may be wondering "well I mean you could just rename your top rank to superadmin, I don't see the issue"
You're completely right, but you know it's one of those OCD things because right now i'd like it if the owner rank can access the pointshop admin tab. Anyone know anything about this?
[QUOTE=Acecool;46769095]Take a look at my dev base... More specifically these few files. Combined, they'll let you print pretty much anything out in print, and even concatenate them too..
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/core/ext_string.lua[/url]
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/_definitions/__metatables.lua?at=master[/url]
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/_definitions/__metatables__tostring.lua?at=master[/url]
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/core/toprint.lua?at=master[/url]
[url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/core/print.lua?at=master[/url]
Or download as addon: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/addons/acecooldev_printall_addon.rar[/url]
Hopefully this helps...
Alright, with the damage... Aren't you supposed to return the dmginfo??? I can't recall but I think I've seen people doing that.
[/quote]
Yeah that's one thing I forgot, I included it back in.
It doesn't work still. It's not printing or anything still.
[editline]22nd December 2014[/editline]
Ok did some testing, what's really fucking weird is that if I add another ScalePlayerDamage hook it actually runs my print("anus") hook but not the one that was recently added. I reloaded gmod and the hook stopped working completely. The hooks seems to be broken completely or something; I put print("WHY") in the base gamemode file for ScalePlayerDamage and it doesn't even print "WHY".
but when I run hook.Call( "ScalePlayerDamage", nil , {Entity(1),HITGROUP_HEAD,DamageInfo()} ) it prints anus and gives me an error about my fake DamageInfo()
[editline]22nd December 2014[/editline]
w/e got it working using the PlayerShouldTakeDamage hook (even though I wanted to reflect damage) but this is a pretty big issue because I want to know if it's one of my scripts that are causing this, I'll have to keep checking script by script and see which is the culprit
[editline]22nd December 2014[/editline]
Ok I don't know what I'm doing wrong, but it only likes to use one ScalePlayerDamage.
I don't know if it's supposed to use one but I would be pretty sad if that was the case.
So I have two addons, one that detects headshots and one that detects friendly fire. They both need to use the hook ScalePlayerDamage but it looks like only one of the same hook can run at a time or my coding is fucked up
So as of now
This function
[lua]
function DetectHeadshots(ply, hitgroup, dmginfo)
if hitgroup == HITGROUP_HEAD then
ply:EmitSound("player/headshot"..math.random(1,2)..".wav",SNDLVL_TALKING,100,1,CHAN_BODY)
end
ply:SetColor(Color(255,0,0,255))
dmginfo:GetAttacker():ChatPrint("monster")
print("WHAT THE HELL")
return dmginfo
end
hook.Add("ScalePlayerDamage","CSS Detect Headshots",DetectHeadshots)
[/lua]
overrides this function
[lua]
function TeamDamageMod(victim,hitgroup,dmginfo)
print("anus")
--local victim = ply
local attacker = dmginfo:GetAttacker()
print(victim:Team())
print(attacker:Team())
if victim:Team() == attacker:Team() and victim:Team() ~= 1001 then
dmginfo:ScaleDamage(0)
end
return dmginfo
end
hook.Add("ScalePlayerDamage","Team Damage Mod", TeamDamageMod )
[/lua]
I want them both to work at the same time but in separate lua files, is that even possible or is that a limitation (because this limitation is HUGE)
[editline]22nd December 2014[/editline]
Ok found out what the problem was
[B]You're not supposed to return dmginfo...[/B]
that just tells all other ScalePlayerDamage hooks to go fuck themselves and not run
Ok I need help with textures/andor lua
[lua]cam.Start3D(EyePos(),EyeAngles() + Angle(0,0,0) )
render.SetMaterial( mat )
render.DrawSphere( self.detail3:GetPos(), self.EffectRadius, 32, 32, Color(255,255,255,55) )
render.DrawSphere( self.detail3:GetPos(), -self.EffectRadius, 32, 32, Color(255,255,255,55) )
cam.End3D()[/lua]
I have this in my draw function, the mat is called elsewhere.
The result of this is unwanted...
... This picture is fine , the sphere draws like it should ...
[t]http://i.imgur.com/TWJ2Hri.jpg[/t]
... but this picture draws like it shouldn't. I'm wondering if there is something I could do to make the texture behind it not override like that.
[t]http://i.imgur.com/I4p5ptv.jpg[/t]
What hook are you using?
okay so this is a really stupid question but I can't find any tutorials on it:
how do I make a derma panel show up on using an entity? as the code for that would go in cl_init.lua but I can't do ENT:Use() definitions in cl_init.lua.
[QUOTE=Exho;46775216]What hook are you using?[/QUOTE]
Draw
[editline]22nd December 2014[/editline]
Actually it looks like it might be because I'm using self:SetRenderBounds( Vector(-1,-1,-1)*200, Vector(1,1,1)*200) but I need that in order to draw properly in the first place
If the object isn't in sight the sphere is told not to draw.
How can i making collision box tracer?
i tried made entity collision box or traceHull
but all fucck not rotating...
so uploaded image
thus
[img]http://s12.postimg.org/kginvh7t9/2014_12_23_00001.jpg[/img]
I want to find a player(entities) is rotated in the box
any oneeeee help?
Is there even a reliable way of having vphysics and setmodelscale work together? Entities i jump on flings me away.
Is there anyway to get a list of player classes from the player manager? Or at least a way to check if a player class is valid?
[QUOTE=Sparky-Z;46776303]Is there anyway to get a list of player classes from the player manager? Or at least a way to check if a player class is valid?[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/player_manager/GetPlayerClass]player_manager.GetPlayerClass[/url]
?
[QUOTE=Revenge282;46776333][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/player_manager/GetPlayerClass]player_manager.GetPlayerClass[/url]
?[/QUOTE]
Well, I need a list of the valid classes. Not just a specific player's class. Thanks though.
EDIT:
Also if I could somehow extend the player_manager module that would work too. I just need access to its list of player classes.
[QUOTE=Sparky-Z;46776348]Well, I need a list of the valid classes. Not just a specific player's class. Thanks though.
EDIT:
Also if I could somehow extend the player_manager module that would work too. I just need access to its list of player classes.[/QUOTE]
All that function really is is just this:
[lua]function player_manager.GetPlayerClass( ply )
local id = ply:GetClassID()
if ( id == 0 ) then return end
return util.NetworkIDToString( id )
end[/lua]
So if you use that then probably figure out a number of classes and create a table of them from there. If not, you might want to just hook into RegisterClass and then have it add to a table each time its called.
[QUOTE=Revenge282;46776462]
So if you use that then probably figure out a number of classes and create a table of them from there. If not, [B]you might want to just hook into RegisterClass and then have it add to a table each time its called.[/B][/QUOTE]
Thanks! That's exactly what I needed.
[lua]
local ClassList = {}
local oldRegister = player_manager.RegisterClass
function player_manager.RegisterClass( name, tab, base )
oldRegister(name, tab, base)
table.insert(ClassList, name)
end
function player_manager.GetClassList()
return ClassList
end
[/lua]
Trying to get a DColorMixer to change the playermodel's color but it doesn't seem to want to do it. It GETS the color without issues but it won't SET it.
[lua]
local Mixer = vgui.Create( "DColorMixer", TabTwo )
Mixer:SetPos(10,20)
Mixer:SetSize( 267,186 )
Mixer:SetPalette( true )
Mixer:SetAlphaBar( true )
Mixer:SetWangs( true )
local clr = LocalPlayer():GetPlayerColor()
local rrr = clr.x * 255
local ggg = clr.y * 255
local bbb = clr.z * 255
Mixer:SetColor( Color(rrr,ggg,bbb,255) )
function Mixer:ValueChanged(col)
local rr = col.r / 255
local gg = col.g / 255
local bb = col.b / 255
LocalPlayer():SetPlayerColor(Vector(rr,gg,bb))
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.