"Removed hook ‘ContextScreenClick’ (now redundant)"
Then what hook are we supposed to use as a replacement..?
[QUOTE=Ylsid;38980410]"Removed hook ‘ContextScreenClick’ (now redundant)"
Then what hook are we supposed to use as a replacement..?[/QUOTE]
What are you trying to do?
Is it possible to have an animated texture inside a VGUI menu?
I tried setting an animated material with DImage, but it always comes up black / not animating.
It works just fine (animation plays) when it's set as my spray.
Need some help with [URL="http://facepunch.com/showthread.php?t=1228151&p=38980219&viewfull=1#post38980219"]this[/URL] and [URL="http://facepunch.com/showthread.php?t=1235031&p=38979479&viewfull=1#post38979479"]this[/URL], thanks!
[QUOTE=Drakehawke;38981117]What are you trying to do?[/QUOTE]
Detect if I've clicked an area on a screen which changes position dynamically (so vgui = no go)
[QUOTE=Ylsid;38981972]Detect if I've clicked an area on a screen which changes position dynamically (so vgui = no go)[/QUOTE]
Make a hook for when a mouse button is pressed, check the (x,y) of the mouse click is within the range you're concerned with?
I don't understand though, is the mouse active or something? Otherwise the mouse pos will always be in the middle of the screen (like when you aim)
Unless you want to check the aim vector is in an area? Is that what you mean?
[QUOTE=Trumple;38982124]Make a hook for when a mouse button is pressed, check the (x,y) of the mouse click is within the range you're concerned with?
I don't understand though, is the mouse active or something? Otherwise the mouse pos will always be in the middle of the screen (like when you aim)
Unless you want to check the aim vector is in an area? Is that what you mean?[/QUOTE]
Yeah, this is what I've had to do, I guess it works.
[QUOTE=Ylsid;38982390]Yeah, this is what I've had to do, I guess it works.[/QUOTE]
I'm not aware of any other check you could perform that is already made for you. Besides, it's simple enough if you make use of OOP-style methods
-snip; got it-
[QUOTE=Ylsid;38981972]Detect if I've clicked an area on a screen which changes position dynamically (so vgui = no go)[/QUOTE]
try
[lua]
hook.Add( "GUIMouseReleased", "somestring", function(mc)
if mc == MOUSE_LEFT then
local mouseX, mouseY = input.GetCursorPos()
// do stuff
end
end)
[/lua]
that runs whenever you click, and with a check to see if your mouseX/mouseY is in the right spot, you should be able to achieve what your looking for.
I am getting
[ERROR] gamemodes/darkrp/gamemode/client/cl_events.lua:1: unexpected symbol near '.'
1. unknown - gamemodes/darkrp/gamemode/client/cl_events.lua:0
Which makes no sense to me because this is how the code looks like:
[lua]local EV.ActiveEvents = {}
function EV.ReceiveInfo()
EV.ActiveEvents = net.ReadTable()
local CurrentEvent = {}
CurrentEvent.name = EV.ActiveEvents.name
CurrentEvent.time = EV.ActiveEvents.time
end
net.Receive( "EventsInfo", EV.ReceiveInfo())[/lua]
[QUOTE=Netheous;38983622]I am getting
[ERROR] gamemodes/darkrp/gamemode/client/cl_events.lua:1: unexpected symbol near '.'
1. unknown - gamemodes/darkrp/gamemode/client/cl_events.lua:0
Which makes no sense to me because this is how the code looks like:
[lua]local EV.ActiveEvents = {}
function EV.ReceiveInfo()
EV.ActiveEvents = net.ReadTable()
local CurrentEvent = {}
CurrentEvent.name = EV.ActiveEvents.name
CurrentEvent.time = EV.ActiveEvents.time
end
net.Receive( "EventsInfo", EV.ReceiveInfo())[/lua][/QUOTE]
Run [lua]print(IsValid(EV))[/lua] and see what it returns.
[QUOTE=Hyper Iguana;38983659]Run [lua]print(IsValid(EV))[/lua] and see what it returns.[/QUOTE]
Don't have to, EV is valid because I got it in the included, shared file and it's not local.
sh_events.lua
[lua]EV = {}
EV.EventsList = {}[/lua]
@Edit: Also it doesn't output any boolean, just nothing.
[QUOTE=Netheous;38983622]I am getting
[ERROR] gamemodes/darkrp/gamemode/client/cl_events.lua:1: unexpected symbol near '.'
1. unknown - gamemodes/darkrp/gamemode/client/cl_events.lua:0
Which makes no sense to me because this is how the code looks like:
[lua]local EV.ActiveEvents = {}
function EV.ReceiveInfo()
EV.ActiveEvents = net.ReadTable()
local CurrentEvent = {}
CurrentEvent.name = EV.ActiveEvents.name
CurrentEvent.time = EV.ActiveEvents.time
end
net.Receive( "EventsInfo", EV.ReceiveInfo())[/lua][/QUOTE]
[lua]EV.ActiveEvents = {}[/lua]
If EV is local, it will be local. If it isn't, it won't be. Doesn't make sense to add a "local" to something that won't be local in the first place.
As a general rule of thumb, if you're using a dot, don't use local, it'll just error
[QUOTE=Netheous;38983622]I am getting
[ERROR] gamemodes/darkrp/gamemode/client/cl_events.lua:1: unexpected symbol near '.'
1. unknown - gamemodes/darkrp/gamemode/client/cl_events.lua:0
Which makes no sense to me because this is how the code looks like:
snip[/QUOTE]
[lua]
EV.ActiveEvents = {}
function EV.ReceiveInfo()
EV.ActiveEvents = net.ReadTable()
local CurrentEvent = {}
CurrentEvent.name = EV.ActiveEvents.name
CurrentEvent.time = EV.ActiveEvents.time
end
net.Receive( "EventsInfo", EV.ReceiveInfo)[/lua]
you can't set a local variable inside a table. you also had () at the end of EV.ReceiveInfo on the last line
[QUOTE=my_hat_stinks;38983895][lua]EV.ActiveEvents = {}[/lua]
If EV is local, it will be local. If it isn't, it won't be. Doesn't make sense to add a "local" to something that won't be local in the first place.
As a general rule of thumb, if you're using a dot, don't use local, it'll just error[/QUOTE]
Oh, I see, so basically I tried to make local inside a non-local variable ?
@Edit: It's funny how I made so many scripts and after a month long pause I am making such a mistakes
How can I get the current active page URL on a DHTML element? My FinishedURL and OpeningURL functions don't seem to be called.
Are you able to "block" specific stuff that's being sent from the server to the client?
I want to play a scene on an NPC, but only one player see's the NPCs animation.
Does anybody know of a way to fix the screenscale issue with fonts? The issue I'm talking about is that players on different resolutions have text being over-sized for them and it screws the positioning of things up.
[QUOTE=jrj996;38986053]Does anybody know of a way to fix the screenscale issue with fonts? The issue I'm talking about is that players on different resolutions have text being over-sized for them and it screws the positioning of things up.[/QUOTE]
Oh yeah, and why is this tiny (tooltip)
[img]http://puu.sh/1FLcR[/img]
Also...
[QUOTE=T3h raps13r;38985128]How can I get the current active page URL on a DHTML element? My FinishedURL and OpeningURL functions don't seem to be called.[/QUOTE]
How can I get the size of a string? (number of bytes, not string.len)
[QUOTE=Undefined;38988342]How can I get the size of a string? (number of bytes, not string.len)[/QUOTE]
Isn't it the same thing?
1 char = 1 byte right?
Edit: Fixed
[QUOTE=ollie;38988622]Isn't it the same thing?
1 char = 1 byte right?[/QUOTE]
Well, unless you're using Unicode.
But yeah.
[QUOTE=Reload377;38989284][code]
[ERROR] gamemodes/dm/gamemode/cl_init.lua:456: attempt to index field 'DM' (a nil value)
1. Dm_CS_DrawScoreboard - gamemodes/dm/gamemode/cl_init.lua:456
2. v - gamemodes/dm/gamemode/cl_init.lua:54
3. unknown - lua/includes/modules/hook.lua:82 [/code]
Line 456
[lua]draw.SimpleText(v.DM["Kill"], "TargetID", 515, pos + 2, Color(0,0,0,255))[/lua]
I'm a noob.[/QUOTE]
We're going to need more code than that to figure it out :C
[QUOTE=ollie;38988622]Isn't it the same thing?
1 char = 1 byte right?[/QUOTE]
isn't it technically number of characters +1?
[QUOTE=Drak_Thing;38985965]Are you able to "block" specific stuff that's being sent from the server to the client?
I want to play a scene on an NPC, but only one player see's the NPCs animation.[/QUOTE]
Maybe you are sending the scene to only one person ?
Would be easier to tell if you show us the code
[editline]27th December 2012[/editline]
Okay, so back to the problem.
In the past, I was doing this in my gamemode:
shared.lua
[lua]CRP = {}
function CRP.AddTeam( teamTbl )
team.SetUp(table.Count(CRP.Teams), teamTbl.Name, teamTbl.Color)
CRP.Teams[teamTbl.Name] = teamTbl
end
CRP.Teams = {}
local NewTeam = {}
NewTeam["Name"] = "Citizen"
NewTeam["Descr"] = [[You should look for a job, what quality of life will you have with such a low salary?]]
NewTeam["Color"] = Color(185, 245, 0, 255)
NewTeam["Salary"] = 35
NewTeam["Weapons"] = {}
NewTeam["Mdls"] = {}
NewTeam["Limit"] = false
NewTeam["LvlReq"] = false
NewTeam["VoteReq"] = false
CRP.AddTeam(NewTeam)
local NewTeam = {}
NewTeam["Name"] = "Policeman"
NewTeam["Descr"] = [[Don't drink on watch! Keep calm and patrol the streets, show them that you are worth your salary!]]
NewTeam["Color"] = Color(255, 0, 255, 255)
NewTeam["Salary"] = 70
NewTeam["Weapons"] = {}
NewTeam["Mdls"] = {}
NewTeam["Limit"] = 5
NewTeam["LvlReq"] = 2
NewTeam["VoteReq"] = false
CRP.AddTeam(NewTeam)
[REST OF THE CODE][/lua]
And then, inside server/sv_database.lua I was doing:
[lua]function CRP.DBLoadPlayer(ply)
local DBresult = sql.Query("SELECT * FROM CRP_stats WHERE id = '"..ply:SteamID().."'")
ply.CRPstats = {}
ply.CRPstats["Name"] = DBresult.name or ply:Name()
ply.CRPstats["Job"] = CRP.Teams[team.GetName(ply:Team())].Name or "Unemployed"
ply.CRPstats["Money"] = DBresult.money or 0
ply.CRPstats["Salary"] = CRP.Teams[team.GetName(ply:Team())].Salary or 0
CRP.SendStats(ply, false, false, true)
end
function CRP.DBNewPlayer(ply)
sql.Query("INSERT INTO CRP_stats ('id', 'name', 'money') VALUES ('"..ply:SteamID().."', 'Stranger', '0')")
CRP.DBLoadPlayer(ply)
end
[REST OF THE CODE][/lua]
And it worked just fine, but now when I do
EV= {} in sh_events.lua
And then in cl_events and sv_events try to put function into EV by doing "EV.FuncName()" I get
[ERROR] gamemodes/darkrp/gamemode/client/cl_events.lua:1: attempt to index global 'EV' (a nil value)
[ERROR] gamemodes/darkrp/gamemode/server/sv_events.lua:3: attempt to index global 'EV' (a nil value)
Why is it happening ? I mean, I did everything as I did in my other code that worked in 100%
Im trying to make a simple way to include folders in the addons.
So far its searching in the folders. But when it comes to
sub sub folders it stops with a nil value.
Ive tried to put an if statement in, but that doesnt seem to fix it. Anyone that knows why?
[code]
local t_Filter = {
"db"
};
local function ProcessFolder( addon_Name, t_Location )
print("addons/" .. addon_Name .. "/" .. t_Location .. "*", "GAME")
local t_Files, t_Directories = file.Find( "addons/" .. addon_Name .. "/" .. t_Location .. "*", "GAME" )
for _, t_File in pairs( t_Files ) do
if ( !table.HasValue( t_Filter, string.GetExtensionFromFilename( t_File ) ) ) then
local fixPath = string.Replace( t_Location, "addons/", "" )
resource.AddFile( fixPath .. t_File );
MsgN( "resource.AddFile( '" .. fixPath .. t_File .. "' );" );
end
end
for _, t_Directory in pairs( t_Directories ) do
MsgN( "Found directory: '" .. t_Directory .. "'." );
print(t_Directory);
--if (!t_Location == nil) then
print(t_Location .. t_Directory , t_Total);
ProcessFolder( t_Location .. t_Directory , t_Total );
--end
end
end
if ( game.IsDedicated() ) then
-- ProcessFolder("Your addon name here", "Folder i want to process here")
ProcessFolder( "Kane and Lynch players", "Models/" );
ProcessFolder( "Kane and Lynch players", "Materials/" );
end
[/code]
Are there any good LUA tutorials that don't need alterations to fit with the new gm13 library or whatever?
I've fiddled about in the past and I really want to get my head down and do something now.
[QUOTE=Instant Mix;38990128]Are there any good LUA tutorials that don't need alterations to fit with the new gm13 library or whatever?
I've fiddled about in the past and I really want to get my head down and do something now.[/QUOTE]
Generally, the old GM12 wiki is still great for most things. Just remember important changes, there are only a few.
[url]https://docs.google.com/document/d/1khSuIYrAMkqXu7wlH5YRJNwz6hOH6Xqi5lqBhE3x6gA/edit[/url]
Timers, file library, fonts, IsValid, net library instead of datastream, those are most of the main ones. We're in a tough time to start learning, since the GM13 wiki is largely incomplete, but it's not impossible and there are plenty of people here to help
Sorry, you need to Log In to post a reply to this thread.