Anyone know what it is I am doing wrong for this? I even printed out all the entities and could not find it after I did this.
[lua]
hook.Add("InitPostEntity","Lights",function()
local pos = Vector(2508.289795, 690.628967, -377.235657)
local angle = Angle(0,0,0)
local ent = ents.Create("light")
ent:SetPos(pos)
ent:SetAngles(angle)
ent:Spawn()
end)
[/lua]
Any help is appreciated!
Is there a surface.GetTextureID for .pngs? I noticed surface.GetTextureID only works for vmt/vtf
Trying to run a console command by pressing a derma button, works only after editing the cl_init while the gamemode is running... Any idea why this might be?
[QUOTE=Charrax;39683685]Is there a surface.GetTextureID for .pngs? I noticed surface.GetTextureID only works for vmt/vtf[/QUOTE]
Material("someimage.png")
[LUA]for _, v in pairs(player.GetAll()) do
print (v..)
end[/LUA]
It's supposed to print every players name. But when I run it it says "Unexpected symbol near .."
Im sorry if this is stupid but I am new to lua and learning. Thanks :v:
There's no reason to put the .. there, just do print(v)
[QUOTE]It's supposed to print every players name. But when I run it it says "Unexpected symbol near .." [/QUOTE]
no need for the .. after the v in your print statement, It's looking for a second string and not finding one...
Replace the'v..' with 'v:Nick()' and should function fine
[QUOTE=.\\Shadow};39683793]There's no reason to put the .. there, just do print(v)[/QUOTE]
Thanks it works!
How would I do it with text and variables?
Hey I have a problem with my npc, in init.lua:
[lua]
function ENT:AcceptInput( name, activator)
if ( name == "Use" && IsValid( activator ) && activator:IsPlayer( ) ) then
local path = "cars/vandura/" .. activator:UniqueID() .. ".txt"
if file.Exists(path, "data") then
umsg.Start( "SavedCars", activator)
umsg.End()
else
activator:ChatPrint("You don't own any cars.")
end
end
end
[/lua]
and this all works and everything, but when its supposed to say the chatprint, it displays it in the players console not their chatbox. Any ideas?
Btw this is darkrp.
[QUOTE=ben434;39684287]Hey I have a problem with my npc, in init.lua:
and this all works and everything, but when its supposed to say the chatprint, it displays it in the players console not their chatbox. Any ideas?
Btw this is darkrp.[/QUOTE]
Are you using a custom chatbox?
[lua]
surface.SetDrawColor(255,255,255,255)
surface.SetMaterial( Material( "gui/blue/main.png" ) )
surface.DrawTexturedRect( ,sleft - 1,hudypos,260,50)
[/lua]
My material won't work. It doesn't even say I am missing the file. I am pretty sure I am downloading it.
[lua]
if (SERVER) then
AddCSLuaFile("silkicons.lua")
resource.AddFile( "materials/gui/silkicons/money.vmt" )
resource.AddFile( "materials/gui/silkicons/money.vtf" )
resource.AddFile( "materials/gui/silkicons/money_add.vmt" )
resource.AddFile( "materials/gui/silkicons/money_add.vtf" )
resource.AddFile( "materials/gui/silkicons/coins.vmt" )
resource.AddFile( "materials/gui/silkicons/coins.vtf" )
resource.AddFile( "materials/gui/silkicons/money_dollar.vmt" )
resource.AddFile( "materials/gui/silkicons/money_dollar.vtf" )
resource.AddFile( "materials/gui/silkicons/user_suit.vmt" )
resource.AddFile( "materials/gui/silkicons/user_suit.vtf" )
resource.AddFile( "materials/gui/DarkRPBlue.png" )
resource.AddFile( "materials/gui/blue/main.png" )
end
[/lua]
[QUOTE=Charrax;39684400][lua]
surface.DrawTexturedRect( ,sleft - 1,hudypos,260,50)
[/QUOTE]
You have a spare comma.
[QUOTE=ben434]Hey I have a problem with my npc, in init.lua:
and this all works and everything, but when its supposed to say the chatprint, it displays it in the players console not their chatbox. Any ideas?
Btw this is darkrp.[/QUOTE]
You could try this:
[CODE]function ENT:AcceptInput( name, activator)
if ( name == "Use" && IsValid( activator ) && activator:IsPlayer( ) ) then
local path = "cars/vandura/" .. activator:UniqueID() .. ".txt"
if file.Exists(path, "data") then
umsg.Start( "SavedCars", activator)
umsg.End()
else
activator:PrintMessage(HUD_PRINTTALK, "You don't own any cars.")
end
end
end[/CODE]
[QUOTE=Ice Tea;39684411]You have a spare comma.[/QUOTE]
Still doesnt work.
[QUOTE=Ice Tea;39684396]Are you using a custom chatbox?[/QUOTE]
yeah i removed my custom chatbox and it works, thanks.
[lua]
hook.Add("PlayerAuthed", "checkgroup", function(ply)
local id = ply:SteamID64()
http.Fetch("http://steamcommunity.com/gid/<GroupID>/memberslistxml/?xml=1", function(result, size) --Alternatively, use "http://steamcommunity.com/groups/<GroupName>/memberslistxml/?xml=1"
if size > 0 then
for w in string.gmatch(result, "<steamID64>(%d+)</steamID64>") do
if w == id then
ULib.ucl.addUser( ply:SteamID(), {}, {}, "vip" )
end
end
end
end)
end)
[/lua]
I have this code which I got a Lua Coder to confirm is right, I just need to know how to implement it onto my server, I have ULX and ULib installed.
Does it go into One of these or does it go into a Lua File and into the Auto-Run Server Side Folder?
Thank You,
~Maddog.
Edit: Nevermind im a moron
Hello, I have a quick question.
How do I download things from the workshop, and actually get the files onto my computer, so I can edit them, for practice?
Dario
[QUOTE=Dario z;39685354]Hello, I have a quick question.
How do I download things from the workshop, and actually get the files onto my computer, so I can edit them, for practice?
Dario[/QUOTE]
After you subscribe the certain thing, you will find it in addons like this xxx.gma
To convert it you this program --->[url]http://www.facepunch.com/showthread.php?t=1173875[/url]
Cheers bro
Hey. I am wondering how to disable vehicle spawning for admins and also making it so admins cant just set themselves or others on a team. thanks I have ulx and fadmin. I am running a DarkRP uptodate server.
[QUOTE=Maddog2k62k7;39685089]-Le snip-
I have this code which I got a Lua Coder to confirm is right, I just need to know how to implement it onto my server, I have ULX and ULib installed.
Does it go into One of these or does it go into a Lua File and into the Auto-Run Server Side Folder?
Thank You,
~Maddog.[/QUOTE]
If you want the "[u][b]lua[/b][/u]/autorun/server" to "lua/[u][b]autorun[/b][/u]/server" on the "lua/autorun/[u][b]server[/b][/u]" .. then yes :P
[QUOTE=Dario z;39685354]Hello, I have a quick question.
How do I download things from the workshop, and actually get the files onto my computer, so I can edit them, for practice?
Dario[/QUOTE]
Goto: C:\Program Files <(x86)>\Steam\steamapps\<steamidthingy>\garrysmod\garrysmod\addons and you'll find all the gma's (File-format for Garrysmod-stuff downloaded from workshop).
Open those in notepad++ or any text editing-software and you'll see the lua behind them. Just keep in mind that the first few lines aren't pure lua.
[QUOTE=Nak;39686792]If you want the "[u][b]lua[/b][/u]/autorun/server" to "lua/[u][b]autorun[/b][/u]/server" on the "lua/autorun/[u][b]server[/b][/u]" .. then yes :P[/QUOTE]
I see what you did there, I tried this but it does not seem to work. Any hints?
[QUOTE=Maddog2k62k7;39686818]I see what you did there, I tried this but it does not seem to work. Any hints?[/QUOTE]
Debug'z/optimize the code. Lots and lots of optimize.
The code will force a xml fetch from steam each time someone joins the server. It will basic lag.
[u]Now this isn't the most optimized .. but I don't feel like writing 50-100 lines:[/u]
[lua]Data = ""
http.Fetch("http://steamcommunity.com/gid/<GroupID>/memberslistxml/?xml=1", function(result, size, headers,httpcode) --Alternatively, use "http://steamcommunity.com/groups/<GroupName>/memberslistxml/?xml=1"
if size > 0 and httpcode!=200 then //Steam seems to return http 200 each time
Data = result
print("Fetched data from steam.")
else
print("Error. Wasn't able to fetch the data from steam. HTTP: "..httpcode)
if httpcode==203 then print("Steam have blocked this information.\nYou can try get a steamspi key to fix it, this script dosen't work anymore.") end
if httpcode==403 then print("Steam have forbitten this xml.\nYou can try get a steamapi key to fix it, this script don't work anymore.") end
if httpcode==418 then print("I'm a Teapot!\nLol .. steam is playing funny today.") end
end
end)
hook.Add("PlayerAuthed", "checkgroup", function(ply)
local id = ply:SteamID64()
for w in string.gmatch(Data, "<steamID64>(%d+)</steamID64>") do
if w == id then
ULib.ucl.addUser( ply:SteamID(), {}, {}, "vip" )
end
end
end)[/lua]
Hello, I'm trying to make my own drive class, I created the file in garrysmod/lua/drive/drive_test.lua but whenever I call
[CODE]drive.PlayerStartDriving( player, ent, "drive_test" );[/CODE] I get this error:
[CODE]Unknown drive type drive_test[/CODE]
Is there anything else I need to do to make my own drive class?
[editline]23rd February 2013[/editline]
I basically copy/pasted drive_sandbox.lua in the file and modified this line [CODE]drive.Register( "drive_sandbox",
{[/CODE] to change the name by drive_test
The weapon respawn and cannot pick up weapon again scripts aren't working anymore :c help
[CODE]function RespawnWeapon(weapon,class,pos,angles)
timer.Create("TheTimer",2,1,function(class,pos,angles)
local w = ents.Create(class)
w:SetPos(pos)
w:SetAngles(angles)
w:Spawn()
w:CallOnRemove("Respawn", RespawnWeapon, class, pos, angles)
end,class,pos,angles)
end
hook.Add("InitPostEntity", "Respawns", function()
--[[for _, ent in pairs(ents.FindByClass("weapon_*")) do
ent:CallOnRemove("Respawn", RespawnWeapon, ent:GetClass(), ent:GetPos(), ent:GetAngles())
end]]
end)
function CheckForPickup(player,weapon)
RespawnWeapon(weapon,weapon:GetClass(),weapon:GetPos(),weapon:GetAngles())
end
hook.Add("PlayerCanPickupWeapon","CheckForPickup",CheckForPickup)[/CODE]
----------------------------------------------------------------------
[CODE]function oneTypeOnly(ply,wep)
if ply:HasWeapon("weapon_physcannon")== true then
if wep:GetClass() == "weapon_physcannon" then return false
else return true
end
end
return true
end
function CheckForPickup(player,weapon)
if (oneTypeOnly(player,weapon)) then
RespawnWeapon(weapon,weapon:GetClass(),weapon:GetPos(),weapon:GetAngles())
end
hook.Add("PlayerCanPickupWeapon","CheckForPickup",CheckForPickup)[/CODE]
Is it possible to raise/lower the volume of a html panel?
[QUOTE=legodude;39683712]Trying to run a console command by pressing a derma button, works only after editing the cl_init while the gamemode is running... Any idea why this might be?[/QUOTE]
Is that derma in a scripted NPC?
[QUOTE=Maddog2k62k7;39685089]
I have this code which I got a Lua Coder to confirm is right, I just need to know how to implement it onto my server, I have ULX and ULib installed.
Does it go into One of these or does it go into a Lua File and into the Auto-Run Server Side Folder?
Thank You,
~Maddog.[/QUOTE]
This will work fine
[lua]hook.Add("PlayerAuthed", "checkgroup", function(ply)
if ply:IsUserGroup("vip") then return end // If we're a vip already don't execute it again
local id = ply:SteamID64()
local MaxPage = 10
local Group = "GroupHere"
for pagenum = 1,MaxPage do // Loop through the pages in case there are 1 or more pages
http.Fetch("https://steamcommunity.com/groups/"..Group.."/memberslistxml/?xml=1&p="..pagenum, function(result, size)
if size > 0 then
for w in string.gmatch(result, "<steamID64>(%d+)</steamID64>") do
if w == id then
ULib.ucl.addUser( ply:SteamID(), {}, {}, "vip" )
end
end
end
end)
end
end)
[/lua]
I've already tested it and it works goes in lua/autorun/server
[lua]
local Group = "GroupHere" // Change GroupHere to your group name
local MaxPage = 10 // You can see the max page number in the group
[/lua]
[code]<nextPageLink>
<![CDATA[
http://steamcommunity.com/groups/GroupHere/memberslistxml/?xml=1&p=2
]]>
</nextPageLink>[/code]
That's how you find how many pages you have in your group
does anyone know of a lua OO script that will allow me to have classes and inheritance?
i found [url]http://lua-users.org/wiki/ClassesAndMethodsExample[/url]
but it is unclear to me how i would go about overwriting super class methods.
what i need is class methods, that i can overwrite but still access the superclass method.
Sorry, you need to Log In to post a reply to this thread.