Could try changing it from k = 0 to k = 1 / chunks.
[QUOTE=Kogitsune;46466983]Could try changing it from k = 0 to k = 1 / chunks.[/QUOTE]
This didn't work with k = 1 / chunks. It has the same result.
Multiples of 5 have the same issue. it for some reason adds another chunk.
[QUOTE=Robotboy655;46466134]In the next update ( I think ) you can use this hook:
[url]http://wiki.garrysmod.com/page/GM/EntityFireBullets[/url]
[editline]12th November 2014[/editline][/QUOTE]
Thanks! I've put a temporary pause on that until then, but I'm having the weirdest error ever with something else. I'm using this hook which calls phageboost(attacker) function:
[t]http://puu.sh/cN7Sm/7fd5a4f291.png[/t]
Networking:
[t]http://puu.sh/cN7Zg/2701bf59c7.png[/t]
but it tosses this error even though it works as intended:
[t]http://puu.sh/cN7Uy/22d1ddb968.png[/t]
I'm essentially using a pointshop item which when equipped, and you shoot a player, it boosts your speed for a short time so I wanted to display it on the HUD by showing a small box that says "Boost!" on it. It works fine, but this error is tossed every time a player is shot when they have the item equipped and I have no idea why.
Is there another way of ServerSide telling a player to use a chat.AddText with my message? I dont want to use another net message and apparently SendLua is a bad choice
ply:ChatPrint(str)
I'm still trying to wrap my head around glua client & server sided operations. Inside my init.lua I have included "items/items.lua", and inside my cl_init.lua I have included "items/cl_init.lua"
The purposes of items.lua is to handle when a player uses any item, function GetItem() determines what type of item was used and calls a new function respectively
In "cl_items.lua" I plan on reading from a database to determine what the player has in his inventory, but for learning I have a DButton on screen that when clicked it uses a bottle of water, which will heal a player.
[B]cl_items.lua[/B]
[code]
local function UseItem(item)
net.Start("item_use")
net.WriteTable(item)
net.SendToServer() -- Server listens for item_use and reads from the table item
end
b.DoClick = function()
local item = GetItem("water") -- temporary button calling use function on static item
UseItem(item)
end
local function FailedToUse(client, item)
client:EmitSound(SoundNoUse)
end
net.Receive("item_failed", function(len)
local client = net.ReadEntity()
local item = net.ReadTable()
FailedToUse(client, item)
end)
[/code]
Now inside my items.lua I have a function listening for "item_use", receiving the item table. If the item wasn't able to be used it sends back a network string called "item_failed" so that I can print a message and play an error sound on the client side
[b]items.lua[/b]
[code]
util.AddNetworkString("item_use")
util.AddNetworkString("item_failed")
net.Receive("item_use", function(len, client)
local item = net.ReadTable()
if(item) then
if(item.ent == "item_consumable") then
if(client:UseConsumable(item)) then
-- Item used successfully, remove from inventory
else
net.Start("item_failed")
net.WriteEntity(client)
net.WriteTable(item)
net.Send(client) -- send a message back to cl_items.lua that item use failed (health is full already)
end
end
end
end)
[/code]
My question is, would it work online with multiple clients connected? Is there a better way to handle things like this? Should I wrap CLIENT or SERVER conditionals around anything?
[QUOTE=Exho;46467515]Is there another way of ServerSide telling a player to use a chat.AddText with my message? I dont want to use another net message and apparently SendLua is a bad choice[/QUOTE]
Just use net message.
[editline]12th November 2014[/editline]
[QUOTE=serfma;46467470]Thanks! I've put a temporary pause on that until then, but I'm having the weirdest error ever with something else. I'm using this hook which calls phageboost(attacker) function:
[t]http://puu.sh/cN7Sm/7fd5a4f291.png[/t]
Networking:
[t]http://puu.sh/cN7Zg/2701bf59c7.png[/t]
but it tosses this error even though it works as intended:
[t]http://puu.sh/cN7Uy/22d1ddb968.png[/t]
I'm essentially using a pointshop item which when equipped, and you shoot a player, it boosts your speed for a short time so I wanted to display it on the HUD by showing a small box that says "Boost!" on it. It works fine, but this error is tossed every time a player is shot when they have the item equipped and I have no idea why.[/QUOTE]
Looks like phageboostHUD is not defined clientside or something. Make sure you use the same variable name everywhere, etc ( [B]Lua is case sensitive[/B] ), or show more code ( Lines 0-25 of phage.lua ) if you want more help.
[QUOTE=Exho;46467515]Is there another way of ServerSide telling a player to use a chat.AddText with my message? I dont want to use another net message and apparently SendLua is a bad choice[/QUOTE]
SendLua is only a bad choice if you are imputing a variable into the function that can be modified by the client.
[QUOTE=AnonTakesOver;46470371]SendLua is only a bad choice if you are imputing a variable into the function that can be modified by the client.[/QUOTE]
And if you are trying to send a string more than 250 characters long.
[QUOTE=Robotboy655;46466134]In the next update ( I think ) you can use this hook:
[url]http://wiki.garrysmod.com/page/GM/EntityFireBullets[/url]
[editline]12th November 2014[/editline][/QUOTE]
He can already use it.
I'm having trouble with creating console commands. Basically I want admins to have the ability to modify a bunch of features my SWEP pack has but one of my friends is bitching at me that it doesn't work on his Dedicated Server. My friends try it on non-dedicated servers and it works.
This is what I have for practically all of them:
[code]CreateConVar("sv_css_damage_scale", "1", FCVAR_REPLICATED + FCVAR_ARCHIVE , "This is the value that all damage from CSS weapons is multiplied. Default is 1." )[/code]
I read through all of the FCVAR lists and I understood most of the commands, but I could be misinterpreting what the below fcvar means
[code]FCVAR_SERVER_CAN_EXECUTE
Makes the command or ConVar only executeable/changeable from the server console[/code]
pretty sure that this means that if I include this, admins won't be able to use it or it could be the morning and im being dumb
[QUOTE=ROFLBURGER;46473058]I'm having trouble with creating console commands. Basically I want admins to have the ability to modify a bunch of features my SWEP pack has but one of my friends is bitching at me that it doesn't work on his Dedicated Server. My friends try it on non-dedicated servers and it works.
This is what I have for practically all of them:
[code]CreateConVar("sv_css_damage_scale", "1", FCVAR_REPLICATED + FCVAR_ARCHIVE , "This is the value that all damage from CSS weapons is multiplied. Default is 1." )[/code]
I read through all of the FCVAR lists and I understood most of the commands, but I could be misinterpreting what the below fcvar means
[code]FCVAR_SERVER_CAN_EXECUTE
Makes the command or ConVar only executeable/changeable from the server console[/code]
pretty sure that this means that if I include this, admins won't be able to use it or it could be the morning and im being dumb[/QUOTE]
Is your friend entering the commands to srcds console or into his in-game console. Because he should be entering them into the srcds console.
[QUOTE=Robotboy655;46473198]Is your friend entering the commands to srcds console or into his in-game console. Because he should be entering them into the srcds console.[/QUOTE]
Ok so how would I make it so he could enter it into his own console?
My swep pack comes with a derma menu that any admin can accesses. The derma menu sends the settings via console commands. If that doesn't work, then that's a problem.
[QUOTE=Robotboy655;46470342]Just use net message.
[editline]12th November 2014[/editline]
Looks like phageboostHUD is not defined clientside or something. Make sure you use the same variable name everywhere, etc ( [B]Lua is case sensitive[/B] ), or show more code ( Lines 0-25 of phage.lua ) if you want more help.[/QUOTE]
Hook which calls when a player gets shot (and the error triggers):
[t]http://puu.sh/cO3Xu/263a41509b.png[/t]
the error called:
[t]http://puu.sh/cO407/8278efd7ac.png[/t]
Networking full (ignore everything that doesn't say phage :p):
[t]http://puu.sh/cO41v/4dc090060a.png[/t]
HUD code:
[t]http://puu.sh/cO44c/159293ce8b.png[/t]
This is everything. It will still display the "BOOST!" on the HUD correctly, just tosses this error when the player is shot. I just don't understand why it tosses an error but works still.
Let it be known that I'm learning for fun and I know it's messy or silly, but I'm at least learning. ;)
[img]http://i.imgur.com/OFgjuKP.png[/img] Can you find your problem here?
[editline]12th November 2014[/editline]
[QUOTE=ROFLBURGER;46473267]Ok so how would I make it so he could enter it into his own console?
My swep pack comes with a derma menu that any admin can accesses. The derma menu sends the settings via console commands. If that doesn't work, then that's a problem.[/QUOTE]
You don't. Create clientside versions of the convars, when they are changed, send a net message to the server and change the serverside commands.
[B][U]DO NOT FORGET TO CHECK FOR IsAdmin BOTH ON CLIENT AND SERVER.[/U][/B]
How can you make gradients colored? Also does anyone know any good sites for textures for vgui's and such?
[QUOTE=_Entity;46473625]How can you make gradients colored? Also does anyone know any good sites for textures for vgui's and such?[/QUOTE]
Make a white-to-transparent gradient texture and color it. There are such textures shipped with GMod.
[QUOTE=Robotboy655;46473382][img]http://i.imgur.com/OFgjuKP.png[/img] Can you find your problem here?
[editline]12th November 2014[/editline]
You don't. Create clientside versions of the convars, when they are changed, send a net message to the server and change the serverside commands.
[B][U]DO NOT FORGET TO CHECK FOR IsAdmin BOTH ON CLIENT AND SERVER.[/U][/B][/QUOTE]
Oh jesus I really didn't notice the space. That's a first.
However, that does not solve anything. Still having the issue where the phageboost() function is returning nil.
[editline]12th November 2014[/editline]
There something I'm missing? :p
[QUOTE=Robotboy655;46473684]Make a white-to-transparent gradient texture and color it. There are such textures shipped with GMod.[/QUOTE]
do you mind providing an example?
[QUOTE=_Entity;46473818]do you mind providing an example?[/QUOTE]
Example of what? Paining a textured box onto the screen? Or using a photo editing software to make a gradient?
I am having an issue with the hud I'm making, basically the health bar won't move and it is shorter then it should be.
This is what I have, the back part is perfect. I'm guessing I shouldn't use math.Clamp but I'm unsure of what other things I can use to achieve the same affect. Any suggestions on other methods or is there an error on my end?
[CODE]
--Health bar backing
draw.Roundedbox( 0, x + 10, y + 57, w - 20, h - 112, healthbarcolors.back )
--Health bar
draw.Roundedbox( 0, x + 10, y + 57, math.Clamp( health, 0, w - 20)*2, h - 112, healthbarcolors.main
[/CODE]
[QUOTE=Robotboy655;46473382]You don't. Create clientside versions of the convars, when they are changed, send a net message to the server and change the serverside commands.
[B][U]DO NOT FORGET TO CHECK FOR IsAdmin BOTH ON CLIENT AND SERVER.[/U][/B][/QUOTE]
brb in an hour after I experiment with net
[QUOTE=Baby Weiner;46474070]I am having an issue with the hud I'm making, basically the health bar won't move and it is shorter then it should be.
This is what I have, the back part is perfect. I'm guessing I shouldn't use math.Clamp but I'm unsure of what other things I can use to achieve the same affect. Any suggestions on other methods or is there an error on my end?
[CODE]
--Health bar backing
draw.Roundedbox( 0, x + 10, y + 57, w - 20, h - 112, healthbarcolors.back )
--Health bar
draw.Roundedbox( 0, x + 10, y + 57, math.Clamp( health, 0, w - 20)*2, h - 112, healthbarcolors.main
[/CODE][/QUOTE]
You should learn how to use maths.
math.Clamp( health, 0, 100 ) / 100 * (w - 20)
[QUOTE=Robotboy655;46474421]You should learn how to use maths.
math.Clamp( health, 0, 100 ) / 100 * (w - 20)[/QUOTE]
Anywhere I can go to learn how to use them properly?
[QUOTE=Baby Weiner;46474505]Anywhere I can go to learn how to use them properly?[/QUOTE]
[url]http://wiki.garrysmod.com/page/Category:math[/url] - look up various math functions here
Here's something I whipped up quick using a modifier to size a vertical health bar, untested
[code]
local BarX = 48 -- The width of your health bar
local BarY = 128 -- The max height of your health bar
local _hp = client:Health() -- Store player's current health
local _hpMax = client:MaxHealth() -- Store player's max health
local _hpMod = ((BarH / _hpMax) * _hp) -- Modifier (1.28 / 100 = 1.28) then multiplied by current health to size the bar accordingly
draw.RoundedBox(0, 32, ScrH()-BarY-32, BarX, _hpMod, Color(25, 255, 25, 255))
[/code]
[QUOTE=Baby Weiner;46474505]Anywhere I can go to learn how to use them properly?[/QUOTE]
I don't know really, I am not trying to be mean, but I learned this at school.. Just try to break down what you want to accomplish and try to figure out the, um, maths required for that.
For example, you want a box'es width change according to health. Lets break it down:
1) Box's width should range from 0 to my custom number, (w-10)
2) Players health is usually ranging from 0 to 100
How do we make a [del]MATHS[/del] formula from this?
1) Easiest solution here is to multiply our maximum length by a value ranging from 0 to 1. This way, if we get 0.5 * (w-10), it's half of the bar. Perfect.
Now, how do we get a number from 0 to 1, knowing that a players health is usually ranging from 0 to 100?
2) Easy. Divide the players health by 100. Now we get a number between 0 and 1. Throw it all together and you got yourself [del]MATHS[/del] formula for width of your bar.
We throw additional math.Clamp(hp, 0, 100) to make sure the health stays in boundaries for our HUD and doesn't go across the whole screen if an admin sets his health to 9999.
Hopefully this is useful to somebody. :eng101:
Am I cursed?
[t]http://puu.sh/cOtj8/b948b99043.png[/t]
[t]http://puu.sh/cOtlO/e5bace4269.png[/t]
[t]http://puu.sh/cOtD7/9e9bfcb4c3.png[/t]
Yet again, the function is ran (ps_giveitem()) and there's correct output, yet an error is tossed, saying it's nil. This is the full code and note that I understand this would give a player the hat every single time the round begins, but ignore it, I was just wanting to test.
[editline]12th November 2014[/editline]
Yeeeaaah found out my issue. It was running shared and tossing an error client-side.
[QUOTE=serfma;46475909]Am I cursed?
[t]http://puu.sh/cOtj8/b948b99043.png[/t]
[t]http://puu.sh/cOtlO/e5bace4269.png[/t]
[t]http://puu.sh/cOtD7/9e9bfcb4c3.png[/t]
Yet again, the function is ran (ps_giveitem()) and there's correct output, yet an error is tossed, saying it's nil. This is the full code and note that I understand this would give a player the hat every single time the round begins, but ignore it, I was just wanting to test.
[editline]12th November 2014[/editline]
Yeeeaaah found out my issue. It was running shared and tossing an error client-side.[/QUOTE]
Your error being yellow means it's being ran clientside, I'm pretty sure you should be giving the item serverside?
EDIT: You editted while I was posting, glad you worked it out.
[QUOTE=wh1t3rabbit;46476056]Your error being yellow means it's being ran clientside, I'm pretty sure you should be giving the item serverside?
EDIT: You editted while I was posting, glad you worked it out.[/QUOTE]
Wow never knew the error being yellow meant it's being ran clientside. Thank you.
Could anybody give me a quick snippet for tabbed and styled menus as seen here (James0roll posted in the What you're working on thread)
[url]http://i.imgur.com/ubQZ4Ok.jpg[/url]
I've been trying to figure out how to customize GUI menus without much luck =\ I'm also curious how I could create a menu such as DarkRP's job selection menu
Sorry, you need to Log In to post a reply to this thread.