[QUOTE=Insomnia Array;38801673]I've googled around for a while and couldn't find how to get a material or a texture of an HTML panel? Anyone know how to?
Or for that matter, does anyone know how else can I draw an HTML page in 3D space?[/QUOTE]
[b]1#[/b]
[b][url=http://wiki.garrysmod.com/index.php?title=Classes/Panel/GetHTMLMaterial]GetHTMLMaterial[img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[b]2#[/b]
[url=http://wiki.garrysmod.com/page/cam]cam[/url].
[b][url=http://wiki.garrysmod.com/page/Libraries/cam/Start3D2D]Start3D2D[img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[lua]-- Your panel between.[/lua]
[b][url=http://wiki.garrysmod.com/page/Libraries/cam/End3D2D]End3D2D[img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
Hey guys, so the purpose of this script is to alter the salary a player gains depending on their rank. So for example, VIPs should earn 25% extra (hence, * 1.25).
[b]The Default DarkRP Code[/b]
[lua]function meta:PayDay()
if not IsValid(self) then return end
if not self:isArrested() then
DB.RetrieveSalary(self, function(amount)
amount = math.floor(amount or GAMEMODE.Config.normalsalary)
hook.Call("PlayerGetSalary", GAMEMODE, self, amount)
if amount == 0 or not amount then
GAMEMODE:Notify(self, 4, 4, LANGUAGE.payday_unemployed)
else
self:AddMoney(amount)
GAMEMODE:Notify(self, 4, 4, string.format(LANGUAGE.payday_message, CUR .. amount))
end
end)
else
GAMEMODE:Notify(self, 4, 4, LANGUAGE.payday_missed)
end
end[/lua]
[b] I tried implementing this, however it refuses to work[/b]
[lua]if self.Player:IsUserGroup("vip") then
amount = math.floor(amount)*1.25
elseif self.Player:IsUserGroup("superadmin") then
amount = math.floor(amount)*2
elseif self.Player:IsUserGroup("guest") then
amount = math.floor(amount)*1[/lua]
Can anybody help me get a fix for this? Struggled for a while now and anything I try breaks the payday system completely.
Massive thanks in advance
[QUOTE=MICKMAC;38802006]
[b] I tried implementing this, however it refuses to work[/b]
[lua]if self.Player:IsUserGroup("vip") then
amount = math.floor(amount)*1.25
elseif self.Player:IsUserGroup("superadmin") then
amount = math.floor(amount)*2
elseif self.Player:IsUserGroup("guest") then
amount = math.floor(amount)*1[/lua][/QUOTE]
Remove the
[lua].Player[/lua]
from
[lua]self.Player[/lua]
and add an
[lua]end[/lua]
at the bottom, then try again.
[editline]:[/editline]
[lua]
if self:IsUserGroup("vip") then
amount = math.floor(amount)*1.25
elseif self:IsUserGroup("superadmin") then
amount = math.floor(amount)*2
elseif self:IsUserGroup("guest") then
amount = math.floor(amount)*1
end[/lua]
[QUOTE=TheTrueAndy;38802005][b]1#[/b]
[b][url=http://wiki.garrysmod.com/index.php?title=Classes/Panel/GetHTMLMaterial]GetHTMLMaterial[img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[/QUOTE]
Wasn't that removed?
-snip-
[QUOTE=Drakehawke;38802161]Wasn't that removed?[/QUOTE]
It sits there in the panel metatable but always returns nil, on both HTML and DHTML panels. That's the problem with it, otherwise I wouldn't be asking.
The base hook (GM:AllowPlayerPickup) only works for prop_physics entity but not for my prop_garbage entity (not sure why). The reason I am doing this pseudo prop_physics is because I am making this entity mapper-friendly for a gamemode that was made 2 years ago (I am recoding this from scratch, really messy and all). However, that prop will be always unfrozen and grabbable by the player but the hook does nothing and outputs nothing with custom based entities.
I will thank you if you find the reason why.
init.lua
[LUA]
AddCSLuaFile("shared.lua")
AddCSLuaFile("cl_init.lua")
include("shared.lua")
function ENT:Initialize()
local rdmtbl = table.Random(GAMEMODE.Garbage)
self:SetModel(rdmtbl.Model)
self:PhysicsInit(SOLID_VPHYSICS)
--self:SetUseType(SIMPLE_USE)
util.SpriteTrail(self, 0, Color(255, 255, 255, 255), false, 15, 1, 4, 1 / (15 + 1) * .5, "trails/laser.vmt")
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:SetMass(10)
phys:EnableMotion(true)
phys:Wake()
end
self:SetPointValue(rdmtbl.Points)
end
[/LUA]
shared.lua
[LUA]
ENT.Type = "anim"
ENT.RenderGroup = RENDERGROUP_BOTH
ENT.m_IsGarbage = true
function ENT:SetPointValue(points)
self:SetDTInt(0, points)
end
[/LUA]
cl_init.lua
[LUA]
include("shared.lua")
function ENT:Draw()
self:DrawModel()
end
[/LUA]
How would you resize a player now that SetModelScale no longer works?
EnableMatrix is nil when accessing through a player.
code snippet which doesn't work because of EnableMatrix being nil
[LUA]
pl:SetHull( Vector( -16 * x, -16 * y, 0 ), Vector( 16 * x, 16 * y, 72 * z ) )
pl:SetHullDuck( Vector( -16 * x, -16 * y, 0 ), Vector( 16 * x, 16 * y, 36 * z ) )
pl:SetViewOffset( Vector( 0, 0, 68 * z ) )
pl:SetViewOffsetDucked( Vector( 0, 0, 32 * z ) )
pl:SetStepSize( z * 16 ) -- Best Guess, anyone?
pl:SetCollisionBounds( Vector( -16 * x, -16 * y, 0 ), Vector( 16 * x, 16 * y, 72 * z ) )
pl:SetWalkSpeed( 50 * ( x + y + z ) * 0.33 + 200 )
pl:SetRunSpeed( 100 * ( x + y + z ) * 0.33 + 400 )
pl:SetJumpPower( 160 * z )
--pl:SetGravity( 1 / z )
local mat = Matrix()
mat:Scale(size)
pl:EnableMatrix("RenderMultiple", mat)
[/LUA]
[QUOTE=Donkie;38800974]Post the cl_wanted file on pastebin and link, we need code![/QUOTE]
[url]http://pastebin.com/4kyv2LJv[/url]
and here is the error message again
[lua]
[ERROR] addons/wanted/lua/autorun/client/cl_wanted.lua:207: attempt to call method 'EnableHorizontal' (a nil value)
1. Function - addons/wanted/lua/autorun/client/cl_wanted.lua:207
2. unknown - lua/includes/modules/usermessage.lua:87
[/lua]
How can I make a SENT that i've created into another entity?
I want this for the convenience of having the class names on the SENT and the hooks inside the SENT.
Ex:
[lua]
function ENT:Initialize()
self = ents.Create("prop_vehicle_jeep")
end
[/lua]
Is there any way to get the clip size of a weapon?
I implemented one way but it only works with SWEPs.
Is there any easy way to get the player typing a console command from inside the console command's auto-complete function?
I need the auto-complete options to be dependant upon the player who is about to call the console command, and I can't see how I'd get the player before they've called the console command.
[QUOTE=Fatman55;38809238]Is there any way to get the clip size of a weapon?
I implemented one way but it only works with SWEPs.[/QUOTE]
GetActiveWeapon():Clip1()
[B]Example[/B]
local Ammo = LocalPlayer():GetActiveWeapon():Clip1()
Ammo will be given the value of the weapon's first clip say something like in the .357 it would be 6
I'm trying to get player nick clientside. But every time i run
LocalPlayer():Nick() i get a nil value, any way i could get it?
[QUOTE=McDunkable;38809577]GetActiveWeapon():Clip1()
[B]Example[/B]
local Ammo = LocalPlayer():GetActiveWeapon():Clip1()
Ammo will be given the value of the weapon's first clip say something like in the .357 it would be 6[/QUOTE]
Yeah but that doesn't give the size of it, just the amount in the current clip.
Hello,
For my addon, I'm trying to set a global on button press, but it's 0 when I have the SWEP made, even if it's set on that button press. I also store an npc in the array, and need the button's text to change to what I stored. For some reason, it's not working. Here's my testing button (autorun):
[CODE]
if CLIENT then
button = vgui.Create("DButton")
button:SetParent(Panel)
button:SetPos(25, 50)
button:SetSize( 100, 30)
--net.Receive("gotcha!", function () button:SetText("Pokeball " .. net.ReadString()) end)
if not pokemoncaught[1] then
button:SetText("Empty Pokeball 1")
button.DoClick = function()
net.Start("pokeball_give")
net.SendToServer()
buttons = 1
end
elseif pokemoncaught[1] then
net.Start("give_monster")
net.SendToServer()
buttons = 1
button:SetText(pokemoncaught[1]:GetClass())
end[/CODE]
else
...
end
Trying to make my own version of ULX asay in a DarkRP server, because the ulx chat commands sometimes don't work.
In main.lua:
[lua]local function AdminAssistance(ply, args)
if args == "" then return "" end
local DoSay = function(text)
if text == "" then return end
for k, v in pairs(player.GetAll()) do
if v == ply:IsAdmin() or v == ply then
GAMEMODE:TalkToPerson(v, col, "(HELP) " ..ply:Nick(), Color(255, 0, 0,255), text, ply)
end
end
end
return args, DoSay
end
AddChatCommand("/adminassist", AdminAssistance)[/lua]
Can't get it to work.
Is there any default lua command that applies like the ent_fire !picker does (ex: where you looking at prop/entity/player etc.)?
[QUOTE=Fatman55;38810070]Yeah but that doesn't give the size of it, just the amount in the current clip.[/QUOTE]
player:GetAmmoCount( weapon:GetPrimaryAmmoType() )
?
[QUOTE=Cobra Bukkake;38810759]Trying to make my own version of ULX asay in a DarkRP server, because the ulx chat commands sometimes don't work.
Can't get it to work.[/QUOTE]
[lua]local function AdminAssistance(ply, args)
if args == "" then return "" end
for k, v in pairs(player.GetAll()) do
if v:IsAdmin() or v == ply then
GAMEMODE:TalkToPerson(v, team.GetColor( ply:Team() ), "(HELP) " ..ply:Nick(), Color(255, 0, 0,255), args, ply)
end
end
return ""
end
AddChatCommand("/adminassist", AdminAssistance)[/lua]
[QUOTE=uberpwns;27266000][lua]
hook.Add("PlayerSpawn", "SomeUniqueName", function(ply)
if ply:Team() == TEAM_CP then
ply:SetArmor( 15 )
elseif ply:Team() == TEAM_CHIEF then
ply:SetArmor( 25 )
elseif ply:Team() == TEAM_MAYOR then
ply:SetArmor( 50 )
else
ply:SetArmor( 0 )
end
end)[/lua][/QUOTE]
Doesn't work for me. I've tried putting it in lua/autorun, lua/autorun/server, darkrp/gamemode/server
Does someone know why it isn't working?
i cant seem to get this to work with the new function GetConVarNumber any help
[CODE] --plus the 1 we're spawning right now
if ( founder:GetCount(cls) + 1 ) > server_settings.Int("sbox_max"..cv,0) then
ent:Remove()
founder:PrintMessage(HUD_PRINTCENTER, "Limit reached for ["..ename.."] !")
return false
end
[/CODE]
[CODE] --plus the 1 we're spawning right now
if ( founder:GetCount(cls) + 1 ) > GetConVarNumber("sbox_max") then
ent:Remove()
founder:PrintMessage(HUD_PRINTCENTER, "Limit reached for ["..ename.."] !")
return false
end[/CODE]
I can't check at the moment, but maybe someone knows or could tell me.
If I resource.AddFile a model, will it's related materials be included too?
It is cvars.Number(gm_your_cvar, default)
[QUOTE=_Undefined;38815096]I can't check at the moment, but maybe someone knows or could tell me.
If I resource.AddFile a model, will it's related materials be included too?[/QUOTE]
[URL="http://wiki.garrysmod.com/page/Libraries/resource/AddFile"]resource/AddFile[/URL]
On the Additional Notes
If called for vmt or mdl files, all related files will be automatically added.
I'm guessing if you add a bleh.mdl file only the models bleh.vtx bleh.skn ect would get downloaded, but not the materials.
Hey ! The error is : attempt to perform arithmetic on field 'dir' (a nil value) ( Line 8 )
[code]
view = {}
local vec = Vector( -200, -32, 400 )
local dist = 64
function CalcView( ply, origin, angles, fov )
view.origin = net.ReadEntity(npc):GetPos() + vec
view.angles = Angle(64,0,0)
view.fov = fov
view.dir = LPCameraScreenToVector( gui.MouseX(), gui.MouseY(), ScrW(), ScrH(), view.angles, math.rad( view.fov ) )
view.tr = util.QuickTrace( view.origin, view.dir * 2048 )
return view
end[/code]
LPCameraScreenToVector function.
[code]
function LPCameraScreenToVector( iScreenX, iScreenY, iScreenW, iScreenH, angCamRot, fFoV )
-- This code works by basically treating the camera like a frustrum of a pyramid.
-- We slice this frustrum at a distance "d" from the camera, where the slice will be a rectangle whose width equals the "4:3" width corresponding to the given screen height.
local d = 4 * iScreenH / ( 6 * math.tan( 0.5 * fFoV ) ) ;
-- Forward, right, and up vectors (need these to convert from local to world coordinates
local vForward = angCamRot:Forward();
local vRight = angCamRot:Right();
local vUp = angCamRot:Up();
-- Then convert vec to proper world coordinates and return it
return ( d * vForward + ( iScreenX - 0.5 * iScreenW ) * vRight + ( 0.5 * iScreenH - iScreenY ) * vUp ):Normalize();
end
[/code]
Thanks in advance.
Is gui.OpenURL working for anyone else, I'm sure I heard somewhere that he re-added it.
I run it clientside, gui.OpenURL("google.com"). Nothing appears. The function exists because it doesn't spew out any errors.
It works fine for me. Try prefixing using [url]http://www[/url]. I know https doesn't work.
[QUOTE=Disseminate;38816432]It works fine for me. Try prefixing using [URL]http://www[/URL]. I know https doesn't work.[/QUOTE]
Ahh that's why, was trying to open a paypal URL. Cheers
Very new to this, but I am trying to figure out why this is returning a nil value. I've gone through the initialization of the inventory, and followed it back to the error that is being displayed. I heard that this may be a very simple one line fix, but I haven't been able to figure out what that is.
[LUA][ERROR] ...memode/schemas/global/plugins/inventory/cl_inventory.lua:384: attempt to index field 'InventoryFrame' (a nil value)
1. closefunc - ...memode/schemas/global/plugins/inventory/cl_inventory.lua:384
2. CloseTabs - gamemodes/tiramisu/gamemode/cl_init.lua:522
3. SetActiveTab - gamemodes/tiramisu/gamemode/cl_init.lua:529
4. DoClick - gamemodes/tiramisu/gamemode/cl_binds.lua:49
5. unknown - lua/vgui/dlabel.lua:206[/LUA]
Offending Code: [url]https://github.com/kamaitama/Tiramisu/blob/master/gamemode/schemas/global/plugins/inventory/cl_inventory.lua#L383[/url]
[LUA]
function CloseInventory()
TIRA.InventoryFrame.Display = false
TIRA.InventoryFrame:SetKeyboardInputEnabled( false )
TIRA.InventoryFrame:SetMouseInputEnabled( false )
TIRA.InventoryFrame.CloseButton:SetVisible(false)
TIRA.InventoryFrame:RequestFocus()
end
[/LUA]
Sorry, you need to Log In to post a reply to this thread.