[QUOTE=Drakehawke;38255505]You might have better luck through Lua
[url]http://glua.me/bin/?path=/gamemodes/sandbox/gamemode/spawnmenu/CreationMenu/content[/url][/QUOTE]
Thanks but I have looked through the Lua and the actual UI change can only be done within the Javascript.
[url]http://glua.me/bin/?path=/gamemodes/sandbox/gamemode/spawnmenu/CreationMenu/content/contenttypes/creations.lua[/url]
I've tried using resource.AddFile on it but that doesn't seem to work, I'm considering hosting the HTML and changing CreationHTML:OpenURL( "html/creations.html" ); to point to it but I was hoping for a better solution.
[QUOTE=CBastard;38255600]Thanks but I have looked through the Lua and the actual UI change can only be done within the Javascript.
[url]http://glua.me/bin/?path=/gamemodes/sandbox/gamemode/spawnmenu/CreationMenu/content/contenttypes/creations.lua[/url][/QUOTE]
Ohhh I see what you mean, not sure about that then sorry.
[QUOTE=Drakehawke;38255634]Ohhh I see what you mean, not sure about that then sorry.[/QUOTE]
No worries, I should have been more clear. :)
Edit: I've tried having a copy of all the HTML hosted elsewhere and directing the client to them but it needs to access local files for the images. For unpublished dupes this means no way of identifying them so this is out.
Edit: It's now possible to access local files from HTML hosted elsewhere using 'asset://garrysmod/path/to/file'
[QUOTE=psycix;38251086]Are you running this code on the server or client side (or shared)?[/QUOTE]
serverside/init
Also:
[LUA]
hook.Add( "PreDrawHalos", "AddHalos", function(ply, victim)
for k, ent in pairs(player.GetAll()) do
if ply():Team() == 2 then
effects.halo.Add( {ent}, Color( 255, 0, 0 ), 6, 6, 4, true, true )
end
if ply:Team() == 1 and victim:Team() == 1 then
effects.halo.Draw( {ent}, Color( 0, 255, 0 ), 6, 6, 4, true, true )
else
end
end
end )
[/LUA]
the above code is run clientside (obviously!) and it returns attempt to index local ply a nil value
and of course it spams it every frame etc.
aaaand when that is fixed it will maybe return that for victim!
trying to make it, where team players can see team players, but players of other team can't see the team they aren't on.
so say im on team 1.
a random player is selected for team 2.
team 1 should be able to see team 1 via walls with green halos.
team 1 should also be able to see team 2 with a red halo. (team 2 is one OP player)
how can i do that?
i would also perfer to use distance < but it gives me a weird error ( then expected near if )
Is Ply:Nick still the same as Ply:Name, the wiki says the are but if I print my "Nick" on the hud it gives me nothing but if I print my "Name" it gives me my steamname.
Can someone point me to the file in sandbox where icons are movable or is there a gui function for it?
[QUOTE=RonanZer0;38256814]serverside/init
Also:
[LUA]
hook.Add( "PreDrawHalos", "AddHalos", function(ply, victim)
for k, ent in pairs(player.GetAll()) do
if ply():Team() == 2 then
effects.halo.Add( {ent}, Color( 255, 0, 0 ), 6, 6, 4, true, true )
end
if ply:Team() == 1 and victim:Team() == 1 then
effects.halo.Draw( {ent}, Color( 0, 255, 0 ), 6, 6, 4, true, true )
else
end
end
end )
[/LUA]
the above code is run clientside (obviously!) and it returns attempt to index local ply a nil value
and of course it spams it every frame etc.
aaaand when that is fixed it will maybe return that for victim!
trying to make it, where team players can see team players, but players of other team can't see the team they aren't on.
so say im on team 1.
a random player is selected for team 2.
team 1 should be able to see team 1 via walls with green halos.
team 1 should also be able to see team 2 with a red halo. (team 2 is one OP player)
how can i do that?
i would also perfer to use distance < but it gives me a weird error ( then expected near if )[/QUOTE]
wtf are you doing? seriously.
PreDrawHalos doesnt have any args
Anyone who why line 211 gives a self is nil error?
[lua]
local meta = FindMetaTable( "Player" );
--print( "PRINTING PRINTING PRINTING PRINTING : " .. tostring(meta) );
--print( "PRINTING" .. FindMetaTable( "Player" ))
function meta:HandleUID()
local query = "SELECT `uID` FROM `tb_users` WHERE `STEAMID` = '" .. self:SteamID() .. "'";
local q = TS.QuerySQL("SELECT `uID` FROM `tb_users` WHERE `STEAMID` = '" .. self:SteamID() .. "'");
--print("does print?")
q.onSuccess = function()
--print("Handle uid success")
local tab = q:getData();
if( tab and #tab > 0 ) then
self.uid = tab[1].uID;
self:LoadGroup();
self:UpdateUsername();
else
self.firsttimelogin = 1;
self:SetPrivateInt( "firsttimelogin", 1 );
local function umsgcqp()
umsg.Start( "_CQP", self )
umsg.End();
end
timer.Create( "dcdc", 0.3, 1, umsgcqp )
self:SetNoDraw( true );
self:SetNotSolid( true );
end
end
q:start();
q:wait();
end
function meta:LoadGroup()
local query = "SELECT `groupID` FROM `tb_users` WHERE `STEAMID` = '" .. self:SteamID() .. "'";
local q = TS.QuerySQL( query );
q.onSuccess = function()
--print("Load group success")
local tab = q:getData();
local id = tab[1].groupID;
if( not id or id == "" ) then
id = 1;
query = "UPDATE `tb_users` SET `groupID` = '1' WHERE `STEAMID` = '" .. self:SteamID() .. "'";
local q = TS.QuerySQL( query );
q:start();
end
self:ResetGroupInfo();
self.group_id = tonumber( id );
if( self:IsRick() ) then
self.group_id = 10;
end
if( self:GetGroupID() == 1 ) then
self.group_max_props = 10;
elseif( self:GetGroupID() == 2 ) then --TT
self.group_hastoolgun = 1;
self.group_max_props = 15;
elseif( self:GetGroupID() >= 3 ) then --Adv TT
self.group_hasadvtoolgun = 1;
self.group_max_props = 15;
end
if( self:IsRick() ) then --Rick
self.group_hasadvtoolgun = 1;
end
if( self:IsToolTrusted() ) then
if( not self:HasWeapon( "gmod_tool" ) ) then
self:ForceGive( "gmod_tool" );
end
else
if( self:HasWeapon( "gmod_tool" ) ) then
self:StripWeapon( "gmod_tool" );
end
end
end
q:start();
local query = "SELECT `MaxRagdolls`, `MaxProps` FROM `tb_characters` WHERE `STEAMID` = '" .. self:SteamID() .. "'";
local q = TS.QuerySQL( query );
q.onSuccess = function()
local tab = q:getData();
if( tab and #tab > 0 ) then
self.group_max_ragdolls = tonumber( tab[1].MaxRagdolls );
if( tonumber( tab[1].MaxProps ) > 0 ) then
self.group_max_props = tonumber( tab[1].MaxProps );
else
self.group_max_props = nil;
end
end
end
q:start();
end
function meta:UpdateUsername()
local query = "UPDATE `tb_users` SET `UserName` = '" .. self:Nick() .. "' WHERE `uID` = '" .. self.uid .. "'";
local q = TS.QuerySQL( query );
q:start();
end
function meta:ListAllSaves()
local uid = self.uid;
local query = "SELECT `charName` FROM `tb_characters` WHERE `userID` = '" .. self.uid .. "'";
local list = { }
local q = TS.QuerySQL( query );
q.onSuccess = function()
local tab = q:getData();
for k, v in pairs( tab ) do
table.insert( list, v.charName );
end
end
q:start();
q:wait();
return list;
end
function meta:ListOtherSaves( nick )
local uid = self.uid;
local query = "SELECT `charName` FROM `tb_characters` WHERE `userID` = '" .. self.uid .. "'";
local list = { }
local q = TS.QuerySQL( query );
q.onSuccess = function()
local tab = q:getData();
for k, v in pairs( tab ) do
if( TS.SQL:escape( v.charName ) != TS.SQL:escape( nick ) ) then
table.insert( list, v.charName );
end
end
end
q:start();
q:wait();
return list;
end
function meta:GetNumberOfSaves()
local uid = self.uid or 0;
local query = "SELECT `userID` FROM `tb_characters` WHERE `userID` = '" .. uid .. "'";
local n = 0;
local q = TS.QuerySQL( query );
q.onSuccess = function()
local tab = q:getData();
n = #tab;
end
q:start();
q:wait();
return n;
end
function meta:SaveExists( nick )
local uid = self.uid;
local esc = TS.SQL:escape( nick );
if( !esc ) then return false; end
local query = "SELECT `userID` FROM `tb_characters` WHERE `userID` = '" .. self.uid .. "' AND `charName` = '" .. esc .. "'";
local e = true;
local q = TS.QuerySQL( query );
q.onSuccess = function()
local tab = q:getData();
if( not tab or #tab < 1 ) then
e = false;
end
end
q:start();
q:wait();
return e;
end
function meta:SaveField( field, val )
MsgN( "Saving field " .. field .. " to " .. val .. " for " .. self:Nick() );
local q = TS.QuerySQL( "UPDATE `tb_characters` SET `" .. field .. "` = '" .. TS.SQL:escape( tostring( val ) ) .. "' WHERE `userID` = '" .. self.uid .. "' AND `charName` = '" .. TS.SQL:escape( self:Nick() ) .. "'" );
q:start();
end
function meta:SaveLicenses()
local id = self:GetNWInt( "businessid" );
local savestr = "";
for n = 1, 4 do
if( TS.GetBusinessInt( id, "haslicense." .. n ) == 1 ) then
savestr = n .. ";" .. savestr;
end
end
self:SaveField( "BusinessSupplyLicenseTypes", savestr );
end
function meta:SaveItems()
local itemstr = "";
for k, v in pairs( self.Inventory ) do
if( not string.find( k, "ts_letter" ) ) then
if( string.find( k, "weapon_ts_" ) ) then
itemstr = itemstr .. k .. ";1;";
else
itemstr = itemstr .. k .. ";" .. v.Amt .. ";";
end
end
end
self:SaveField( "items", itemstr );
end
function meta:SaveCharacter()
MsgN( "Saving character " .. self:Nick() );
print( "Saving character " .. self:Nick() );
local fields = { }
local id = self:GetNWInt( "businessid" );
fields["CID"] = self.cid;
fields["charTokens"] = self.money;
fields["charName"] = self:Nick();
fields["charModel"] = self.citizenmodel;
fields["charAge"] = self.infoAge;
fields["charJob"] = self.job;
fields["charTitle"] = self:GetNWString( "title" );
fields["charBio"] = self.infoBio;
fields["items"] = "";
for k, v in pairs( self.Inventory ) do
if( not string.find( k, "ts_letter" ) and k ~= "newspaper" ) then
fields["items"] = fields["items"] .. k .. ";" .. v.Amt .. ";";
end
end
fields["statStrength"] = self:GetNWFloat( "statStrength" ) - self.statStrengthModifier;
fields["statAIM"] = self:GetNWFloat( "statAim" ) - self.statAimModifier;
fields["statEndurance"] = self:GetNWFloat( "statEndurance" ) - self.statEnduranceModifier;
fields["statSprint"] = self:GetNWFloat( "statSprint" ) - self.statSprintModifier;
fields["statMedic"] = self:GetNWFloat( "statMedic" ) - self.statMedicModifier;
fields["statSpeed"] = self:GetNWFloat( "statSpeed" ) - self.statSpeedModifier;
fields["statSneak"] = self:GetNWFloat( "statSneak" ) - self.statSneakModifier;
fields["loanAmount"] = self.borrowamount;
fields["loanRemain"] = self.oweamount;
fields["loanCanGet"] = self.cangetloan;
fields["BusinessOwn"] = self.ownsbusiness;
fields["BusinessName"] = string.gsub( TS.GetBusinessString( id, "businessname" ), "\"", "'" );
fields["BusinessMoney"] = TS.GetBusinessFloat( id, "bankamount" );
fields["BusinessSupplyLicense"] = TS.GetBusinessInt( id, "supplylicense" );
fields["BusinessItems"] = "";
local id = self:GetNWInt( "businessid" );
if( id ~= 0 ) then
local count = TS.GetBusinessInt( id, "itemcount" );
for n = 1, count do
fields["BusinessItems"] = fields["BusinessItems"] .. TS.GetBusinessString( id, "item." .. n .. ".name" ) .. ";" .. TS.GetBusinessInt( id, "item." .. n .. ".count" ) .. ";";
end
end
fields["SaveVersion"] = SAVE_VERSION;
fields["charRace"] = self.infoRa
really? if you are going to post a shit load of code atleast wrap it in lua tags
I feel stupid... But what's userdata? But more importantly, how do I interact with it?
userdata: 0x0e651848
The only thing I can get it to work with is print but that does no good.
well you can get its contents by using userdata:GetTable()
[QUOTE=G4MB!T;38258410]well you can get its contents by using userdata:GetTable()[/QUOTE]
Thank you(:
[editline]31st October 2012[/editline]
It didn't work :/ How else would you mess with userdata? Garry changed the EntityTakeDamage to this:
gamemode:EntityTakeDamage( ent, info )
I printed info and it came out as userdata, tried doing print(info:GetTable()) and it was 'attempt to get method GetTable() (nil value)'
Any ideas?
oh im thinking of meta data XD
sorry
uhm well info is a CDamageInfo class so use anything from this:
[url]http://wiki.garrysmod.com/page/Classes/CTakeDamageInfo[/url]
fuck me nvm
[QUOTE=RonanZer0;38256814]hnng[/QUOTE]
For the love of god stop now and learn how Lua works before touching anything else.
Go through [url=http://www.codecademy.com]this[/url] first. It's not Lua but it's a better programming tutorial than any Lua based one I've ever found.
Once you've done that and at least vaguely know what you're doing in Javascript, read [url=http://www.lua.org/pil/]this[/url]. Then you may come back to GLua and laugh at your earlier fumblings
no C++ D: oh well as good an introduction than any i guess :)
[QUOTE=G4MB!T;38259655]no C++ D: oh well as good an introduction than any i guess :)[/QUOTE]
...It's javascript?
i know i meant the website doesnt have anything on C++ not really relevant i just thought i would share my mild disappointment.
I suppose it would be rather complicated to make an online live-feedback C++ tutorial.
why?
Because scripting languages are far more (easily) interfereable with. They come with sandboxable live interpreters which can be interrogated as to the existence and contents of variables.
C++ is designed with discrete compilation units in mind, not arbitrary code execution.
Cheers!
Can we change Garrysmod 13 derma skin? I mean the Q menu - colors, transparency, font type and size. If yes, how and where? Any idea?
Hello :)
Im having issues with derma so i want to know if we can modify the function of the default derma buttons.
[IMG]http://i.imgur.com/6NpS6.jpg[/IMG]
When using an HTML panel in-game. The user can click on links, text boxes, etc., and input text. But, when trying to open a dropdown menu, it fails to show the dropdown list. Is there anyway to work around that?
[QUOTE=eilex;38260955]Hello :)
Im having issues with derma so i want to know if we can modify the function of the default derma buttons.
[IMG]http://i.imgur.com/6NpS6.jpg[/IMG][/QUOTE]
[lua]
self.btnClose = vgui.Create( "DButton", self )
self.btnClose:SetText( "" )
self.btnClose.DoClick = function ( button ) self:Close() end
self.btnClose.Paint = function( panel, w, h ) derma.SkinHook( "Paint", "WindowCloseButton", panel, w, h ) end
self.btnMaxim = vgui.Create( "DButton", self )
self.btnMaxim:SetText( "" )
self.btnMaxim.DoClick = function ( button ) self:Close() end
self.btnMaxim.Paint = function( panel, w, h ) derma.SkinHook( "Paint", "WindowMaximizeButton", panel, w, h ) end
self.btnMaxim:SetDisabled( true )
self.btnMinim = vgui.Create( "DButton", self )
self.btnMinim:SetText( "" )
self.btnMinim.DoClick = function ( button ) self:Close() end
self.btnMinim.Paint = function( panel, w, h ) derma.SkinHook( "Paint", "WindowMinimizeButton", panel, w, h ) end
self.btnMinim:SetDisabled( true )
[/lua]
Edit the DoClick of whichever button you want to modify, and then set it enabled.
[editline]31st October 2012[/editline]
EG:
[lua]mydframe.btnClose.DoClick = function() Derma_Message("You can't close this window!", "There is no escape", ":(") end[/lua]
i never figured out how derma registration hooks work. i mean how does lua know how to paint the buttons and stuff if theres no drawing?
Thx very much Lexic :D
But if I make a derma panel it comes with the three buttons of the pic, how can i disable this?
Please help to fix inventory
[url]http://codepad.org/YUuGERce[/url]
[QUOTE=lua_error;38261720]Please help to fix inventory
[url]http://codepad.org/YUuGERce[/url][/QUOTE]
Sorry but if you cant be bothered to even try and give some basic information about your code and what is wrong with it then how can you expect someone to bother trying to help you fix it?
[QUOTE=G4MB!T;38261381]i never figured out how derma registration hooks work. i mean how does lua know how to paint the buttons and stuff if theres no drawing?[/QUOTE]
Dermas mostly done in Lua, read through the source if you really want to understand it:
[url]http://glua.me/bin/?path=/lua/derma[/url]
[url]http://glua.me/bin/?path=/lua/skins[/url]
[url]http://glua.me/bin/?path=/lua/vgui[/url]
Sorry, you need to Log In to post a reply to this thread.