[QUOTE=YoutoYokodera;52442204]Ahh i'll just accept the gay new animation then, i dont know anything about modeling and such :p
Ty btw[/QUOTE]
If you want to use NPC anims you have to set the correct move_yaw pose parameter in GM:UpdateAnimation(), though fixing the animation in Blender really would be the proper way to do it.
[lua]
-- originally by bigbang i think?
local estyaw = math.Clamp(math.atan2(vel.y, vel.x) * 180 / 3.141592, -180, 180)
local myaw = math.NormalizeAngle(math.NormalizeAngle(ply:EyeAngles().y) - estyaw)
ply:SetPoseParameter("move_yaw", -myaw)
-- fix non-euclidian comedy legs
if CLIENT then
ply:SetIK(true)
end
[/lua]
[QUOTE=Spamppa2;52442300]i have been trying to check if player is inside cordinates he wont take damage but players can still take damage how did i fail this time?
[lua]local function PlayerSpawnProtection(victim, attacker)
local BoxCorner = Vector(-2246.671387, -4722.780273, 2848.473389)
local OppositeCorner = Vector(-3108.852295, -4651.897949, 2849.468506)
local TopCorner = Vector(-2996.481201, -4631.507813, 3320.731201)
local PlayersInArea = ents.FindInBox(BoxCorner,OppositeCorner,TopCorner)
return not table.HasValue(PlayersInArea,victim)
end
hook.Add( "PlayerShouldTakeDamage", "PlayerSpawnProtection", PlayerSpawnProtection)[/lua][/QUOTE]
That is incredibly inefficient.
Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/WithinAABox]Vector:WithinAABox[/url] instead.
Also - FindInBox, as well as WithinAABox, take 2 vectors as arguments - Top right corner, and bottom left borner (Max and min)
Using mysqloo v9, I'm running in to a problem which might have an easy fix, but I cannot seem to figure it out.
I have a function which injects some data in to the database, but before that is done, it calls another function which does a query to check some data. Now, it seems that the first function doesn't "wait" for a return from the second function before continuing it's execution.
I realize that halting the servers execution will cause problems, even if the query is very swift.
How would one work around this?
[QUOTE=Fillipuster;52442316]Using mysqloo v9, I'm running in to a problem which might have an easy fix, but I cannot seem to figure it out.
I have a function which injects some data in to the database, but before that is done, it calls another function which does a query to check some data. Now, it seems that the first function doesn't "wait" for a return from the second function before continuing it's execution.
I realize that halting the servers execution will cause problems, even if the query is very swift.
How would one work around this?[/QUOTE]
If you absolutely need to wait you can block until the query is completed with query:wait().
[QUOTE=Luni;52442331]If you absolutely need to wait you can block until the query is completed with query:wait().[/QUOTE]
Will this block all server execution until completed?
Furthermore, do you have some example usage?
-snip-
[QUOTE=Fillipuster;52442343]Will this block all server execution until completed?
Furthermore, do you have some example usage?[/QUOTE]
Yes.
[code]
local val
local query = database:query "SELECT 5 + 5 AS output"
function query:onSuccess(data)
val = data[1].output
end
query:start()
query:wait()
print(val)
[/code]
Another dirtier solution would be to put the stuff into the database inside of a callback that can be passed to the function that gets the data. I would suggest using coroutines but afaik they're still broken on the current release.
[QUOTE=Fillipuster;52442343]Will this block all server execution until completed?
Furthermore, do you have some example usage?[/QUOTE]
Yes.
[lua]
local q = db:query("select 1")
q:start()
q:wait()
assert(q:error() == "", q:error())
PrintTable(query:getData()))
[/lua]
e: damnit
[QUOTE=bigdogmat;52442375]Another dirtier solution would be to put the stuff into the database inside of a callback that can be passed to the function that gets the data. I would suggest using coroutines but afaik they're still broken on the current release.[/QUOTE]
9.4 seems to play well with them, at least on Windows
Thanks @Luni & @bigdogmeat!
I think I'll go with callback functions and hope it doesn't get too nesty.
[QUOTE=Luni;52442383]
9.4 seems to play well with them, at least.[/QUOTE]
I couldn't get them to work until I recompiled with the gmod-module-base development headers
[QUOTE=bigdogmat;52442465]I couldn't get them to work until I recompiled with the gmod-module-base development headers[/QUOTE]
Huh. I know v8 or v9.0 shat itself on coroutines but (at least on Windows) I haven't had any problems with 9.1 or 9.4
wrong thread
Is there a table that contains all the info used when calling surface.CreateFont? (Like a global font table)
-snip-
Fixed - I wasn't including the shared files to the client. Rookie mistake.
[QUOTE=kpjVideo;52442923]Is there a table that contains all the info used when calling surface.CreateFont? (Like a global font table)[/QUOTE]
It's stored in the engine, probably in a hash table.
i have been trying to make simple radio entity but i keep getting this weird error
[lua]AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Use( activator, caller )
self:EmitSound( "metro.mp3", 75, 100, 1, CHAN_AUTO )
end
function ENT:Initialize()
self:SetModel( "models/props_c17/oildrum001.mdl" )
self:SetUseType( SIMPLE_USE )
self:SetNotSolid(true)
self:PhysicsInit( SOLID_VPHYSICS )
end
[/lua]
error:
[lua]
[ERROR] lua/entities/radio/init.lua:14: attempt to call field 'PlayFile' (a nil value)
1. unknown - lua/entities/radio/init.lua:14
[/lua]
[QUOTE=RasmusG5;52443351]i have been trying to make simple radio entity but i keep getting this weird error
:snip:[/QUOTE]
You're not calling `PlayFile` anywhere in that code snippet.
What is the most effective way to decrease run speed while holding a specific swep? I tried set player speed in SWEP's think hook but when i switch weapon idk how to set back the speed to default, or do it in GM:Think but that just look heavy
how does the :match(string) function work?
[QUOTE=YoutoYokodera;52445082]What is the most effective way to decrease run speed while holding a specific swep? I tried set player speed in SWEP's think hook but when i switch weapon idk how to set back the speed to default, or do it in GM:Think but that just look heavy[/QUOTE]
If SWEP.Weight doesn't work then use the GM:SetPlayerSpeed hook.
anyone know an easy way to covert a bunch of file paths into a table?
"lua/autorun/server/sv_file01.lua"
"lua/autorun/server/sv_file02.lua"
"lua/autorun/server/sv_file03.lua"
"lua/autorun/sh_file01.lua"
would be convert a table looking like
lua = {}
lua.autorun = {}
lua.autorun.FILES = {"sh_file01.lua"}
lua.autorun.server = {}
lua.autorun.server.FILES = {"sv_file01.lua","sv_file02.lua","sv_file03.lua"}
[QUOTE=ROFLBURGER;52445900]anyone know an easy way to covert a bunch of file paths into a table?
"lua/autorun/server/sv_file01.lua"
"lua/autorun/server/sv_file02.lua"
"lua/autorun/server/sv_file03.lua"
"lua/autorun/sh_file01.lua"
would be convert a table looking like
lua = {}
lua.autorun = {}
lua.autorun.FILES = {"sh_file01.lua"}
lua.autorun.server = {}
lua.autorun.server.FILES = {"sv_file01.lua","sv_file02.lua","sv_file03.lua"}[/QUOTE]
Iterate and add them to the table based on their path
[QUOTE=YourStalker;52445865]If SWEP.Weight doesn't work then use the GM:SetPlayerSpeed hook.[/QUOTE]
From the wiki: [QUOTE]This is not a hook.[/QUOTE]
Wtf does that even mean?
[QUOTE=JasonMan34;52445934]Iterate and add them to the table based on their path[/QUOTE]
Yeah but how?
[QUOTE=ROFLBURGER;52445943]Yeah but how?[/QUOTE]
[lua]
local paths = {
"lua/autorun/server/sv_file01.lua",
"lua/autorun/server/sv_file02.lua",
"lua/autorun/server/sv_file03.lua",
"lua/autorun/sh_file01.lua",
}
local res = {}
for k, v in ipairs(paths) do
local path, name = v:match("^(.-)/?([^/]+)$")
-- iterate over subdirectories
local cur = res
for dir in path:gmatch("[^/]+") do
cur[dir] = cur[dir] or {}
cur = cur[dir]
end
-- add to destination array
if cur.FILES then
table.insert(cur.FILES, name)
else
cur.FILES = {name}
end
end
[/lua]
[QUOTE=YourStalker;52445865]If SWEP.Weight doesn't work then use the GM:SetPlayerSpeed hook.[/QUOTE]
I did not use Weight i set the speed by SetRunSpeed in SWEP:Holster and Deploy
But they doesn't change when i change weapon
Using think hook to detect if the player is holding the swep would be a pain
[QUOTE=Luni;52442383]Yes.
[lua]
local q = db:query("select 1")
q:start()
q:wait()
assert(q:error() == "", q:error())
PrintTable(query:getData()))
[/lua]
e: damnit
9.4 seems to play well with them, at least on Windows[/QUOTE]
If I have to either wait for queries or use callback functions, how come GMod's PData can retrieve SQL information without "delay"?
[QUOTE=Fillipuster;52446140]If I have to either wait for queries or use callback functions, how come GMod's PData can retrieve SQL information without "delay"?[/QUOTE]
It can't. PData uses Gmod's own SQLite driver, which is fast enough (since it's built into the game and not sending queries to an external server) that the delay isn't usually noticeable.
[QUOTE=Luni;52446186]It can't. PData uses Gmod's built-in SQLite driver, which cannot use threaded queries like MySQLOO can, but since it's built into the game the delay isn't usually noticeable.[/QUOTE]
Ah, I see.
Does waiting for queries halt all servers execution, or will other threads keep working, only halting the current thread?
[QUOTE=Fillipuster;52446192]Ah, I see.
Does waiting for queries halt all servers execution, or will other threads keep working, only halting the current thread?[/QUOTE]
The queries will still have been dispatched to the MySQL server, outside of Gmod, but MySQLOO won't be able to run the callbacks until your code is done blocking.
[QUOTE=Luni;52446201]The queries will still have been dispatched to the MySQL server, outside of Gmod, but MySQLOO won't be able to run the callbacks until your code is done blocking.[/QUOTE]
I was thinking in the lines of say, another addon handling some server-side hook. Would that still fire while the server is waiting for the MySQL return?
Sorry, you need to Log In to post a reply to this thread.