[QUOTE=PigeonTroll;49555182]Regarding SWEPs, I'm confused over when to just use variables or use SetupDataTables() and go from there.
And also in SetupDataTables(), is it better to use DTVar or NetworkVar? On the wiki it says that NetworkVar should be used, but in default TTT weapons, DTVar is used.[/QUOTE]
DTVars are said to be faster, use SetupDataTables() when creating NetworkVars/DTVars, use NetworkVars/DTVars if you want the variable to be networked (the same and available) on both the server and client.
I'm trying to make it so that a moderate damage shotgun will insta-kill if all 12 pellets hits the target WITHOUT increasing the damage.
A solution I can think of is making it store a table on the player tracking the amount of bullets received from that specific weapon in a self.Primary.Delay amount of time, but that sounds lag-intensive. Would this be the best way of doing this?
storing it as
victim.BulletTable[weapon] = CurTime()
and checking if there are 12 values counted that is under CurTime() + weapon.Primary.Delay
I have no idea why isn't working?
I'm just trying to print the players name.[lua]if SERVER then
function startNetWork()
util.AddNetworkString("pong")
end
net.Receive("pong", function(ply)
print("It works! " .. ply:Nick())
end)
hook.Add( "Initialize", "someUniqueText", startNetWork)
elseif CLIENT then
function sendMsgToServer()
net.Start("pong")
net.SendToServer()
end
concommand.Add("pong", sendMsgToServer)
end[/lua]Server Error[CODE][ERROR] lua/autorun/pong.lua:7: attempt to index local 'ply' (a number value)
1. func - lua/autorun/pong.lua:7
2. unknown - lua/includes/extensions/net.lua:32[/CODE]
[QUOTE=Nipah;49556933]I have no idea why isn't working?
[/QUOTE]
ply is the second argument, not the first one, length is, it should be function( len , ply )
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Receive]net.Receive[/url]
I'm wondering, I know some Java, would that make it a bit easier to learn LUA?
[QUOTE=Minelayer;49560930]I'm wondering, I know some Java, would that make it a bit easier to learn LUA?[/QUOTE]
other than knowing the common aspects of all program languages, no
but lua's pretty damn easy to pick up
[QUOTE=Nipah;49556933]I have no idea why isn't working?[/QUOTE]
You also don't need to put util.AddNetworkString on the Initialize(or any other) hook, you can just run it when the file loads.
[QUOTE=GGG KILLER;49562054]You also don't need to put util.AddNetworkString on the Initialize(or any other) hook, you can just run it when the file loads.[/QUOTE]The wiki suggested it. [URL="https://wiki.garrysmod.com/page/util/AddNetworkString"]util.AddNetworkString[/URL]
Is that not common practice?
What does mean something like this: self.m_b, self.m_f and etc ?
[QUOTE=Neyt;49564830]What does mean something like this: self.m_b, self.m_f and etc ?[/QUOTE]
Variables assigned to a weapon
[editline]19th January 2016[/editline]
Or entity
[editline]19th January 2016[/editline]
Or panel
[editline]19th January 2016[/editline]
Or a value in a table called self
[QUOTE=geferon;49565189]Variables assigned to a weapon
[editline]19th January 2016[/editline]
Or entity
[editline]19th January 2016[/editline]
Or panel
[editline]19th January 2016[/editline]
Or a value in a table called self[/QUOTE]
Thanks! Where i can find more information about that ?
[QUOTE=Neyt;49565423]Thanks! Where i can find more information about that ?[/QUOTE]
There isnt.
Everyone names the variables as they want.
You should look in the lua files to more things like self.WHATEVER = SOMETHING
Is it possible adding a train to a map, or can u only do it on hammer?
[QUOTE=seabeds;49554483]I did in fact take a look at that before asking (thank you anyways!) but i cannot figure out what hooks/functions i would use for the purchase of a traitor weapon (i am currrenly learning lua right now).[/QUOTE]
There is some useful information for TTT hooks on badkings site for it [url=http://ttt.badking.net/guides/hooks]Here[/url]. Then you could loop through all players, see if their role (ply:GetRole()) is ROLE_TRAITOR then show them the message.
Assuming you know how to use hooks, if not, it's easy look it up.
Are Lua files in autorun shared by default, or do i have to AddCSLuaFile() them?
[QUOTE=Austin1346;49567201]Are Lua files in autorun shared by default, or do i have to AddCSLuaFile() them?[/QUOTE]
Shared by default.
You dont have to addcslua them.
[media]https://youtu.be/LEwav3ybYEE[/media]
How can i find out what's causing these freezes? They only happen once per play session, so probably something with caching/preloading.
I'm getting a relatively low amount of freezes, some players can barely play at all because they happen all over the place.
And it doesn't happen if i run the map locally without my gamemode on it.
How can I stop GMod from screwing up my images? I have an image that looks like this, right?
[IMG]http://i.imgur.com/Fs5MxU8.png[/IMG]
It's the dinosaur (blinking) from Google Chrome's offline game thing. I then did
[CODE]
local dinoblink = Material( 'dinogame/blink.png', 'alphatest noclamp' )
[/CODE]
To cache the material for later use, right?
Then, I set the material using [URL="https://wiki.garrysmod.com/page/surface/SetMaterial"]surface.SetMaterial[/URL] and set the draw color to be fully white, then I used [URL="https://wiki.garrysmod.com/page/surface/DrawTexturedRect"]surface.DrawTexturedRect[/URL] to draw it, using the exact width and height dimensions of the original image to avoid distortion, and somehow GMod managed to make it look like this:
[IMG]http://i.imgur.com/q6l6APO.png[/IMG]
The edges have black bits on them and it looks really bad. How can I fix this?
[QUOTE=MPan1;49568370]How can I stop GMod from screwing up my images? I have an image that looks like this, right?
[IMG]http://i.imgur.com/Fs5MxU8.png[/IMG]
It's the dinosaur (blinking) from Google Chrome's offline game thing. I then did
[CODE]
local dinoblink = Material( 'dinogame/blink.png', 'alphatest noclamp' )
[/CODE]
To cache the material for later use, right?
Then, I set the material using [URL="https://wiki.garrysmod.com/page/surface/SetMaterial"]surface.SetMaterial[/URL] and set the draw color to be fully white, then I used [URL="https://wiki.garrysmod.com/page/surface/DrawTexturedRect"]surface.DrawTexturedRect[/URL] to draw it, using the exact width and height dimensions of the original image to avoid distortion, and somehow GMod managed to make it look like this:
[IMG]http://i.imgur.com/q6l6APO.png[/IMG]
The edges have black bits on them and it looks really bad. How can I fix this?[/QUOTE]
The alphatest parameter might be causing it. Make sure both of your .png files are fully transparent with no layer interlacing.
Without alphatest it looks pretty much the same, except the edges look like that on ALL the sides, but they're a little less noticeable. Not sure if I exported them with interlacing or not, but I'm pretty sure I didn't. I hope I didn't, or I'll have to re-export every single file :(
[editline]20th January 2016[/editline]
Jesus, this is a weird bug thing:
Right, so I'm creating a table of materials to use later like this:
[CODE]
local cactimats = {
Material( 'dinogame/smallcacti1.png', 'alphatest noclamp' ),
Material( 'dinogame/smallcacti2.png', 'alphatest noclamp' ),
Material( 'dinogame/smallcacti3.png', 'alphatest noclamp' ),
Material( 'dinogame/largecacti1.png', 'alphatest noclamp' ),
Material( 'dinogame/largecacti2.png', 'alphatest noclamp' ),
Material( 'dinogame/largecacti3.png', 'alphatest noclamp' ),
}
[/CODE]
But when I print the table, it prints this:
[CODE]
1 = dinogame/smallcacti1
2 = dinogame/smallcacti2
3 = dinogame/smallcacti3
4 = dinogame/largecacti1
5 = dinogame/largecacti2
6 = dinogame/largecacti3
7 = 3.4252323712908e-006
[/CODE]
Why does it add another odd table key for no reason?
[QUOTE=MPan1;49569117]Without alphatest it looks pretty much the same, except the edges look like that on ALL the sides, but they're a little less noticeable. Not sure if I exported them with interlacing or not, but I'm pretty sure I didn't. I hope I didn't, or I'll have to re-export every single file :(
[editline]20th January 2016[/editline]
Jesus, this is a weird bug thing:
Right, so I'm creating a table of materials to use later like this:
[CODE]
local cactimats = {
Material( 'dinogame/smallcacti1.png', 'alphatest noclamp' ),
Material( 'dinogame/smallcacti2.png', 'alphatest noclamp' ),
Material( 'dinogame/smallcacti3.png', 'alphatest noclamp' ),
Material( 'dinogame/largecacti1.png', 'alphatest noclamp' ),
Material( 'dinogame/largecacti2.png', 'alphatest noclamp' ),
Material( 'dinogame/largecacti3.png', 'alphatest noclamp' ),
}
[/CODE]
But when I print the table, it prints this:
[CODE]
1 = dinogame/smallcacti1
2 = dinogame/smallcacti2
3 = dinogame/smallcacti3
4 = dinogame/largecacti1
5 = dinogame/largecacti2
6 = dinogame/largecacti3
7 = 3.4252323712908e-006
[/CODE]
Why does it add another odd table key for no reason?[/QUOTE]
Material returns two arguments and your result is exactly how varargs are supposed to work. You can wrap each Material call in brackets to limit the expression to 1 value.
One last question- this one is probably really basic:
So, I'm trying to replicate the Google Chrome offline dinosaur game, and I want the canvas to scroll. Currently I'm adding the number 8 to whatever the previous scroll value was in a paint hook. Is there a way for me to compensate for any times the paint hook DOESN'T get called so it looks smooth, and goes the same speed on any kind of computer, no matter how good it is at rendering? It probably has something to do with RealFrameTime but I still don't really understand how/when to properly use it.
[QUOTE=MPan1;49569296]One last question- this one is probably really basic:
So, I'm trying to replicate the Google Chrome offline dinosaur game, and I want the canvas to scroll. Currently I'm adding the number 8 to whatever the previous scroll value was in a paint hook. Is there a way for me to compensate for any times the paint hook DOESN'T get called so it looks smooth, and goes the same speed on any kind of computer, no matter how good it is at rendering? It probably has something to do with RealFrameTime but I still don't really understand how/when to properly use it.[/QUOTE]
If im not wrong you will have to add a value wich youll have to multiply by FrameTime or RealFrameTime.
So all I need to do is multiply it by RealFrameTime? Anyone have a second opinion on that? It sounds a bit too simple to me...
[QUOTE=MPan1;49569308]So all I need to do is multiply it by RealFrameTime? Anyone have a second opinion on that? It sounds a bit too simple to me...[/QUOTE]
Try it and tell me how it works.
[editline]20th January 2016[/editline]
Also, whats the difference between RealFrameTime and FrameTime
According to the wiki, the difference is that RealFrameTime isn't affected by stuff like host_timescale, but FrameTime is. Also, I tried multiplying the number by RealFrameTime and it just makes everything go really slowly. Is there some number I need to multiply RealFrameTime by to get it to run at an above-snail's-pace speed?
[QUOTE=MPan1;49569324]According to the wiki, the difference is that RealFrameTime is affected by stuff like host_timescale, but FrameTime isn't. Also, I tried multiplying the number by RealFrameTime and it just makes everything go really slowly. Is there some number I need to multiply RealFrameTime by to get it to run at an above-snail's-pace speed?[/QUOTE]
You have it backwards, RealFrameTime is the one not affected by timescale (hence the word Real)
[QUOTE=Z0mb1n3;49569414]You have it backwards, RealFrameTime is the one not affected by timescale (hence the word Real)[/QUOTE]
Sorry, mistype. Fixed it. Anyway, any idea how to multiply the number being added by RealFrameTime and not have it go really slowly? Am I supposed to multiply RealFrameTime by 60 (as in 60fps-probably the max framerate) or something?
[QUOTE=MPan1;49569421]Sorry, mistype. Fixed it. Anyway, any idea how to multiply the number being added by RealFrameTime and not have it go really slowly?[/QUOTE]
Well, ideally you would Lerp it, but since your game goes at a constant speed, I'd use [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/math/Approach"]math.Approach[/URL], with the 'amount' argument being RealFrameTime()*8 (or whatever number of units it's supposed to scroll per second)
Sorry if this is another stupid question, but what am I meant to use for the start and end values?
EDIT: Wait, so the number I'm multiplying RealFrameTime by is meant to be the amount of units it scrolls per second? That explains why it was so slow- but why do I need to use math.Approach then? Is that just meant to make it smoother or something?
Sorry, you need to Log In to post a reply to this thread.