[QUOTE=Blasteh;47492244]I use furryfinder for this, much simpler than pure lua implementations.
[URL]http://facepunch.com/showthread.php?t=996309[/URL]
If you want a lua-only implementation, someone has made it on here before.. you'll have to search for it though.[/QUOTE]
Already figured out what to use, forgot to snip it but thanks.
[QUOTE=wauterboi;47487588]What's the best way to network spread between clients?[/QUOTE]
Use [url]http://wiki.garrysmod.com/page/util/SharedRandom[/url] for whatever degree of randomness you have and you don't have to network it at all.
[QUOTE=Sheeplie;47424040]I'm trying to use GM:PlayerDeath and chat.AddText so that each time a player dies, it will print something to the chatbox. The problem is, PlayerDeath is serverside and chat.Addtext is clientside. Not sure what to do.[/QUOTE]
Maybe try using nets?
[QUOTE]Having a problem when trying to convert the Combine Control swep base over to Nutscript 1.1.
I have tried and tried to get this to work, but no luck.
[CODE]
[ERROR] gamemodes/hl2rp/entities/weapons/weapon_cc_base/sh_helper.lua:180: bad argument #2 to 'LerpAngle' (Angle expected, got nil)
1. LerpAngle - [C]:-1
2. FreeaimThink - gamemodes/hl2rp/entities/weapons/weapon_cc_base/sh_helper.lua:180
3. unknown - gamemodes/hl2rp/entities/weapons/weapon_cc_base/shared.lua:389
[/CODE]
Happen's right when I try to equip my weapon.
[CODE]self.currentFreeAimOffset = LerpAngle(FrameTime() * 10, self.currentFreeAimOffset, self.freeAimOffset)[/CODE]
This is the line the error points me too. I am not that experienced in coding, so all of this is complicated to me, but any help is appreciated! There is various other errors, but I'll try and solve them one at a time.[/QUOTE]
[QUOTE=Robotboy655;47459377]self.currentFreeAimOffset is nil.
Do you define it somewhere other then that line?[/QUOTE]
[QUOTE] [CODE]--[[ freeaim ]]--
function SWEP:FreeaimThink()
local FT = FrameTime()
if SERVER then
-- freeaim stuff (serverside)
if self.useFreeaim then
if not self:InSights() then
local goalOffset, faLimit = self.freeAimOffset, self.freeAimLimit
local delta = self:GetAngularVelocity() * FT * self.freeAimSpeed
local length = (goalOffset.p - delta.p)^2 + (goalOffset.y - delta.y)^2
if length > (faLimit^2) then
local norm1, norm2 = goalOffset:Forward(), (goalOffset - delta):Forward()
local nAng = norm1:AngleEx(norm2) -- angle between the two points
-- we only care to take pitch and yaw
goalOffset.p = nAng.p
goalOffset.y = nAng.y
else
-- no need for fancy maths
goalOffset = goalOffset - delta
end
self.freeAimOffset = goalOffset
else
self.freeAimOffset = Angle(0, 0, 0)
end
end
else
-- freeaim stuff (clientside)
if self.useFreeaim then
if not self:InSights() then
local goalOffset, faLimit = self.freeAimOffset, self.freeAimLimit
local delta = self:GetAngularVelocity() * FT * self.freeAimSpeed
local length = (goalOffset.p - delta.p)^2 + (goalOffset.y - delta.y)^2
if length > (faLimit^2) then
local norm1, norm2 = goalOffset:Forward(), (goalOffset - delta):Forward()
local nAng = norm1:AngleEx(norm2) -- angle between the two points
-- we only care to take pitch and yaw
goalOffset.p = nAng.p
goalOffset.y = nAng.y
else
-- no need for fancy maths
goalOffset = goalOffset - delta
end
self.freeAimOffset = goalOffset
self.currentFreeAimOffset = LerpAngle(FrameTime() * 10, self.currentFreeAimOffset, self.freeAimOffset)
else
self.freeAimOffset = Angle(0, 0, 0)
self.currentFreeAimOffset = LerpAngle(FrameTime() * 10, self.currentFreeAimOffset, self.freeAimOffset)
end
if self.nextFreeAimSync <= CurTime() then -- keep it in sync, just to avoid rounding errors.
-- i realize im trusting the client, but it keeps it from being super jumpy and still keeps it in sync
net.Start("fa_sync_s")
net.WriteAngle(self.freeAimOffset)
net.SendToServer()
self.nextFreeAimSync = CurTime() + 1
end
end
end
end[/CODE]
here is the full code, if it helps, as I edited into my post, I am not THAT experienced, and am only editting this base to work over on Nutscript, so I'm not sure. This is probably a bit advanced for me, but I'm doing it just for the practice and experience.[/QUOTE]
Still need help, lol.
you are using self.currentFreeAimOffset to define itself when it does not exist yet.
-snip-
[QUOTE=skullorz;47493048]you are using self.currentFreeAimOffset to define itself when it does not exist yet.[/QUOTE]
Where would I define it? Sorry, still new to this..
How would I detect if a player is stuck in something? I've tried this but it gets loads of false positives
[lua]
local function isstuck(ply)
print("checking stuck")
local pos=ply:LocalToWorld(ply:OBBCenter())
local td={}
td.start=pos
td.endpos=pos
td.mins=ply:OBBMins()
td.maxs=ply:OBBMaxs()
td.filter={ply}
local tr=util.TraceHull(td)
PrintTable(tr)
return tr.Hit
end
[/lua]
[QUOTE=A Fghtr Pilot;47492900]Maybe try using nets?[/QUOTE]
maybe don't reply to a question on page one?
also, it was already solved, by using game events.
Why can I join my dedicated server, but get this when I launch a local game on the same map:
[code]
Dropped Hoffa from server (Server out of date)
Disconnect: Server out of date.
Disconnect: Server out of date.
[/code]
The error message "You dont have css installed for the textures" thing keeps popping up on my darkrp server. I know its because they dont own CounterStrike Source but I need to disable that error message but i just dont know how.
[QUOTE=meowking1;47497130]The error message "You dont have css installed for the textures" thing keeps popping up on my darkrp server. I know its because they dont own CounterStrike Source but I need to disable that error message but i just dont know how.[/QUOTE]
It's because your server doesn't have cstrike content installed. Most hosts have an easy way to install it, but you might have to do it yourself.
[QUOTE=Abinox01;47497538]What is the function to add health?[/QUOTE]
[lua]ply:SetHealth(ply:Health() + x);[/lua]
[editline]10th April 2015[/editline]
I dont even code.
[editline]10th April 2015[/editline]
Ninja'd.
[QUOTE=Abinox01;47497538]What is the function to add health?[/QUOTE]
Dude, google? "gmod lua add health"
[QUOTE=G4MB!T;47497621][lua]ply:SetHealth(ply:GetHealth() + x);[/lua]
[editline]10th April 2015[/editline]
Ninja'd.[/QUOTE]
That wouldn't work anyways since someone decided to make it :Health and not :GetHealth. Seriously, why is there still not an alias for this?
[QUOTE=rotor2;47497919]That wouldn't work anyways since someone decided to make it :Health and not :GetHealth. Seriously, why is there still not an alias for this?[/QUOTE]
Thanks, fixed that. You can make your own alias by doing ply.GetHealth = ply.Health. As for the reasoning for the lack of alias, I dont have the answer but straight up changing it in an update would break a lot of legacy code.... Like... A lot.
How do you give a nextbot a weapon? Standard "Give" doesnt work
[QUOTE=G4MB!T;47497981]Thanks, fixed that. You can make your own alias by doing ply.GetHealth = ply.Health. As for the reasoning for the lack of alias, I dont have the answer but straight up changing it in an update would break a lot of legacy code.... Like... A lot.[/QUOTE]
would it be worth it too make two functions that do the exact same thing or will everyone have a cry?
[QUOTE=AnonTakesOver;47498259]would it be worth it too make two functions that do the exact same thing or will everyone have a cry?[/QUOTE]
All you need to do is to add a global variable that copies the function. Really if anyone thinks it's so dumb that it's Health and not GetHealth, well, just add GetHealth then.
[QUOTE=Author.;47497158]It's because your server doesn't have cstrike content installed. Most hosts have an easy way to install it, but you might have to do it yourself.[/QUOTE]
Its not that one, I already have CSS mounted onto the server. Its the one for individuals who do not own CSS (But most of whom already downloaded the textures elsewhere)
[QUOTE=Author.;47498289]All you need to do is to add a global variable that copies the function. Really if anyone thinks it's so dumb that it's Health and not GetHealth, well, just add GetHealth then.[/QUOTE]
true, ive always thought it's annoying but never enough for me to make my own GetHealth alias.
[QUOTE=meowking1;47498352]Its not that one, I already have CSS mounted onto the server. Its the one for individuals who do not own CSS (But most of whom already downloaded the textures elsewhere)[/QUOTE]
DarkRP only checks for CS:S serverside. Must be some addon.
[QUOTE=Bo98;47498401]DarkRP only checks for CS:S serverside. Must be some addon.[/QUOTE]
I was unaware of that, do you know any popular addons that it might be the case in?
[QUOTE=Exho;47498235]How do you give a nextbot a weapon? Standard "Give" doesnt work[/QUOTE]
If I remember rightly you have to do it all by hand... equipping, running the weapon fire function for that weapon.
Its rather a pain.
[QUOTE=AnonTakesOver;47498259]would it be worth it too make two functions that do the exact same thing or will everyone have a cry?[/QUOTE]
Sure its worth it but it raises a few points. Why do we need GetHealth when there is a function (Health) that does the exact same thing? For consistency right? Well since the functionality is already there, its a waste of time. There is also the point of having 2 functions doing the exact same thing. Removing Health and replacing it with GetHealth obviously will break the universe like I noted before. But the real question is, why did this happen in the first place? It doesnt take a professional to say "We have SetHealth, the logical opposite would be GetHealth", it was poor API design by whoever implemented it (Assuming it was Garry) and, while it isnt too late to change, it will have to be deprecated then replaced.
[QUOTE=Th13teen;47498466]If I remember rightly you have to do it all by hand... equipping, running the weapon fire function for that weapon.
Its rather a pain.[/QUOTE]
Alright well how do I give them a world model then for a specific gun? Are there any addons that do this that I could use for example code?
[QUOTE=Author.;47498289]All you need to do is to add a global variable that copies the function. Really if anyone thinks it's so dumb that it's Health and not GetHealth, well, just add GetHealth then.[/QUOTE]
We shouldn't have to do that. Go to the wiki page for the entity and player metas and look at the amount of Set functions that have a Get counterpart. Why is Health different? It takes one line to do add an alias, and will save us from the posts of "why is GetHealth nil?".
Stop defending bad design.
Alright, so I'm have a small problem with the TTTBodyFound hook.
[CODE]local function findBody( ply, deadply, rag )
((This bit of code is by another author and is thus censored.))
end
hook.Add("TTTBodyFound", "Levels_TTTFoundBody", findBody)[/CODE]
The function is supposed to add a bit of EXP for the leveling system on my server. It's a simple single line that I have working perfectly in several other places in the same LUA file. For example:
[CODE]local function DNAGet( ply, dnaOwner, ent )
((Exact same censored code as above))
end
hook.Add( "TTTFoundDNA", "Levels_TTTFoundDNA", DNAGet)[/CODE]
That function and hook works perfectly fine. When a person gets DNA off of a body, it gives them the exp as it should. But the one for finding a body doesn't work. I've sat and stared at this thing for several minutes, and I feel like I'm making some obvious mistake that I'm just not seeing. I'd really appreciate it if someone could point it out to me.
Also since I'm here anyway, what's a good way to return the amount of karma a player has? If there is a simple method that is.
Sorry, you need to Log In to post a reply to this thread.