[QUOTE=syl0r;46044535]You could try a trace between [URL="http://wiki.garrysmod.com/page/Entity/EyePos"]ply:EyePos()[/URL] and the flashbang. If it doesn't hit anything then it's atleast potentially visible.
The next thing you can do is check if you are looking in the direction of the flashbang.
[LUA]
local direction = flashbang:GetPos()-ply:EyePos()
--Do some trace stuff
local dotProduct = ply:GetAimVector():Dot(direction:GetNormal())
local angle = math.acos(dotProduct)
if(angle <= math.pi/2) then
-- visible
end
[/LUA][/QUOTE]
Yeah that's what I'm doing, getting the direction through FOV.
I was thinking of using a trace but it's like this doesn't seem reliable (because one could be looking at a thin pole and not be blinded)
Is there a limit size that the pdata sql integer values can store? I tired making it store a 99999999999999999999999999999999999999999999999999999 value and it keeps returning this:
[code]
inf
[/code]
Yes, it's 2^64 for unsigned integers and -2^63 to +2^63-1 for signed ones
Edit: Actually SQLite only support signed integers from -2^63 to 2^63-1
[QUOTE=syl0r;46069417]Yes, it's 2^64 for unsigned integers and -2^63 to +2^63-1 for signed ones[/QUOTE]
herp a derp *slams head*
So it is like actual integer values. See I thought that, I am just doing to much stuff right now.
I am saving the players bank money in sql. I am pretty sure they won't hit that value though.
[QUOTE=bran92don;46069447]herp a derp *slams head*
So it is like actual integer values. See I thought that, I am just doing to much stuff right now.
I am saving the players bank money in sql. I am pretty sure they won't hit that value though.[/QUOTE]
I somehow doubt that. Also, make sure that you aren't using %d in string.format since it only supports 32 bit integers.
Hey I'm trying to create an AvatarImage element which has been cropped to a circle. I've got the AvatarImage just need help with the corners. Any help is appreciated, thank you :)
[QUOTE=Sereni;46072412]Hey I'm trying to create an AvatarImage element which has been cropped to a circle. I've got the AvatarImage just need help with the corners. Any help is appreciated, thank you :)[/QUOTE]
The only advice I could think of would be to use stencils, but I have no clue how they work.
link: [url]http://facepunch.com/showthread.php?t=1337232&p=43271812&viewfull=1#post43271812[/url]
[QUOTE=ROFLBURGER;46069080]Yeah that's what I'm doing, getting the direction through FOV.
I was thinking of using a trace but it's like this doesn't seem reliable (because one could be looking at a thin pole and not be blinded)[/QUOTE]
For the flashbang, you could use [url=http://wiki.garrysmod.com/page/util/PixelVisible]util.PixelVisible[/url].
[QUOTE=Sereni;46072412]Hey I'm trying to create an AvatarImage element which has been cropped to a circle. I've got the AvatarImage just need help with the corners. Any help is appreciated, thank you :)[/QUOTE]
Here's an easy template for doing simple masking using stencils.
[lua]
render.ClearStencil()
render.SetStencilTestMask(1) -- halo sets these to a value that wasn't the default,
render.SetStencilWriteMask(1) -- causes weird sideeffects if you don't understand what they do
render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_NEVER) -- don't actually draw the mask object(s)
render.SetStencilPassOperation(STENCILOPERATION_KEEP) -- hide parts that the mask doesn't cover (keep the refernce value at 0)
render.SetStencilFailOperation(STENCILOPERATION_INCR) -- increment reference value of pixels to 1 (default is 0) if your object fails to draw (your mask is over it)
render.SetStencilZFailOperation(STENCILOPERATION_KEEP)
-- draw your mask object
render.SetStencilReferenceValue(1) -- change reference value to 1
render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_EQUAL) -- set stencils to only draw the pixels whose value is equal to the reference value
-- draw your object you want to be masked
render.SetStencilEnable(false)
[/lua]
This is an inclusive mask, it should be fairly easy to understand how to change it to be an exclusive mask by reading the comments.
I wish to calculate / predict a perfect physics bounce using some lovely vector math, a bounce like \/
Would this math be Velocity Normal + Hit Normal ?
Reworded: Movement Normal + Surface Normals
I have this for a SENT right now;
[code]( TrRes.HitNormal + self.Owner:GetAimVector() * 0.5 ):GetNormal()[/code]
but early on I tried
[code]( TrRes.HitNormal + self.Owner:GetAimVector() ):GetNormal()[/code]
both worked, but the current one (top) did a very good bounce too. Which one is a perfect reflection?
[editline]I can't believe I actually need text in these tags[/editline]
Let me translate that sexy code for something more applicable to the question;
[code]( HitSurfaceNormal + ForwardVelocityNormal ):GetNormal()[/code]
I have a quick question about FastDL vs. Workshop
If I take all my workshop addons and extract them and put them in the addons folder and add them to fastdl (playermodels and such), would I still need to add the workshop id for players to download the addon from the workshop or would it automatically work from fastdl without them downloading it from the steam workshop?
[QUOTE=bluebull107;46083697]I have a quick question about FastDL vs. Workshop
If I take all my workshop addons and extract them and put them in the addons folder and add them to fastdl (playermodels and such), would I still need to add the workshop id for players to download the addon from the workshop or would it automatically work from fastdl without them downloading it from the steam workshop?[/QUOTE]
You are completely missing the point of FastDL
Workshop caps your download speed and you have to download every thing in it
FastDL you can take out certain models and materials from a workshop addon and they only need to download those, with an uncapped speed.
You need to remove the add workshop ids and put add resource file, and the argument is the path of where the models and materials are on the FastDL seever, there are some generators online for you to generate a file for this
[QUOTE=AnonTakesOver;46083964]You are completely missing the point of FastDL
Workshop caps your download speed and you have to download every thing in it
FastDL you can take out certain models and materials from a workshop addon and they only need to download those, with an uncapped speed.
You need to remove the add workshop ids and put add resource file, and the argument is the path of where the models and materials are on the FastDL seever, there are some generators online for you to generate a file for this[/QUOTE]
Can you give me an example for the add resource?
[QUOTE=bluebull107;46084090]Can you give me an example for the add resource?[/QUOTE]
There are quite a few examples listed [URL="https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5809.html"]here[/URL]
And I have to add every file that is used, not just the directory to the folder?
[QUOTE=bluebull107;46084656]And I have to add every file that is used, not just the directory to the folder?[/QUOTE]
Yup.
You could write a recursive script that adds all files for you though.
[CODE]v:SendLua( [[chat.AddText(Color(243, 156, 18), "[",
Color(52, 152, 219), "LEVEL",
Color(243, 156, 18), "]",
Color(52, 152, 219), "]]..ply:Nick()..[[",
Color(243, 156, 18), " just leveled up to level ",
Color(52, 152, 219), "]]..tostring(level)..[[",
Color(243, 156, 18), "!")]])[/CODE]
Why in the world does lines 1 and 3 act like the [ and ] are not strings? I have them enclosed in "s but for some reason they break.
-snip-
I completely misread what you were trying to do.
It seems to work for me, the string is just longer than 255 characters so it can't be sent using SendLua.
[QUOTE=serfma;46084729][CODE]v:SendLua( [[chat.AddText(Color(243, 156, 18), "[",
Color(52, 152, 219), "LEVEL",
Color(243, 156, 18), "]",
Color(52, 152, 219), "]]..ply:Nick()..[[",
Color(243, 156, 18), " just leveled up to level ",
Color(52, 152, 219), "]]..tostring(level)..[[",
Color(243, 156, 18), "!")]])[/CODE]
Why in the world does lines 1 and 3 act like the [ and ] are not strings? I have them enclosed in "s but for some reason they break.[/QUOTE]When using SendLua the things in the brackets has to be in ""
because you're sending a string
[CODE]v:SendLua("[[chat.AddText(Color(243, 156, 18), "[",
Color(52, 152, 219), "LEVEL",
Color(243, 156, 18), "]",
Color(52, 152, 219), "]]..ply:Nick()..[[",
Color(243, 156, 18), " just leveled up to level ",
Color(52, 152, 219), "]]..tostring(level)..[[",
Color(243, 156, 18), "!")]]")[/CODE]
[QUOTE=serfma;46084729][CODE]v:SendLua( [[chat.AddText(Color(243, 156, 18), "[",
Color(52, 152, 219), "LEVEL",
Color(243, 156, 18), "]",
Color(52, 152, 219), "]]..ply:Nick()..[[",
Color(243, 156, 18), " just leveled up to level ",
Color(52, 152, 219), "]]..tostring(level)..[[",
Color(243, 156, 18), "!")]])[/CODE]
Why in the world does lines 1 and 3 act like the [ and ] are not strings? I have them enclosed in "s but for some reason they break.[/QUOTE]
Never use SendLua. It has 255 symbol limit.
[QUOTE=Robotboy655;46084800]Never use SendLua. It has 255 symbol limit.[/QUOTE]
What should I use then?
[QUOTE=serfma;46084803]What should I use then?[/QUOTE]
net library. And not simply WriteString. Do it properly.
[QUOTE=serfma;46084803]What should I use then?[/QUOTE]
Use a net message.
Only send the player and the new level and then construct the message on the client.
Don't use RunString or SendLua in this case since I can easily inject lua code into your code using my nick.
Example of a nick that would rek your server:
[QUOTE]")while(true) do end --[/QUOTE]
[QUOTE=Robotboy655;46084809]net library. And not simply WriteString. Do it properly.[/QUOTE]
[QUOTE=syl0r;46084813]Use a net message.
Only send the player and the new level and then construct the message on the client.
Don't use RunString or SendLua in this case since I can easily inject lua code into your code using my nick.
Example of a nick that would rek your server:[/QUOTE]
Alrighty. Never messed with networking at all, have 0 knowledge of it but gonna have to learn it.
Following the "keep clean" part:
Bad argument to SetPos.
[lua]if ( !CLIENT ) then
local pBall = ents.Create( "prop_combine_ball" )
pBall:SetOwner( pOwner );
pBall:SetPhysicsAttacker( pOwner );
pBall:SetPos( vecSrc );
pBall:SetVelocity( vecVelocity );
pBall:Spawn();
pBall:GetPhysicsObject():AddGameFlag( FVPHYSICS_DMG_DISSOLVE );
pBall:GetPhysicsObject():AddGameFlag( FVPHYSICS_WAS_THROWN );
pBall:GetPhysicsObject():SetVelocity( vecVelocity );
pBall:SetModel( "models/Effects/combineball.mdl" );
end[/lua]
[code][ERROR] addons/tropystaff/lua/weapons/tropystaff.lua:65: bad argument #1 to 'SetPos' (Vector expected, got nil)
1. SetPos - [C]:-1
2. unknown - addons/tropystaff/lua/weapons/tropystaff.lua:65[/code]
vecSrc and vecVelocity aren't defined anywhere.
You can also replace
[LUA]
if ( !CLIENT ) then
[/LUA]
with
[LUA]
if ( SERVER ) then
[/LUA]
[QUOTE=syl0r;46084813]Use a net message.
Only send the player and the new level and then construct the message on the client.
Don't use RunString or SendLua in this case since I can easily inject lua code into your code using my nick.
Example of a nick that would rek your server:[/QUOTE]
[CODE]if ( SERVER ) then
util.AddNetworkString( "Lvl" )
function LvlWrite()
net.Start( "Lvl" )
net.WriteString(lvler)
net.WriteString(plylevel)
net.Broadcast()
end
end
if ( CLIENT ) then
net.Receive( "Lvl", function()
local player = net.ReadString()
local level = net.ReadString()
chat.AddText(Color(243, 156, 18), "[",
Color(52, 152, 219), "LEVEL",
Color(243, 156, 18), "] ",
Color(52, 152, 219), player,
Color(243, 156, 18), " just leveled up to level ",
Color(52, 152, 219), level,
Color(243, 156, 18), "!")
end )
end
hook.Add( "onLevelUp", "LvlUpMsg" , function(ply, level, tilnextlevel)
lvler = ply:GetName()
plylevel = tostring(level)
LvlWrite()
end) [/CODE]
How does this look for a first time? I know it's messy and may not be the best, but it works. Really new to lua and coding in general.
BTW I realize Robotboy said not simply WriteString, but I'm not really sure what else to do. :p
[QUOTE=syl0r;46085340]vecSrc and vecVelocity aren't defined anywhere.
You can also replace
[LUA]
if ( !CLIENT ) then
[/LUA]
with
[LUA]
if ( SERVER ) then
[/LUA][/QUOTE]
I did base the primary attack of the SWEP off of the AR2's secondary. Which in itself came from the hl2 weapon bases. I wasn't entirely sure whether they were outdated or not.
use net.WriteEntity(player) on the serverside and use
[LUA]local ply = net.ReadEntity()
local nick = ply:Nick()[/LUA]
On the clientside.
For numbers use net.WriteUInt(tonumber(level),32)
and
[LUA]
local lvl = net.ReadUInt(32)
[/LUA]
on the clientside
[QUOTE=syl0r;46085495]use net.WriteEntity(player) on the serverside and use
[LUA]local ply = net.ReadEntity()
local nick = ply:Nick()[/LUA]
On the clientside.
For numbers use net.WriteUInt(tonumber(level),32)
and
[LUA]
local lvl = net.ReadUInt(32)
[/LUA]
on the clientside[/QUOTE]
May I ask why the changes were needed? Just curious so I know in the future. :)
Thanks a lot, by the way, it all works great!
Sorry, you need to Log In to post a reply to this thread.