How do i check if a player is visible on my screen, I have tried Entity:Visible(ent) but it just throws me an error saying [ERROR] lua/modmenu.lua:471: attempt to call method 'Visible' (a nil value)
EDIT: Never mind i found why this does not work, it is server sided code XD
[QUOTE=Robotboy655;49095657]Make sure you are up to date, that was already fixed.[/QUOTE]
As of right now, the issue still stands. Vehicle entities are returning null, even in the OnEntityCreated hook, which is where I previously setup datatables. I can no longer do that now since IsValid returns false on a vehicle.
Does anyone know the name of the table where DarkRP warrants/wanteds are stored? I cannot find it.
[QUOTE=McSniper12;49137218]Does anyone know the name of the table where DarkRP warrants/wanteds are stored? I cannot find it.[/QUOTE]
Theres no table.
There are functions:
[URL="http://wiki.darkrp.com/index.php/Functions/Player/Shared/isWanted"]Player:IsWanted[/URL]
[QUOTE=Revenge282;49136622]As of right now, the issue still stands. Vehicle entities are returning null, even in the OnEntityCreated hook, which is where I previously setup datatables. I can no longer do that now since IsValid returns false on a vehicle.[/QUOTE]
What vehicles are you trying to use? Classnames, addon names, etc.
Why dosen't render.MaterialOverrideByIndex force Material override when Bonemerging?
[code]
hook.Add("PostDrawOpaqueRenderables","testMaterialOverride",function()
if not IsValid(ViewTestingModel) or not IsValid(ViewTestingModelParent) then // Setup Viewmodel
SafeRemoveEntity(ViewTestingModel)
SafeRemoveEntity(ViewTestingModelParent)
ViewTestingModel = ClientsideModel("models/weapons/cstrike/c_rif_sg552.mdl")
ViewTestingModel:SetPos(Entity(1):GetShootPos())
ViewTestingModel:SetNoDraw(true)
ViewTestingModelParent = ClientsideModel("models/weapons/c_arms_chell.mdl")
ViewTestingModelParent:SetPos(Entity(1):GetShootPos())
ViewTestingModelParent:SetNoDraw(true)
ViewTestingModelParent:SetSequence(2)
ViewTestingModelParent:SetCycle(1)
-- Apply Bonemerging
ViewTestingModel:SetParent(ViewTestingModelParent)
ViewTestingModel:AddEffects(EF_BONEMERGE)
end
ViewTestingModelParent:SetRenderAngles(AngleRand()*0.01)
-- ViewTestingModel:RemoveEffects(EF_BONEMERGE)
-- use to remove bonemerge, and see the material!
ViewTestingModelParent:DrawModel()
render.MaterialOverrideByIndex(1,Material("models/props_forest/sawmill_logs")) -- apply SubMaterial
ViewTestingModel:DrawModel() -- Shows default Material
end)
[/code]
While Bonemerge is active, the Material is not getting drawn.
But after the Bonemerge effect is removed, it is drawn.
Any ideas?
Best way of getting x and y coordinates of a player's death?
[QUOTE=McSniper12;49141072]Best way of getting x and y coordinates of a player's death?[/QUOTE]
Probably
[CODE]
hook.Add( 'PlayerDeath', 'GetXandY', function( victim, inflictor, attacker )
local pos = victim:GetPos()
local x, y = pos.x, pos.y
end
[/CODE]
Now for another question-is there a way to rotate any type of panel, e.g. DFrames?
[QUOTE=Robotboy655;49138973]What vehicles are you trying to use? Classnames, addon names, etc.[/QUOTE]
TDM and LoneWolfies are the only addons that have anything to do with the vehicles. The others are just EPOE, dbugr, etc.
Function creating the vehicle:
[lua]function SetupVehicle(veh,pos,ang)
print("SetupVehicle","Step in")
if !VEHICLE_DATABASE[veh] then return false end
print("SetupVehicle","Vehicle exists")
local m = VEHICLE_DATABASE[veh].PaintJobs[1].model
local s = VEHICLE_DATABASE[veh].Script
local c = ents.Create('prop_vehicle_jeep')
print(m,s,c,veh,pos,ang)
c:SetModel(m)
c:SetKeyValue('vehiclescript','scripts/vehicles/'..s..'.txt')
c:PhysicsInit(SOLID_VPHYSICS)
c:SetUseType(SIMPLE_USE)
c:SetPos(pos)
c:SetAngles(ang)
c:Spawn()
c:Fire('lock','',0)
return c
end[/lua]
Print output of above function:
[code]SetupVehicle Step in
SetupVehicle Vehicle exists
OEC Vehicle [NULL]
models/tdmcars/hon_civic97.mdl civic Vehicle [NULL] civic -5128.467285 -13398.031250 82.992577 0.000 0.000 0.000[/code]
The third line (OEC ...) is from this function:
[lua]local function SetupVehicleDataTables(veh)
print("OEC",veh)
if IsValid(veh) and veh:IsVehicle() then
print("Install DT")
veh:InstallDataTable()
veh.SetupDataTables = function()
print("Setup DT")
veh:NetworkVar("Bool",0,"Stolen")
veh:NetworkVar("Entity",0,"CarOwner")
veh:NetworkVar("String",0,"LicensePlate")
veh:NetworkVar("Int",0,"VehicleHealth")
veh:NetworkVar("Bool",0,"Disabled")
end
veh:SetupDataTables()
end
end
hook.Add("OnEntityCreated","SetupVehicleDataTables",SetupVehicleDataTables)[/lua]
[editline]18th November 2015[/editline]
The scripts, models, etc are all existing and valid, I should add. As well as this all working some time before the latest dev branch update that included the CreateParticleSystem functionalities.
I was wondering how would you make a custom lua animation?
is it by manipulating the bones?
And if you know any good example, it would be really awesome if you could link me it, thanks!
[QUOTE=Revenge282;49141379]TDM and LoneWolfies are the only addons that have anything to do with the vehicles. The others are just EPOE, dbugr, etc.
Function creating the vehicle:
[lua]function SetupVehicle(veh,pos,ang)
print("SetupVehicle","Step in")
if !VEHICLE_DATABASE[veh] then return false end
print("SetupVehicle","Vehicle exists")
local m = VEHICLE_DATABASE[veh].PaintJobs[1].model
local s = VEHICLE_DATABASE[veh].Script
local c = ents.Create('prop_vehicle_jeep')
print(m,s,c,veh,pos,ang)
c:SetModel(m)
c:SetKeyValue('vehiclescript','scripts/vehicles/'..s..'.txt')
c:PhysicsInit(SOLID_VPHYSICS)
c:SetUseType(SIMPLE_USE)
c:SetPos(pos)
c:SetAngles(ang)
c:Spawn()
c:Fire('lock','',0)
return c
end[/lua]
Print output of above function:
[code]SetupVehicle Step in
SetupVehicle Vehicle exists
OEC Vehicle [NULL]
models/tdmcars/hon_civic97.mdl civic Vehicle [NULL] civic -5128.467285 -13398.031250 82.992577 0.000 0.000 0.000[/code]
The third line (OEC ...) is from this function:
[lua]local function SetupVehicleDataTables(veh)
print("OEC",veh)
if IsValid(veh) and veh:IsVehicle() then
print("Install DT")
veh:InstallDataTable()
veh.SetupDataTables = function()
print("Setup DT")
veh:NetworkVar("Bool",0,"Stolen")
veh:NetworkVar("Entity",0,"CarOwner")
veh:NetworkVar("String",0,"LicensePlate")
veh:NetworkVar("Int",0,"VehicleHealth")
veh:NetworkVar("Bool",0,"Disabled")
end
veh:SetupDataTables()
end
end
hook.Add("OnEntityCreated","SetupVehicleDataTables",SetupVehicleDataTables)[/lua]
[editline]18th November 2015[/editline]
The scripts, models, etc are all existing and valid, I should add. As well as this all working some time before the latest dev branch update that included the CreateParticleSystem functionalities.[/QUOTE]
Ok, so it's a different problem, as it turns out, all vehicles are not vehicles until Spawn is called on them.
This is a problem because if I change IsValid back, it will return true if the vehicle object is invalid, and if you try to call any vehicle functions on such invalid vehicle, you will get a crash. ( Which is why it was changed in the first place )
[QUOTE=Robotboy655;49145329]Ok, so it's a different problem, as it turns out, all vehicles are not vehicles until Spawn is called on them.
This is a problem because if I change IsValid back, it will return true if the vehicle object is invalid, and if you try to call any vehicle functions on such invalid vehicle, you will get a crash. ( Which is why it was changed in the first place )[/QUOTE]
I will spawn it first, and move all the function calls after that.
What do you recommend as far as the DTVar stuff goes? Would it be possible to have a hook for entities actually being spawned rather than created in the future? (The hook as it is right now is convenient since it's shared and the spawn function is not. But if worse comes to worse, I can make my own hook for it.)
Is there a way to determine if a player is typing in a text field i.e. the chat box?
I want to use input.IsKeyDown(SOME_KEY) but it registers the key down when the player types in text field's.
[QUOTE=King Traitor;49150538]Is there a way to determine if a player is typing in a text field i.e. the chat box?
I want to use input.IsKeyDown(SOME_KEY) but it registers the key down when the player types in text field's.[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/StartChat]GM/StartChat[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/FinishChat]GM/FinishChat[/url]
[CODE]
[ERROR] lua/vgui/dcategorycollapse.lua:214: attempt to index a nil value
1. Toggle - lua/vgui/dcategorycollapse.lua:214
2. DoClick - lua/vgui/dcategorycollapse.lua:25
3. unknown - lua/vgui/dlabel.lua:218
[ERROR] lua/vgui/dcategorycollapse.lua:214: attempt to index a nil value
1. Toggle - lua/vgui/dcategorycollapse.lua:214
2. DoClick - lua/vgui/dcategorycollapse.lua:25
3. unknown - lua/vgui/dlabel.lua:218
[ERROR] lua/vgui/dcategorycollapse.lua:214: attempt to index a nil value
1. Toggle - lua/vgui/dcategorycollapse.lua:214
2. DoClick - lua/vgui/dcategorycollapse.lua:25
3. unknown - lua/vgui/dlabel.lua:218
[ERROR] lua/vgui/dcategorycollapse.lua:214: attempt to index a nil value
1. Toggle - lua/vgui/dcategorycollapse.lua:214
2. DoClick - lua/vgui/dcategorycollapse.lua:25
3. unknown - lua/vgui/dlabel.lua:218
[/CODE]
Getting the error above. Heres a gif of what im doing to cause it and what it does ingame.
[IMG]https://i.gyazo.com/a1e2ce3529c81c7932d8ed519429cecd.gif[/IMG]
Heres the code.
[CODE]
function openHud()
local DCollapsible = vgui.Create( "DCollapsibleCategory", DermaPanel )
DCollapsible:SetPos( 950,15 )
DCollapsible:SetSize( 400, 50 ) -- Keep the second number at 50
DCollapsible:SetExpanded( 0 ) -- Expanded when popped up
DCollapsible:SetLabel( "Mission Information Panel" )
DCollapsible.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
draw.RoundedBox( 0, 0, 0, w, h, Color( 150, 150, 150, 150 ) ) -- Draw a red box instead of the frame
end
local DermaList = vgui.Create( "DPanelList", DermaPanel ) -- Make a list of items to add to our category ( collection of controls )
DermaList:SetSpacing( 5 ) -- Set the spacing between items
DermaList:EnableHorizontal( false ) -- Only vertical items
DermaList:EnableVerticalScrollbar( true ) -- Enable the scrollbar if ( the contents are too wide
DCollapsible:SetContents( DermaList ) -- Add DPanelList to our Collapsible Category
local CategoryContentOne = vgui.Create( "DCheckBoxLabel" ) -- This section creates a checkbox and
CategoryContentOne:SetText( "God mode" )
CategoryContentOne:SetValue( 0 )
CategoryContentOne:SizeToContents()
DermaList:AddItem( CategoryContentOne ) -- Add the checkbox to the category
local CategoryContentTwo = vgui.Create( "DLabel" ) -- Make some more content
CategoryContentTwo:SetText( "Hello" )
DermaList:AddItem( CategoryContentTwo )
end
openHud()[/CODE]
Am i misunderstanding how to use this derma panel? ;-;
[QUOTE=DamienTehDemo;49153638]:snip:[/QUOTE]
Can you comment line 214?
That one is giving the error
How would I do that dead npcs are getting removed after like 5 seconds?
[QUOTE=DamienTehDemo;49153638][CODE]
[ERROR] lua/vgui/dcategorycollapse.lua:214: attempt to index a nil value
1. Toggle - lua/vgui/dcategorycollapse.lua:214
2. DoClick - lua/vgui/dcategorycollapse.lua:25
3. unknown - lua/vgui/dlabel.lua:218
[ERROR] lua/vgui/dcategorycollapse.lua:214: attempt to index a nil value
1. Toggle - lua/vgui/dcategorycollapse.lua:214
2. DoClick - lua/vgui/dcategorycollapse.lua:25
3. unknown - lua/vgui/dlabel.lua:218
[ERROR] lua/vgui/dcategorycollapse.lua:214: attempt to index a nil value
1. Toggle - lua/vgui/dcategorycollapse.lua:214
2. DoClick - lua/vgui/dcategorycollapse.lua:25
3. unknown - lua/vgui/dlabel.lua:218
[ERROR] lua/vgui/dcategorycollapse.lua:214: attempt to index a nil value
1. Toggle - lua/vgui/dcategorycollapse.lua:214
2. DoClick - lua/vgui/dcategorycollapse.lua:25
3. unknown - lua/vgui/dlabel.lua:218
[/CODE]
Getting the error above. Heres a gif of what im doing to cause it and what it does ingame.
[IMG]https://i.gyazo.com/a1e2ce3529c81c7932d8ed519429cecd.gif[/IMG]
Heres the code.
[CODE]
function openHud()
local DCollapsible = vgui.Create( "DCollapsibleCategory", DermaPanel )
DCollapsible:SetPos( 950,15 )
DCollapsible:SetSize( 400, 50 ) -- Keep the second number at 50
DCollapsible:SetExpanded( 0 ) -- Expanded when popped up
DCollapsible:SetLabel( "Mission Information Panel" )
DCollapsible.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
draw.RoundedBox( 0, 0, 0, w, h, Color( 150, 150, 150, 150 ) ) -- Draw a red box instead of the frame
end
local DermaList = vgui.Create( "DPanelList", DermaPanel ) -- Make a list of items to add to our category ( collection of controls )
DermaList:SetSpacing( 5 ) -- Set the spacing between items
DermaList:EnableHorizontal( false ) -- Only vertical items
DermaList:EnableVerticalScrollbar( true ) -- Enable the scrollbar if ( the contents are too wide
DCollapsible:SetContents( DermaList ) -- Add DPanelList to our Collapsible Category
local CategoryContentOne = vgui.Create( "DCheckBoxLabel" ) -- This section creates a checkbox and
CategoryContentOne:SetText( "God mode" )
CategoryContentOne:SetValue( 0 )
CategoryContentOne:SizeToContents()
DermaList:AddItem( CategoryContentOne ) -- Add the checkbox to the category
local CategoryContentTwo = vgui.Create( "DLabel" ) -- Make some more content
CategoryContentTwo:SetText( "Hello" )
DermaList:AddItem( CategoryContentTwo )
end
openHud()[/CODE]
[/quote]
Didn't test :
[CODE]
function openHud()
local DCollapsible = vgui.Create( "DCollapsibleCategory" )
DCollapsible:SetPos( 950,15 )
DCollapsible:SetSize( 400, 50 ) -- Keep the second number at 50
DCollapsible:SetExpanded( 0 ) -- Expanded when popped up
DCollapsible:SetLabel( "Mission Information Panel" )
DCollapsible.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
draw.RoundedBox( 0, 0, 0, w, h, Color( 150, 150, 150, 150 ) ) -- Draw a red box instead of the frame
end
local DermaList = vgui.Create( "DPanelList", DCollapsible ) -- Make a list of items to add to our category ( collection of controls )
DermaList:SetSpacing( 5 ) -- Set the spacing between items
DermaList:EnableHorizontal( false ) -- Only vertical items
DermaList:EnableVerticalScrollbar( true ) -- Enable the scrollbar if ( the contents are too wide
DCollapsible:SetContents( DermaList ) -- Add DPanelList to our Collapsible Category
local CategoryContentOne = vgui.Create( "DCheckBoxLabel", DCollapsible ) -- This section creates a checkbox and
CategoryContentOne:SetText( "God mode" )
CategoryContentOne:SetValue( 0 )
CategoryContentOne:SizeToContents()
DermaList:AddItem( CategoryContentOne ) -- Add the checkbox to the category
local CategoryContentTwo = vgui.Create( "DLabel", DCollapsible ) -- Make some more content
CategoryContentTwo:SetText( "Hello" )
DermaList:AddItem( CategoryContentTwo )
end
openHud()[/CODE]
The second argument of vgui.Create is where the vgui element is going to be located. (I what element it will be)
[QUOTE=P4sca1;49154807]How would I do that dead npcs are getting removed after like 5 seconds?[/QUOTE]
[url]https://facepunch.com/showthread.php?t=1073876[/url]
How do I make a chat command output a console command or a function?
I want it when a user types "!credits" it opens a Derma panel with a list of contributing users.
[QUOTE=SkellyR;49156755]How do I make a chat command output a console command or a function?
I want it when a user types "!credits" it opens a Derma panel with a list of contributing users.[/QUOTE]
Use [url=http://wiki.garrysmod.com/page/GM/OnPlayerChat]GM/OnPlayerChat[/url] and [URL="https://wiki.garrysmod.com/page/Category:DFrame"]Panels/DFrame[/URL]- e.g.
[CODE]
hook.Add( 'OnPlayerChat', 'OpenCreditsPanel', function( ply, text, teamchat, dead )
if text == "!credits" and ply == LocalPlayer() then
local panel = vgui.Create( 'DFrame' )
panel:SetSize( ScrW() - 500, ScrH() - 500 )
panel:Center()
panel:MakePopup()
-- Just use a couple of DLabels or something here for the names
end
end )
[/CODE]
I'm trying to get a bunch of entities with FindInSphere including some vehicles, is there any way I could filter out stuff like wheels and only select the main part of the car? I tried getting the parent of each entity if it passed ent:IsVehicle but that didn't seem to work.
[QUOTE=YourStalker;49158319]I'm trying to get a bunch of entities with FindInSphere including some vehicles, is there any way I could filter out stuff like wheels and only select the main part of the car? I tried getting the parent of each entity if it passed ent:IsVehicle but that didn't seem to work.[/QUOTE]
Get the vehicles in the sphere, then for each vehicle, check the location of their bones/attachements, and see if the distance from the position of the bone/attachment to the center of your FindInSphere is less than the distance you used?
[QUOTE=MPan1;49157144]Use [url=http://wiki.garrysmod.com/page/GM/OnPlayerChat]GM/OnPlayerChat[/url] and [URL="https://wiki.garrysmod.com/page/Category:DFrame"]Panels/DFrame[/URL]- e.g.
[CODE]
hook.Add( 'OnPlayerChat', 'OpenCreditsPanel', function( ply, text, teamchat, dead )
if text == "!credits" then
local panel = vgui.Create( 'DFrame' )
panel:SetSize( ScrW() - 500, ScrH() - 500 )
panel:Center()
panel:MakePopup()
-- Just use a couple of DLabels or something here for the names
end
end )
[/CODE][/QUOTE]
That would open for everyone at once
[QUOTE=Coffeee;49158942]That would open for everyone at once[/QUOTE]
OnPlayerChat is a clientside hook?
[QUOTE=MPan1;49160958]OnPlayerChat is a clientside hook?[/QUOTE]
Yes, but it's called whenever someone types. You need to check if it's local player who types it.
[DEL]I'm trying to port code of grenades from Realistic CSS Weapons back from GMod 11. The problem is, when I throw the grenade, it goes to where it should and then drops to one position nowhere near it and then it flips out.
Weapon: [URL]http://hastebin.com/avemecevis.lua[/URL]
Entity: [URL]http://hastebin.com/cakisuloto.lua[/URL]
[sp]Ignore easylua lines, they're for testing on server without uploading[/sp]
UPDATE: I dunno what's wrong with the entity since the flashbang one works perfect[/DEL]
UPDATE 2: Fixed, put init function into a server only if.
How does one go about creating a tool?
[QUOTE=zippy36jr;49162780]How does one go about creating a tool?[/QUOTE]
Old tutorial but [url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexa2e7.html[/url]
So im trying to get prop count based on rank since i use URS and i have this line of code but it is giving me an error.
Code:
[CODE]local ply = LocalPlayer()
local limit = URS.limits["prop"][ply:GetUserGroup()][/CODE]
Error:
[CODE]
[ERROR] RunString:4: attempt to index field 'prop' (a nil value)
[/CODE]
Where i got this from: [URL="https://github.com/Aaron113/urs/blob/master/lua/ulx/modules/urs_server.lua#L80"]https://github.com/Aaron113/urs/blob/master/lua/ulx/modules/urs_server.lua#L80[/URL]
Sorry, you need to Log In to post a reply to this thread.