Is this sort of thing possible?
I was planning on creating a map that would have a comedy club, and there are 50 or so civilian NPCs sitting around watching another NPC give a scripted standup comedy show.
Mainly I want to know if that many NPCs would crash the server, especially if there were other players on?
[QUOTE=jd0124;49663813]Is this sort of thing possible?
I was planning on creating a map that would have a comedy club, and there are 50 or so civilian NPCs sitting around watching another NPC give a scripted standup comedy show.
Mainly I want to know if that many NPCs would crash the server, especially if there were other players on?[/QUOTE]
Depends on how well you code them efficiency-wise (for the 50 NPCs sitting, you could use ragdolls posing) and for the standup you'd have to record some sounds and etc.
It is possible, but I'm not sure what kind of processing you'd need.
they wouldn't need to be npc's, just regular entities with some animation code run on them
.
The prefix should be gmsv_ or gmcl_, not gm_.
[QUOTE=Willox;49664318]The prefix should be gmsv_ or gmcl_, not gm_.[/QUOTE]
And the module has to be in GarrysMod/garrysmod/lua/bin, not GarrysMod/garrysmod/bin
[QUOTE=Windwhistle;49655252]Trying to make this SWEP be useable two times for the whole team.
How I'm doing this is I'm counting the number of traitors and adding 2.
However, when I try to print the values in console, they return nil. Any ideas?
Here's where I print my values...
[code]
function SWEP:PrimaryAttack()
print (numberOfTraitors)
print (numberTefibLimit)
if CLIENT then return end
local tr = util.TraceLine({
start = self.Owner:EyePos(),
endpos = self.Owner:EyePos() + self.Owner:GetAimVector() * 80,
filter = self.Owner
})
if IsValid(tr.Entity) and tr.Entity:GetClass() == "prop_ragdoll" then
if not tr.Entity.uqid then
self:FireError("FAILURE - SUBJECT BRAINDEAD")
return
end
local ply = player.GetByUniqueID(tr.Entity.uqid)
if IsValid(ply) then
self:BeginDefib(ply, tr.Entity)
else
self:FireError("FAILURE - SUBJECT BRAINDEAD")
return
end
else
self:FireError("FAILURE - INVALID TARGET")
end
end
[/code]
Here's my code for the numbers check.
[code]
if (SERVER) then
hook.Add( "TTTBeginRound", "NumberOfTypes", function()
local numberOfTraitors = 0
local numberOfPlayers = 0
for k, v in pairs( player.GetAll() ) do
if v:IsTraitor() and v:Alive() then
numberOfTraitors=numberOfTraitors+1
end
if v:Alive() and !v:IsSpec() then
numberOfPlayers=numberOfPlayers+1
end
end
timer.Simple( .5, function()
PrintMessage( HUD_PRINTTALK, "Traitors: "..numberOfTraitors )
PrintMessage( HUD_PRINTTALK, "Number of Players: "..numberOfPlayers )
end )
local numberTefibLimit = numberOfTraitors + 2
PrintMessage( HUD_PRINTTALK, "Number of Traitors Allowed: "..numberTefibLimit )
end )
end
[/code]
Here's my altered error message in Think...
[code]
function SWEP:Think()
if CLIENT then return end
if self:GetDefibState() == STATE_PROGRESS then
if not IsValid(self.Owner) then
self:FireError()
return
end
if not (IsValid(self.TargetPly) and IsValid(self.TargetRagdoll)) then
self:FireError("ERROR - SUBJECT BRAINDEAD")
return
end
local tr = util.TraceLine({
start = self.Owner:EyePos(),
endpos = self.Owner:EyePos() + self.Owner:GetAimVector() * 80,
filter = self.Owner
})
if tr.Entity ~= self.TargetRagdoll then
self:FireError("ERROR - TARGET LOST")
return
end
if numberOfTraitors == numberTefibLimit then
self:FireError("ERROR - TOO MANY TRAITORS")
return
end
if CurTime() >= self:GetDefibStartTime() + 5 then
if self:HandleRespawn() then
self:FireSuccess()
else
self:FireError("ERROR - INSUFFICIENT ROOM")
return
end
end
self:NextThink(CurTime())
return true
end
end
[/code]
And here's where I produce the amount of traitors and adding and stuff...
[code]
function SWEP:HandleRespawn()
local ply, ragdoll = self.TargetPly, self.TargetRagdoll
local spawnPos = self:FindPosition(self.Owner)
if not spawnPos then
return false
end
local credits = CORPSE.GetCredits(ragdoll, 0)
local health = 50
if ragdoll:GetRole() == "ROLE_INNOCENT" or ragdoll:GetRole() == "ROLE_DETECTIVE" then
numberOfTraitors = numberOfTraitors + 1
end
ply:SpawnForRound(true)
ply:SetCredits(credits)
ply:SetRole(ROLE_TRAITOR)
ply:SetHealth(health)
SendFullStateUpdate()
ply:SetPos(spawnPos)
ply:SetEyeAngles(Angle(0, ragdoll:GetAngles().y, 0))
ragdoll:Remove()
return true
end
[/code]
If you need any addition code to help, I'll be more than happy to provide it.[/QUOTE]
No one can tell me what I'm doing wrong. ;D;
[QUOTE=Windwhistle;49667206]No one can tell me what I'm doing wrong. ;D;[/QUOTE]
FireError isn't a Garry's Mod function, and I don't see a declaration for it anywhere in your code. Am I missing something?
[QUOTE=roastchicken;49667359]FireError isn't a Garry's Mod function, and I don't see a declaration for it anywhere in your code. Am I missing something?[/QUOTE]
That's not the whole code, that's just parts of it.
Here's the full SWEP:
[code]
local STATE_NONE, STATE_PROGRESS, STATE_ERROR = 0, 1, 2
local color_red = Color(255, 0, 0)
SWEP.Base = "weapon_tttbase"
SWEP.HoldType = "slam"
SWEP.ViewModel = Model("models/weapons/v_c4.mdl")
SWEP.WorldModel = Model("models/weapons/w_c4.mdl")
--- TTT Vars
SWEP.Kind = WEAPON_EQUIP2
SWEP.AutoSpawnable = false
SWEP.CanBuy = {ROLE_TRAITOR}
SWEP.LimitedStock = true
if CLIENT then
SWEP.PrintName = "T-Defibrillator"
SWEP.Slot = 7
SWEP.Icon = "windfrontier/wf_defibrillator"
SWEP.EquipMenuData = {
type = "item_weapon",
name = "T-Defribrillator",
desc = "Resurrect dead teammates with this one! An innocent can also be brought back as a traitor!"
}
surface.CreateFont("DefibText", {
font = "Tahoma",
size = 13,
weight = 700,
shadow = true
})
function SWEP:DrawHUD()
local state = self:GetDefibState()
local scrW, scrH = ScrW(), ScrH()
local progress = 1
local outlineCol, progressCol, progressText = color_white, color_white, ""
if state == STATE_PROGRESS then
local startTime, endTime = self:GetDefibStartTime(), self:GetDefibStartTime() + 5
progress = math.TimeFraction(startTime, endTime, CurTime())
if progress <= 0 then
return
end
outlineCol = Color(0, 100, 0)
progressCol = Color(0, 255, 0, (math.abs(math.sin(RealTime() * 3)) * 100) + 20)
progressText = self:GetStateText() or "DEFIBRILLATING"
elseif state == STATE_ERROR then
outlineCol = color_red
progressCol = Color(255, 0, 0, math.abs(math.sin(RealTime() * 15)) * 255)
progressText = self:GetStateText() or ""
else
return
end
progress = math.Clamp(progress, 0, 1)
surface.SetDrawColor(outlineCol)
surface.DrawOutlinedRect(scrW / 2 - (200 / 2) - 1, scrH / 2 + 10 - 1, 202, 16)
surface.SetDrawColor(progressCol)
surface.DrawRect(scrW / 2 - (200 / 2), scrH / 2 + 10, 200 * progress, 14)
surface.SetFont("DefibText")
local textW, textH = surface.GetTextSize(progressText)
surface.SetTextPos(scrW / 2 - 100 + 2, scrH / 2 - 20 + textH)
surface.SetTextColor(color_white)
surface.DrawText(progressText)
end
end
function SWEP:SetupDataTables()
self:NetworkVar("Int", 0, "DefibState")
self:NetworkVar("Float", 1, "DefibStartTime")
self:NetworkVar("String", 0, "StateText")
end
function SWEP:Initialize()
self:SetDefibState(STATE_NONE)
self:SetDefibStartTime(0)
end
function SWEP:Deploy()
self:SetDefibState(STATE_NONE)
self:SetDefibStartTime(0)
return true
end
function SWEP:Holster()
self:SetDefibState(STATE_NONE)
self:SetDefibStartTime(0)
return true
end
if (SERVER) then
hook.Add( "TTTBeginRound", "NumberOfTypes", function()
local numberOfTraitors = 0
local numberOfPlayers = 0
for k, v in pairs( player.GetAll() ) do
if v:IsTraitor() and v:Alive() then
numberOfTraitors=numberOfTraitors+1
end
if v:Alive() and !v:IsSpec() then
numberOfPlayers=numberOfPlayers+1
end
end
PrintMessage( HUD_PRINTTALK, "Traitors: "..numberOfTraitors )
PrintMessage( HUD_PRINTTALK, "Number of Players: "..numberOfPlayers )
local numberTefibLimit = numberOfTraitors + 2
PrintMessage( HUD_PRINTTALK, "Number of Traitors Allowed: "..numberTefibLimit )
end )
end
function SWEP:PrimaryAttack()
print (numberOfTraitors)
print (numberTefibLimit)
if CLIENT then return end
local tr = util.TraceLine({
start = self.Owner:EyePos(),
endpos = self.Owner:EyePos() + self.Owner:GetAimVector() * 80,
filter = self.Owner
})
if IsValid(tr.Entity) and tr.Entity:GetClass() == "prop_ragdoll" then
if not tr.Entity.uqid then
self:FireError("FAILURE - SUBJECT BRAINDEAD")
return
end
local ply = player.GetByUniqueID(tr.Entity.uqid)
if IsValid(ply) then
self:BeginDefib(ply, tr.Entity)
else
self:FireError("FAILURE - SUBJECT BRAINDEAD")
return
end
else
self:FireError("FAILURE - INVALID TARGET")
end
end
function SWEP:BeginDefib(ply, ragdoll)
local spawnPos = self:FindPosition(self.Owner)
if not spawnPos then
self:FireError("FAILURE - INSUFFICIENT ROOM")
return
end
self:SetStateText("DEFIBRILLATING - "..string.upper(ply:Name()))
self:SetDefibState(STATE_PROGRESS)
self:SetDefibStartTime(CurTime())
self.TargetPly = ply
self.TargetRagdoll = ragdoll
self:SetNextPrimaryFire(CurTime() + 6)
end
function SWEP:FireError(err)
if err then
self:SetStateText(err)
else
self:SetStateText("")
end
self:SetDefibState(STATE_ERROR)
timer.Simple(1, function()
if IsValid(self) then
self:SetDefibState(STATE_NONE)
self:SetStateText("")
end
end)
self:SetNextPrimaryFire(CurTime() + 1.2)
end
function SWEP:FireSuccess()
self:SetDefibState(STATE_NONE)
self:SetNextPrimaryFire(CurTime() + 1)
hook.Call("UsedDefib", GAMEMODE, self.Owner)
self:Remove()
end
function SWEP:Think()
if CLIENT then return end
if self:GetDefibState() == STATE_PROGRESS then
if not IsValid(self.Owner) then
self:FireError()
return
end
if not (IsValid(self.TargetPly) and IsValid(self.TargetRagdoll)) then
self:FireError("ERROR - SUBJECT BRAINDEAD")
return
end
local tr = util.TraceLine({
start = self.Owner:EyePos(),
endpos = self.Owner:EyePos() + self.Owner:GetAimVector() * 80,
filter = self.Owner
})
if tr.Entity ~= self.TargetRagdoll then
self:FireError("ERROR - TARGET LOST")
return
end
if numberOfTraitors == numberTefibLimit then
self:FireError("ERROR - TOO MANY TRAITORS")
return
end
if CurTime() >= self:GetDefibStartTime() + 5 then
if self:HandleRespawn() then
self:FireSuccess()
else
self:FireError("ERROR - INSUFFICIENT ROOM")
return
end
end
self:NextThink(CurTime())
return true
end
end
function SWEP:HandleRespawn()
local ply, ragdoll = self.TargetPly, self.TargetRagdoll
local spawnPos = self:FindPosition(self.Owner)
if not spawnPos then
return false
end
local credits = CORPSE.GetCredits(ragdoll, 0)
local health = 50
if ragdoll:GetRole() == "ROLE_INNOCENT" or ragdoll:GetRole() == "ROLE_DETECTIVE" then
numberOfTraitors = numberOfTraitors + 1
end
ply:SpawnForRound(true)
ply:SetCredits(credits)
ply:SetRole(ROLE_TRAITOR)
ply:SetHealth(health)
SendFullStateUpdate()
ply:SetPos(spawnPos)
ply:SetEyeAngles(Angle(0, ragdoll:GetAngles().y, 0))
ragdoll:Remove()
return true
end
local Positions = {}
for i=0,360,22.5 do table.insert( Positions, Vector(math.cos(i),math.sin(i),0) ) end -- Populate Around Player
table.insert(Positions, Vector(0, 0, 1)) -- Populate Above Player
function SWEP:FindPosition(ply)
local size = Vector(32, 32, 72)
local StartPos = ply:GetPos() + Vector(0, 0, size.z/2)
local len = #Positions
for i = 1, len do
local v = Positions[i]
local Pos = StartPos + v * size * 1.5
local tr = {}
tr.start = Pos
tr.endpos = Pos
tr.mins = size / 2 * -1
tr.maxs = size / 2
local trace = util.TraceHull(tr)
if(not trace.Hit) then
return Pos - Vector(0, 0, size.z/2)
end
end
return false
end
[/code]
So I'm spawning zombies and using SetModel() on them for an alternate model, however when i kill one the dead ragdoll that spawns out is the original zombie model.
Any idea what causes this or will i have to use CreateClientsideRagdoll/CreateEntityRagdoll to override the default system and make my own?
[QUOTE=101kl;49669028]So I'm spawning zombies and using SetModel() on them for an alternate model, however when i kill one the dead ragdoll that spawns out is the original zombie model.
Any idea what causes this or will i have to use CreateClientsideRagdoll/CreateEntityRagdoll to override the default system and make my own?[/QUOTE]
Is SetModel being called shared? I'm also having some problems with Get/SetModel where GetModel is returning the old model for the client but the correct one on the server.
[QUOTE=BillyOnWiiU;49659698]Look at the button and do:
lua_run print(player.GetBySteamID("your steamiddd"):GetEyeTrace().Entity:EntIndex())
in RCON and then upon PlayerInitialSpawn use:
Entity(the number RCON returned):Remove()[/QUOTE]
I'll clarify what I meant, I need a way to block [B]specific[/B] players from activating buttons created by the map. I'm trying make a button claiming system for Deathrun that will only allow the player who claimed the button to activate it.
[QUOTE=TheEmp;49669098]I'll clarify what I meant, I need a way to block [B]specific[/B] players from activating buttons created by the map. I'm trying make a button claiming system for Deathrun that will only allow the player who claimed the button to activate it.[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/EntIndex]Entity:EntIndex[/url], [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/Use]ENTITY/Use[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetNWEntity]Entity:SetNWEntity[/url]?
[QUOTE=YourStalker;49669092]Is SetModel being called shared? I'm also having some problems with Get/SetModel where GetModel is returning the old model for the client but the correct one on the server.[/QUOTE]
Well i am indeed calling SetModel on the client, but it's via a net.send after and I'm not sure it likes that.
[QUOTE=MPan1;49663167]Can you use fonts in Workshop addons (as in when a client downloads the addon, the fonts actually work)? I remember reading somewhere they were disabled or something like that... also, to get them to work, do you only need to put the font in the 'resources' folder of your addon and add a resource.AddFile with a path to the font, or is there something else I missed?[/QUOTE]
Bump :P
[QUOTE=BillyOnWiiU;49659698]Look at the button and do:
lua_run print(player.GetBySteamID("your steamiddd"):GetEyeTrace().Entity:EntIndex())
in RCON and then upon PlayerInitialSpawn use:
Entity(the number RCON returned):Remove()[/QUOTE]
Entity:MapCreationID() would be a better option, sometimes EntIndex() is inconsistent
edit:
if he just wants to make a button claiming system then EntIndex() will do
[QUOTE=MPan1;49669359]Bump :P[/QUOTE]
I think workshop does not let you add fonts to addons, Iirc.
[editline]4th February 2016[/editline]
[QUOTE=Arizard;49669455]Entity:MapCreationID() would be a better option, sometimes EntIndex() is inconsistent[/QUOTE]
But he only wants it for a Deathrun button protection system, there's no need to actually save the map entity ID since all information only needs to be stored for the round.
I am moving NPCs with this code:
[CODE]
npc:SetLastPosition( pos )
npc:SetSchedule( SCHED_FORCED_GO_RUN )
[/CODE]
Is there an event to hook or a function that runs when they have reached their destination or gotten as close as possible?
[QUOTE=jd0124;49670704]I am moving NPCs with this code:
[CODE]
npc:SetLastPosition( pos )
npc:SetSchedule( SCHED_FORCED_GO_RUN )
[/CODE]
Is there an event to hook or a function that runs when they have reached their destination or gotten as close as possible?[/QUOTE]
I always store all ordered npcs into a table, and then I use a constant timer to check if they are at a certain distance from their target position in a for loop.
[img]http://puu.sh/mVxoP/dc36ee6f51.png[/img]
[img]http://puu.sh/mVxq3/3d53b62354.jpg[/img]
How can I keep the spacing consistent through resolutions. I am a bit discouraged to post my code because its absolutely horrible
[code] PAYOUT:SetPos( MF:GetWide()/2-MF:GetWide()/11, MF:GetTall()/1.14)
PAYOUT:SetText( "Rewards" )
PAYOUT:SetSize( MF:GetWide()*0.15, MF:GetTall()*0.1 )
PAYOUT.DoClick = function()
local REWPANEL = vgui.Create ('DFrame', SLOTS)
REWPANEL:SetSize(100,100)
REWPANEL:SetPos(0,0)
REWPANEL:ShowCloseButton(true)
end[/code]
[QUOTE=FreddiRox!;49670979][img]http://puu.sh/mVxoP/dc36ee6f51.png[/img]
[img]http://puu.sh/mVxq3/3d53b62354.jpg[/img]
How can I keep the spacing consistent through resolutions. I am a bit discouraged to post my code because its absolutely horrible
[code] PAYOUT:SetPos( MF:GetWide()/2-MF:GetWide()/11, MF:GetTall()/1.14)
PAYOUT:SetText( "Rewards" )
PAYOUT:SetSize( MF:GetWide()*0.15, MF:GetTall()*0.1 )
PAYOUT.DoClick = function()
local REWPANEL = vgui.Create ('DFrame', SLOTS)
REWPANEL:SetSize(100,100)
REWPANEL:SetPos(0,0)
REWPANEL:ShowCloseButton(true)
end[/code][/QUOTE]
Is the window thats open going to be there forever? Or is it just an info window to show that you won or something. Also, what are you using to draw that text that says "reel machine"?
[code]NAME:SetPos( 0, 0 )
NAME:SetSize(ScrW()*0.3,ScrH()*0.3)
NAME.Paint = function ()
draw.DrawText( "REEL MACHINE", "MachineName", MF:GetWide()/2, MF:GetTall()*0.05, Color( 255, 255, 255, 30 ), TEXT_ALIGN_CENTER )
end
[/code]
Thats for the machine name, and its just a info box that opens when you hit rewards. This is the first lua project I've done, I started in Summer but only just came back to it today so I'm very rusty
[QUOTE=FreddiRox!;49671068][code]NAME:SetPos( 0, 0 )
NAME:SetSize(ScrW()*0.3,ScrH()*0.3)
NAME.Paint = function ()
draw.DrawText( "REEL MACHINE", "MachineName", MF:GetWide()/2, MF:GetTall()*0.05, Color( 255, 255, 255, 30 ), TEXT_ALIGN_CENTER )
end
[/code]
Thats for the machine name, and its just a info box that opens when you hit rewards. This is the first lua project I've done, I started in Summer but only just came back to it today so I'm very rusty[/QUOTE]
What's the code for that window, is it what's above in the OP?
Yes
[QUOTE=FreddiRox!;49671158]Yes[/QUOTE]
try using subtraction to decrease the size of the window vertically(height-wise) instead of multiplication. Multiplying/dividing returns slightly changed answers when changing the number that you're dividing, so it's either going to be a little more or a little less depending on if someone's monitor who joins is larger or smaller than the one you're building it off of. I hope this makes sense.
Once you have it setup with subtraction, try chaning your screen resoltuion and seeing if it scales correctly.
If that doesn't work, which it probably won't with scaling, try
windowl:SetSize( x, BaseFrame:GetTall() / 2 ); --change the value of 2 to something that works for you by the way
[QUOTE=Windwhistle;49667206]No one can tell me what I'm doing wrong. ;D;[/QUOTE]
You're trying to print numberOfTraitors and numberTefibLimit outside of their scope. You're declaring them as local variables in a hook function, and trying to print them in a SWEP function. Declare them outside of any functions and you should be good to go.
Hello, I want to make my own hit system and the easiest way I have found to do it is to copy and paste the /warrant code a edit it to be a hit system. Sadly I do not know where the /warrant code is so if someone could tell me I would greatly appreciate it!
[QUOTE=ShadowHedge;49672389]Hello, I want to make my own hit system and the easiest way I have found to do it is to copy and paste the /warrant code a edit it to be a hit system. Sadly I do not know where the /warrant code is so if someone could tell me I would greatly appreciate it![/QUOTE]
How about make your own system so that you actually understand how it works instead of pasting?
[QUOTE=HappyGhetto;49672418]How about make your own system so that you actually understand how it works instead of pasting?[/QUOTE]
[QUOTE=ShadowHedge;49672389]Hello, I want to make my own hit system and the easiest way I have found to do it is to copy and paste the /warrant code a edit it to be a hit system. Sadly I do not know where the /warrant code is so if someone could tell me I would greatly appreciate it![/QUOTE]
i'm a little suspicious of this being the same guy
Is there a way i can get the Pathfollower to pretend a specified NavArea doesn't exist when making a path?
Sorry, you need to Log In to post a reply to this thread.