Got it looking like
[t]http://puu.sh/1pduL[/t]
after turning off the font antialias.
Looks better in my opinion.
[QUOTE=zerothefallen;38406265]Why is it that this swep now is completely broke? I've tried looking into it but I don't understand it.
[lua]
local vectur = Vector(0, ply:GetAngles().y, 0)
turret:SetAngles(vectur)
turret:PhysWake()
turret:SetHealth(400)
local phys = turret:GetPhysicsObject()
self:Remove()
[/lua]
The problem I am having is that the turret isn't facing where the player is, somehow SetAngles broke. Did it change? Not only that, whenever the weapon is used self:Remove() isn't happening.
The full file is here
[url]https://dl.dropbox.com/u/34091117/shared.lua[/url][/QUOTE]
I attempted to change the angles again and no success. No word?
Since I know pretty much nothing about lua (except the simple stuff) - I was wondering if it would be possible to create a lua script, that when someone says "!join server2" or "!join 2" they get automatically dropped from the current server, and automatically connected to the other server.
Thanks for any help, Maddog.
[QUOTE=Maddog2k62k7;38416332]Since I know pretty much nothing about lua (except the simple stuff) - I was wondering if it would be possible to create a lua script, that when someone says "!join server2" or "!join 2" they get automatically dropped from the current server, and automatically connected to the other server.
Thanks for any help, Maddog.[/QUOTE]
Quite simply. Something like this inside a clientside script should work fairly well:
[lua]
local servers = { "127.0.0.1", "8.8.8.8", "8.8.4.4" }
local function changeserver( ply, message )
if (string.sub(message, 1, 5) == "!join") then
RunConsoleCommand("connect", servers[string.sub(message, 6)])
end
end
hook.Add("OnPlayerChat", "playerchangeserver", changeserver)
[/lua]
I haven't actually tested it but the basic idea should be fine.
[QUOTE=jmazouri;38416482]Quite simply. Something like this inside a clientside script should work fairly well:
[lua]
local servers = { "127.0.0.1", "8.8.8.8", "8.8.4.4" }
local function changeserver( ply, message )
if (string.sub(message, 1, 5) == "!join") then
RunConsoleCommand("connect", servers[string.sub(message, 6)])
end
end
hook.Add("OnPlayerChat", "playerchangeserver", changeserver)
[/lua]
I haven't actually tested it but the basic idea should be fine.[/QUOTE]
Thank you, so I'm assuming the "local servers" would be changed to the IP's and each one is server 1/2/3 accordingly?
[QUOTE=Maddog2k62k7;38416510]Thank you, so I'm assuming the "local servers" would be changed to the IP's and each one is server 1/2/3 accordingly?[/QUOTE]
Yup. Usage should be "!join x".
Isn't "connect" blacklisted?
[QUOTE=jmazouri;38416519]Yup. Usage should be "!join x".[/QUOTE]
garrysmod/lua/autorun/client
correct?, along with name "serverjoin.lua" maybe?
I've got a quick question that's probably stupid because I haven't done any lua coding other than editing before. I'm editing Goldenforge so that the hats are in different places for different models (they get stuck in the heads of some), but I don't know the variable for playermodels in TTT, so what is it?. Also, have I made any mistakes in what I've done so far, other than that and the positions being the same?
[QUOTE]
if playermodel = phoenix.mdl then
if (attachment) then
position, angles = attachment.Pos, attachment.Ang
position = position -(angles:Forward() *7) +(angles:Up() *12)
angles:RotateAroundAxis(angles:Right(), 20)
elseif playermodel = arctic.mdl then
if (attachment) then
position, angles = attachment.Pos, attachment.Ang
position = position -(angles:Forward() *7) +(angles:Up() *12)
angles:RotateAroundAxis(angles:Right(), 20)
elseif playermodel guerilla.mdl = then
if (attachment) then
position, angles = attachment.Pos, attachment.Ang
position = position -(angles:Forward() *7) +(angles:Up() *12)
angles:RotateAroundAxis(angles:Right(), 20)
elseif playermodel leet.mdl = then
if (attachment) then
position, angles = attachment.Pos, attachment.Ang
position = position -(angles:Forward() *7) +(angles:Up() *12)
angles:RotateAroundAxis(angles:Right(), 20)
end
[/QUOTE]
I'm trying to make it so you get 'thrown out' of a prop if you're stuck in it awhile after you drop it with your physgun. The prop is made pass-through-able when you drop it until a certain point in time where it throws out any players stuck in it.
Here's the code for it so far:
shared.lua:
[lua]local function PhysgunProtection(ply, ent)
if ent:IsWeapon() == false then
ent:SetCollisionGroup(2)
ent:DrawShadow(false)
ent:SetCustomCollisionCheck(true)
timer.Create( "MakePropNormal", 4 , 1, function()
propphysmarked = ent
timer.Create("MakePropNormal2", 0.1, 1, function()
if ent == propphysmarked then
propphysmarked.MakeNoCollided = 1
ent:SetCollisionGroup(0)
timer.Create("MakePropNormal2.1", 0.1, 1 , function()
ent:SetCollisionGroup(2)
timer.Create("MakePropNormal2.3", 1, 1 , function()
ent:SetCollisionGroup(0)
propphysmarked.MakeNoCollided = 0
ent:DrawShadow(true)
end )
end )
end
end )
end )
end
end
local function PropRepulsion( ent1, ent2)
if ent1:IsWorld() != true then
if ent2:IsWorld() != true then
if ent1 == propphysmarked then
if ent1.MakeNoCollided == 1 then
velocitymoderator = 0
if ent1:BoundingRadius() > 100 then
velocitymoderator = 50
end
if ent1:BoundingRadius() > 300 then
velocitymoderator = 50
end
if ent1:BoundingRadius() > 500 then
velocitymoderator = 400
end
if ent1:BoundingRadius() > 700 then
velocitymoderator = 450
end
if ent1:BoundingRadius() > 900 then
velocitymoderator = 500
end
if ent1:BoundingRadius() > 1100 then
velocitymoderator = 550
end
if ent1:BoundingRadius() > 1300 then
velocitymoderator = 600
end
if ent1:BoundingRadius() > 1500 then
velocitymoderator = 970
end
if ent1:BoundingRadius() > 1700 then
velocitymoderator = 1170
end
if ent1:BoundingRadius() > 1900 then
velocitymoderator = 1370
end
if ent1:BoundingRadius() > 2100 then
velocitymoderator = 1570
end
if ent1:BoundingRadius() > 2300 then
velocitymoderator = 1770
end
if ent1:BoundingRadius() > 2500 then
velocitymoderator = 1950
end
print(ent1:BoundingRadius())
print(velocitymoderator)
ent2:SetVelocity(Vector(ent1:BoundingRadius()+20-velocitymoderator,ent1:BoundingRadius()+20-velocitymoderator,ent1:BoundingRadius()+20-velocitymoderator))
end
end
elseif ent2 == propphysmarked then
if ent2.MakeNoCollided == 1 then
velocitymoderator = 0
if ent2:BoundingRadius() > 100 then
velocitymoderator = 50
end
if ent2:BoundingRadius() > 300 then
velocitymoderator = 50
end
print(ent2:BoundingRadius())
print(velocitymoderator)
ent1:SetVelocity(Vector(ent2:BoundingRadius()+20-velocitymoderator,ent2:BoundingRadius()+20-velocitymoderator,ent2:BoundingRadius()+20-velocitymoderator))
end
end
end
end
hook.Add("ShouldCollide","Player/Prop Protection and Repulsion", PropRepulsion)
hook.Add( "PhysgunDrop", "Physgun Item Ghosting", PhysgunProtection)[/lua]
My problem is that I have no way of averaging out the force of which the players are thrown. Depending on the prop they can either continue to be stuck, just squeeze out, or be thrown half-way across the map. I tried to use a variable called 'velocity moderator' that changes based on the BoundingRadius of the prop, but I'm unable to work out a way to make it so you get pushed just enough for every prop to get out without being thrown half-way across the map.
Any help with this would be appreciated
Not sure what you mean by force but there's entity:GetVelocity():Length2D() which will give you the speed it's going at.
[QUOTE=Chessnut;38417743]Not sure what you mean by force but there's entity:GetVelocity():Length2D() which will give you the speed it's going at.[/QUOTE]
The force and distance traveled is managed through the use of SetVelocity. the velocity is set via the distance of the boundingbox minus the velocitymoderator variable. I can't work out how to average the force of which the player is thrown so that you aren't either barely getting out or thrown accross the map. I tried to use velocitymoderator to do it. It works by having it's value increased as the boundingradius increases. I have to find a way (probably through some mathematics) to have the velocitymoderator increase as the boundingradius does. Ideally this would make it so the resulting velocity only increases and averages out as much as it has to to get the player out of the prop.
I might try and use Length2D to average out the force instead of measuring BoundingRadius, but if anyone has any other ideas, let me know.
Can anyone recommend some online tutorials that describe making a gamemode / addons from start to finish.
I've read the lua book almost completely, but without the stuff from the source engine/gmod its kind of pointless.
[QUOTE=number 1;38419950]Can anyone recommend some online tutorials that describe making a gamemode / addons from start to finish.
I've read the lua book almost completely, but without the stuff from the source engine/gmod its kind of pointless.[/QUOTE]
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8e50.html[/url]
This page goes over your first SWEP. PLEASE do not upload it to garrysmod.org or Workshop. We already have enough of that.
Do you know why this happens?
* that was cam.Start3D() problem. cam is higher priority than normal Paint.
[IMG]http://cloud.steampowered.com/ugc/937008435211255072/F564999AE482F9F7C9BF35E959B2B7E0E364BAA0/[/IMG]
[QUOTE=Darkwater124;38400479]Could we get a fix on GM:PostPlayerDraw() being called twice soon?[/QUOTE]
Is it called twice per player every frame?
[QUOTE=skullorz;38420432]Wrong thread :P[/QUOTE]
aw fuuuu
Next threads add tags please :c
[editline]12th November 2012[/editline]
oh wait nvm
[editline]12th November 2012[/editline]
goddamnit eyes
Well the webdev thing has Questions That Don't Need Their Own Thread
easier to reed
[editline]12th November 2012[/editline]
[QUOTE=KatNotDinner;38421021]Is it called twice per player every frame?[/QUOTE]
[QUOTE=Darkwater124;38339874]Also synced building "ghosts"
[t]http://puu.sh/1n4Zu[/t]
And I think I found something else weird, and I don't think I forgot something this time.
[lua]function drawNames(ply)
....
end
hook.Add("PostPlayerDraw", "drawNames", drawNames)[/lua]
DrawNames can get called twice per player for me:
Not called:
[t]http://puu.sh/1n53V[/t]
Called once:
[t]http://puu.sh/1n54j[/t]
Called twice?
[t]http://puu.sh/1n54s[/t]
[editline]6th November 2012[/editline]
Watch the opacity of the tooltip
[editline]6th November 2012[/editline]
[URL="http://puu.sh/1n55f"]The entire function code if you want to see it[/URL][/QUOTE]
[lua]hook.Add("TTTBeginRound", "BeginMusic", function()
if music:GetInt() != 1 then return end
surface.PlaySound("ttt/guileldstart.mp3")
surface.PlaySound("ttt/roundstart.mp3")
end)[/lua]
How do I make it randomly choose one of those two sounds to play? I know nothing of math.Rand.
[QUOTE=Charrax;38423570][lua]hook.Add("TTTBeginRound", "BeginMusic", function()
if music:GetInt() != 1 then return end
surface.PlaySound("ttt/guileldstart.mp3")
surface.PlaySound("ttt/roundstart.mp3")
end)[/lua]
How do I make it randomly choose one of those two sounds to play? I know nothing of math.Rand.[/QUOTE]
[lua]hook.Add("TTTBeginRound", "BeginMusic", function()
if music:GetInt() != 1 then return end
local randChance = math.random(1, 2)
if randChance == 2 then
surface.PlaySound("ttt/guileldstart.mp3")
else
surface.PlaySound("ttt/roundstart.mp3")
end
end)[/lua]
Use math.random when you want to generate whole numbers (1, 2, 3, etc).
If you have more than two random possibilites I would suggest generating a table as such:
[lua]hook.Add("TTTBeginRound", "BeginMusic", function()
if music:GetInt() != 1 then return end
local randSongs = {
"ttt/guileldstart.mp3",
"ttt/roundstart.mp3"
}
surface.PlaySound(math.random(1, #randSongs))
end)[/lua]
Edit: God dammit
*surface.PlaySound(randSongs[math.random(1, #randSongs)])
[QUOTE=Dark Slayre;38423853]If you have more than two random possibilites I would suggest generating a table as such:
[lua]hook.Add("TTTBeginRound", "BeginMusic", function()
if music:GetInt() != 1 then return end
local randSongs = {
"ttt/guileldstart.mp3",
"ttt/roundstart.mp3"
}
surface.PlaySound(math.random(1, #randSongs))
end)[/lua][/QUOTE]
There's also a table.Random function for if you're using tables, I find it neater
[QUOTE=my_hat_stinks;38423950]There's also a table.Random function for if you're using tables, I find it neater[/QUOTE]
Could you show me that? Both listed above do not work with the reason: "Failed to load sound "1", file probably missing from disk/repository"
[QUOTE=Drakehawke;38424158][lua]
surface.PlaySound(randSongs[math.random(1, #randSongs)])[/lua][/QUOTE]
Thanks. Now adding entries is as simple as:
local randSongs = {
"ttt/guileldstart.mp3",
"ttt/roundstart.mp3",
"ttt/newentry.mp3"
}
How do I change the value of players' IsAdmin() and IsSuperAdmin()?
[editline]12th November 2012[/editline]
With Lua
[QUOTE=Charrax;38424653]Thanks. Now adding entries is as simple as:
local randSongs = {
"ttt/guileldstart.mp3",
"ttt/roundstart.mp3",
"ttt/newentry.mp3"
}[/QUOTE]
That'll work, but as a rule of thumb it's usually better to rely as little on hardcoding as possible, i.e. using file.Find instead of inputting the filenames yourself so you only have to put songs in the folder for them to be used.
Also, do you want every player to hear the same song, or is it permissible for each client to pick one on its own?
[QUOTE=Darkwater124;38424795]How do I change the value of players' IsAdmin() and IsSuperAdmin()?[/QUOTE]
ply:IsAdmin() and ply:IsSuperAdmin() are Lua functions out of [img]http://glua.me/bin.png[/img] [url=http://glua.me/bin/?path=/lua/includes/extensions/player_auth.lua]includes/extensions/player_auth.lua[/url] that rely on ply:IsUserGroup().
Just use ply:SetUserGroup("admin") or ply:SetUserGroup("superadmin").
[QUOTE=Darkwater124;38424795]How do I change the value of players' IsAdmin() and IsSuperAdmin()?
[editline]12th November 2012[/editline]
With Lua[/QUOTE]
Override the metamethods:
[lua]
local meta = FindMetaTable("Player")
function meta:IsAdmin()
return false
end
function meta:IsSuperAdmin()
return false
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.