[QUOTE=VashBaldeus;46207566]Thanks for the idea, though I am having some trouble using ply:SequenceDuration().. gives this:
[code]
[ERROR] lua/autorun/server/ph_tmenu.lua:9: attempt to index local 'ply' (a number value)
1. func - lua/autorun/server/ph_tmenu.lua:9
2. unknown - lua/includes/modules/net.lua:32
[/code]
code:
[code]if ( SERVER ) then
local TAUNT_DELAY = 1
local lastTauntTime = 0
//Menu Page 1
//Button1
util.AddNetworkString("send_p1_B1")
net.Receive( "send_p1_B1", function( ply )
local tSound = net.ReadString()
local tString = ply:SequenceDuration(SoundDuration(tSound))// This is the line the error is speaking about.
local tLength = ply:SequenceDuration(tString)
if tLength >= TAUNT_DELAY then
for _,ply in pairs(player.GetAll()) do
ply:EmitSound(tSound)
print("Should Play sound")
end
else
print("Wait until the taunt is finished.")
end
end )
end[/code][/QUOTE]
Uh. 1, if the entity (player) is running a sequence already, you don't need to put in an argument. 2, if there is an argument, it must be the ID of the sequence in question.
Something like
ply:LookupSequence( TauntSequenceString )
would get you the right argument. You're trying to reference a sound? wtf? I'm confused.
[QUOTE=RonanZer0;46208325]What would be the most efficient way to code a double-kill kind of system?
Naturally the first candidate would be [b]time[/b]rs, but they activate a function after a certain amount of time, not detect something within a time frame.[/QUOTE]
Set a boolean value to false after a certain time. On player death, check if the boolean value is true, if not set to true, if true, announce double kill.
According to the wiki, the one argument for SequenceDuration( arg ) is
arg = A sequence ID to return the length specific sequence of instead of the entity's main/currently playing sequence.
[editline]to make sense[/editline]
I got automerge blocked
I am having a problem adding this job to my server. It seems there is something wrong with the code but I can't find it. When I enter my server the job is not there but my other custom ones are, here is the code.
[LUA] TEAM_SWAT = AddExtraTeam("S.W.A.T", {
color = Color( 70, 70, 70, 225),
model = {"models//player/ct_gsg9.mdl"},
description = [[You are a S.W.A.T member and one of the best protectors of the city! Patrol the city just like a civil protection and use your special weapons to take down criminals!]],
weapons = {"weapon_charge"},
command = "swat",
max = 5,
salary = 80,
admin - 0,
vote = false,
hasLicense = false,
})
[/LUA]
model = {"models//player/ct_gsg9.mdl"},
one / too much.
[QUOTE=WalkingZombie;46208354]Uh. 1, if the entity (player) is running a sequence already, you don't need to put in an argument. 2, if there is an argument, it must be the ID of the sequence in question.
Something like
ply:LookupSequence( TauntSequenceString )
would get you the right argument. You're trying to reference a sound? wtf? I'm confused.[/QUOTE]
I am trying to make that the script checks if the the sound the player is trying to activate is longer or equal to the delay. Meaning if the sound length is lower or equal to delay then it should play the sound if not then send message about delay until sound finished playing.
Ok so I posted something here about my swat job which was not showing up on my server. A person told me to delete one of the / in my model name (i"m not going to state the persons profile but thank you for who did it)
but the job still isn't there. When I enter the game it says something is creating script errors so I know it's something with the code, or it may be the place I put it (1 space below my other custom job). Here is the code and if you have the solution please reply.
[LUA]TEAM_SWAT = AddExtraTeam("S.W.A.T", {
color = Color( 70, 70, 70, 225),
model = {"models/player/ct_gsg9.mdl"},
description = [[You are a S.W.A.T member and one of the best protectors of the city! Patrol the city just like a civil protection and use your special weapons to take down criminals!]],
weapons = {"weapon_charge"},
command = "swat",
max = 5,
salary = 80,
admin - 0,
vote = false,
hasLicense = false,
})
[/LUA]
admin - 0 should be admin = 0
How do I set a global variable that goes for multiple functions but is per each player?
[QUOTE=VashBaldeus;46208752]How do I set a global variable that goes for multiple functions but is per each player?[/QUOTE]
Get the player object somehow and set the variable on that object.
For example:
[lua]
local ply = LocalPlayer();
ply.Whatever = "hi";
[/lua]
How can I make self valid?
[CODE]function Creationsystem(self)
if !IsValid(self) then return end
local getpotion = net.ReadString()
if getpotion == "essencehealths" then
self:SetEssenceofhealth(self:GetEssenceofhealth() - 1)
self:SetHoney(self:GetHoney() - 2)
self:SetBoiledwater(self:GetBoiledwater() - 3)
ServerLog(self:GetHoney() .. "\n")
end
end
net.Receive("createpotions", Creationsystem)[/CODE]
Error
[CODE][ERROR] lua/includes/util.lua:173: attempt to index local 'object' (a number val
ue)
1. IsValid - lua/includes/util.lua:173
2. func - addons/alchemy_table/lua/entities/alchemytable/init.lua:52
3. unknown - lua/includes/modules/net.lua:32
[/CODE]
I've tried so many ways and it's still fucking up. I would be really thankful if you guys could help me.
Thanks in advance!
[QUOTE=HumbleTH;46208923]Get the player object somehow and set the variable on that object.
For example:
[lua]
local ply = LocalPlayer();
ply.Whatever = "hi";
[/lua][/QUOTE]
I get this error:
[code]
[ERROR] lua/autorun/server/phtm_server.lua:3: attempt to call global 'LocalPlayer' (a nil value)
1. unknown - lua/autorun/server/phtm_server.lua:3
[/code]
The code:
[code]if ( SERVER ) then
local TAUNT_DELAY = 3 //Taunt Delay Variable
local ply = LocalPlayer()
local last_taunt
ply.last_taunt=0;//If a taunt was used check variable
util.AddNetworkString("send_p1_B1")
net.Receive( "send_p1_B1", function( ply )
local sound = net.ReadString()
if ply.last_taunt <= TAUNT_DELAY then
ply.last_taunt = TAUNT_DELAY + SoundDuration( sound )
for _, ply in pairs( player.GetAll() ) do
ply:EmitSound( sound )
timer.Simple(SoundDuration(sound)+TAUNT_DELAY+4, function() ply.last_taunt=0 end )//Make sure to calibrate the reset timer properly for each taunt!
end
else
print("Wait until the taunt is finished playing.")
end
end )
)[/code]
I want that when a player uses the menu it will set the variable to the length of the taunt and after a certain timer reset it.
Basically limit players from spamming taunts.
Any tips on how to do such a variable?
LocalPlayer is obviously only clientside and you don't need it because there is already a player argument in the net.Receive function (and you have been told that the first argument of the function is the length of the net message, the second argument is the player who sent the message to the server
[code]net.Receive( "string", function( length, player ) ...[/code]
You probably don't need the lenght in this case, so you can just omit it by doing
[code]net.Receive( "send_p1_B1", function( _, ply ) ...[/code]
And I gave you a way to make your delay thing, but you are right about wanting to make it per player ;) That said, I have heard that SoundDuration sometimes (or most of the times) does not return the correct value, so that may be your problem...
Also I suggest you change your for loop because it's confusing: use another variable name than "ply", since you already have a variable with that name in the same scope.
[QUOTE=DEFCON1;46209172]LocalPlayer is obviously only clientside and you don't need it because there is already a player argument in the net.Receive function (and you have been told that the first argument of the function is the length of the net message, the second argument is the player who sent the message to the server
[code]net.Receive( "string", function( length, player ) ...[/code]
You probably don't need the lenght in this case, so you can just omit it by doing
[code]net.Receive( "send_p1_B1", function( _, ply ) ...[/code][/QUOTE]
I understood that.
The thing is I want to create a Variable that is limiting the player from using another taunt until the first one he launched finished playing.
Example:
[code]if ( SERVER ) then
local TAUNT_DELAY = 3 //Taunt Delay Variable
local last_taunt = 0
util.AddNetworkString("send_p1_B1")
net.Receive( "send_p1_B1", function( ply )
local sound = net.ReadString()
if last_taunt <= TAUNT_DELAY then
last_taunt = TAUNT_DELAY + SoundDuration( sound )
for _, ply in pairs( player.GetAll() ) do
ply:EmitSound( sound )
timer.Simple(SoundDuration(sound)+TAUNT_DELAY+4, function() last_taunt=0 end )//Make sure to calibrate the reset timer properly for each taunt!
end
else
print("Wait until the taunt is finished playing.")
end
end )
//Button2
util.AddNetworkString("send_p1_B2")
net.Receive( "send_p1_B2", function( ply )
local sound = net.ReadString()
if last_taunt <= TAUNT_DELAY then
last_taunt = TAUNT_DELAY + SoundDuration( sound )
for _, ply in pairs( player.GetAll() ) do
ply:EmitSound( sound )
timer.Simple(SoundDuration(sound)+0.5, function() last_taunt=0 end )//Make sure to calibrate the reset timer properly for each taunt!
print("Playing Taunt",sound)
end
else
print("Wait until the taunt is finished playing.")
end
end )[/code]
Currently this code blocks all players from using taunts until the timer is zeroed out after player x launched a taunt, I want the variable to be per player and not 1 for everyone.
You could do it with a timer as you did, but why doing it so complicated?
Just do something like this:
[code]
if CurTime() - (ply.LastTaunt or 0) >= TAUNT_DELAY then
ply.LastTaunt = CurTime() + SoundDuration( sound )
end
[/code]
I can assure you that it works. But I repeat, the problem might be SoundDuration not returning a correct value (unless that was fixed)
[QUOTE=DEFCON1;46209292]You could do it with a timer as you did, but why doing it so complicated?
Just do something like this:
[code]
if CurTime() - (ply.LastTaunt or 0) >= TAUNT_DELAY then
ply.LastTaunt = CurTime() + SoundDuration( sound )
end
[/code]
I can assure you that it works. But I repeat, the problem might be SoundDuration not returning a correct value (unless that was fixed)[/QUOTE]
The thing is that ply.LastTaunt has to be a GLOBAL VARIABLE and Per Player, because there will be more than one taunt playing.
Each time I try to set that variable as global like here:
[code]if ( SERVER ) then
local TAUNT_DELAY = 3 //Taunt Delay Variable
local ply=LocalPlayer();
ply.last_taunt=0;
util.AddNetworkString("send_p1_B1")
net.Receive( "send_p1_B1", function( ply )
local sound = net.ReadString()
if last_taunt <= TAUNT_DELAY then
last_taunt = TAUNT_DELAY + SoundDuration( sound )
for _, ply in pairs( player.GetAll() ) do
ply:EmitSound( sound )
timer.Simple(SoundDuration(sound)+TAUNT_DELAY+4, function() hook.Call("reset_tVar") end )//Make sure to calibrate the reset timer properly for each taunt!
end
else
print("Wait until the taunt is finished playing.")
end
end )[/code]
I get:
[code]
[ERROR] lua/autorun/server/phtm_server.lua:3: attempt to call global 'LocalPlayer' (a nil value)
1. unknown - lua/autorun/server/phtm_server.lua:3
[ERROR] lua/autorun/server/phtm_server.lua:3: attempt to call global 'LocalPlayer' (a nil value)
1. unknown - lua/autorun/server/phtm_server.lua:3
[/code]
I need ply.last_taunt to be a global variable, cause there's more than 1 net.Receive() command and each one plays a sound.
Hey, sorry for being so dumb but how would i put a players name onto a HUD? Thanks in advance.
Read again my post... I gave you answers to your problem but you don't make any changes to your code mess :s
[QUOTE=vontiagaming;46209391]Hey, sorry for being so dumb but how would i put a players name onto a HUD? Thanks in advance.[/QUOTE]
Example here: [url]http://wiki.garrysmod.com/page/draw/DrawText[/url]
[QUOTE=DEFCON1;46209396]
Example here: [url]http://wiki.garrysmod.com/page/draw/DrawText[/url][/QUOTE]
Oh, thanks alot!
[QUOTE=VashBaldeus;46209301]The thing is that ply.LastTaunt has to be a GLOBAL VARIABLE and Per Player, because there will be more than one taunt playing.
Each time I try to set that variable as global like here:
[code]if ( SERVER ) then
local TAUNT_DELAY = 3 //Taunt Delay Variable
local ply=LocalPlayer();
ply.last_taunt=0;
util.AddNetworkString("send_p1_B1")
net.Receive( "send_p1_B1", function( ply )
local sound = net.ReadString()
if last_taunt <= TAUNT_DELAY then
last_taunt = TAUNT_DELAY + SoundDuration( sound )
for _, ply in pairs( player.GetAll() ) do
ply:EmitSound( sound )
timer.Simple(SoundDuration(sound)+TAUNT_DELAY+4, function() hook.Call("reset_tVar") end )//Make sure to calibrate the reset timer properly for each taunt!
end
else
print("Wait until the taunt is finished playing.")
end
end )[/code]
I get:
[code]
[ERROR] lua/autorun/server/phtm_server.lua:3: attempt to call global 'LocalPlayer' (a nil value)
1. unknown - lua/autorun/server/phtm_server.lua:3
[ERROR] lua/autorun/server/phtm_server.lua:3: attempt to call global 'LocalPlayer' (a nil value)
1. unknown - lua/autorun/server/phtm_server.lua:3
[/code]
I need ply.last_taunt to be a global variable, cause there's more than 1 net.Receive() command and each one plays a sound.[/QUOTE]
[code]
net.Receive( "send_p1_B1", function( ply )
if CurTime( ) - ( ply.LastTaunt or 0 ) >= TAUNT_DELAY then
ply.LastTaunt = CurTime( )
rest of taunt code
end
end
[/code]
Your mixing your states - LocalPlayer exits only on the client. The net function passes the player it originates from, so just use that object.
The net function passes the player it originates from, so just use that object [b]but first add the missing parameter[/b]
Like so...
[code]
net.Receive( "send_p1_B1",
function( _, ply ) -- now ply is a player entity, no longer a number!
if CurTime( ) - ( ply.LastTaunt or 0 ) >= TAUNT_DELAY then
ply.LastTaunt = CurTime( )
rest of taunt code
end
end
)
[/code]
[QUOTE=DEFCON1;46209478]The net function passes the player it originates from, so just use that object [b]but first add the missing parameter[/b]
Like so...
[code]
net.Receive( "send_p1_B1",
function( _, ply ) -- now ply is a player entity, no longer a number!
if CurTime( ) - ( ply.LastTaunt or 0 ) >= TAUNT_DELAY then
ply.LastTaunt = CurTime( )
rest of taunt code
end
end
)
[/code][/QUOTE]
I tried that, it doesn't play the sound anymore.
Hi I have added a job that is only for donator in my server (I added the donator group through ULX). It works and all but you can only see it if you are a donator. Now I want it so you can see it in the f4 menu so people know what they can get if they become donators. I'm not sure if it's something in the code or whatever but could anyone help me find an answer on how to do this?
[LUA]TEAM_SWAT = AddExtraTeam("S.W.A.T", {
color = Color( 70, 70, 70, 225),
model = {"models/player/ct_gsg9.mdl"},
description = [[You are a S.W.A.T member and one of the best protectors of the city! Patrol the city just like a civil protection and use your special weapons to take down criminals!]],
weapons = {"weapon_charge"},
command = "swat",
max = 5,
salary = 80,
admin = 0,
vote = false,
hasLicense = false,
customCheck = function(ply) return ply:GetNWString("usergroup") == "donator" end
})
[/LUA]
[QUOTE=DEFCON1;46209478]The net function passes the player it originates from, so just use that object [b]but first add the missing parameter[/b]
Like so...
[code]
net.Receive( "send_p1_B1",
function( _, ply ) -- now ply is a player entity, no longer a number!
if CurTime( ) - ( ply.LastTaunt or 0 ) >= TAUNT_DELAY then
ply.LastTaunt = CurTime( )
rest of taunt code
end
end
)
[/code][/QUOTE]
I solved it!
Thanks allot for the help!!!!!!!
[del]So I'm doing PhysicsInitSphere. For the radius, is there a restriction? Like, can the radius be 0.1875 or 0.375? or must it be greater than 1, greater than 2?I ask because when designing models, the minimum size of a collision piece is like, 2x2x2.[/del]
Scratch that. Tested, works wonderfully.
How would I go about changing the aesthetics of notification.AddLegacy?
[QUOTE=Caliboy50124;46209599]Hi I have added a job that is only for donator in my server (I added the donator group through ULX). It works and all but you can only see it if you are a donator. Now I want it so you can see it in the f4 menu so people know what they can get if they become donators. I'm not sure if it's something in the code or whatever but could anyone help me find an answer on how to do this?
[LUA]TEAM_SWAT = AddExtraTeam("S.W.A.T", {
color = Color( 70, 70, 70, 225),
model = {"models/player/ct_gsg9.mdl"},
description = [[You are a S.W.A.T member and one of the best protectors of the city! Patrol the city just like a civil protection and use your special weapons to take down criminals!]],
weapons = {"weapon_charge"},
command = "swat",
max = 5,
salary = 80,
admin = 0,
vote = false,
hasLicense = false,
customCheck = function(ply) return ply:GetNWString("usergroup") == "donator" end
})
[/LUA][/QUOTE]
Try
customCheck = function(ply) return CLIENT or ply:GetNWString("usergroup") == "donator" end
So I used some code for my chat thingy (it was under the "PostDrawOpaqueRenderables" hook and a Cam.Start3d2d) and threw it under a HUDPaint hook. For whatever reason it just spams the table on and on and on which didnt happen in the other hook. I tried a couple hacky methods of stopping the spam from happening to no real avail.
[IMG]http://i.gyazo.com/9c4a0c90c5de0c6a90f95da3725124de.png[/IMG]
Code, minus some extra stuff
[code]
local ob = ply:GetObserverTarget()
if ob and IsValid(ob) and ob:IsPlayer() and ob:Alive() then
ply = ob
if not ply.Spectators then ply.Spectators = {} end
table.insert(ply.Spectators, "Name 1")
table.insert(ply.Spectators, "Name 2")
table.insert(ply.Spectators, "Name 3")
table.insert(ply.Spectators, "Name 4")
table.insert(ply.Spectators, "Name 5")
table.insert(ply.Spectators, "Name 6")
table.insert(ply.Spectators, "Name 7")
table.insert(ply.Spectators, "Name 8")
end
if ply.Spectators then
local buffer = 20
local width = 100
local height = 150
local x = 10
local y = (ScrH()/2) - (height/2)
draw.RoundedBox( 0, x, y, width, height, Color( 44, 44, 44, 175 ) )
draw.AAText( "Spectators:", "Deathrun_Spec", x + (width/2), y, Color(255,255,255,255), TEXT_ALIGN_CENTER )
local buffer = 20
local width = 100
local height = 150
local x = 10
local y = (ScrH()/2) - (height/2)
draw.RoundedBox( 0, x, y, width, height, Color( 44, 44, 44, 175 ) )
draw.AAText( "Spectators:", "Deathrun_Spec", x + (width/2), y, Color(255,255,255,255), TEXT_ALIGN_CENTER )
for k, v in pairs(ply.Spectators) do
draw.DrawText( v, "Deathrun_Spec", x + (width/2), y + buffer, Color(255,255,255,255), TEXT_ALIGN_CENTER )
buffer = buffer + 15
end
end
[/code]
So my scripted entity is not shooting bullets?
[lua] if ftr.Hit && !self.HasShot then
self.HasShot = true
local b = {}
b.Num = self.Num or 1
b.Src = self:GetPos()
b.Dir = FwdVec
b.Spread = self.Spread or Vector( 0, 0, 0 )
b.Tracer = 0
b.TracerName = self.TraceName or "Tracer"
b.Force = self.Force or 1000
b.Damage = self.Damage or 10
if ftr.HitGroup == HITGROUP_HEAD then b.Damage = b.Damage * 15 end
b.AmmoType = self.AmmoType or "pistol"
self:FireBullets( bullet )
SafeRemoveEntity( self )
end[/lua]
[editline]11th October 2014[/editline]
Do note, the code is being called, I've checked using print.
Got a couple questions...if I force a client to download a workshop addon that is my server's content, after I update the addon to add an extra model, will it still force the clients to update their addon to grab the new/updated version or no? I updated it a day ago or so and players are seeing a model in my pointshop as an error whenever I can see it perfectly fine after clearing my downloads.
Second question, I also have it to force download some fonts which are both on the local server and FastDL server (resource/fonts/bebasneue.ttf) but it will NOT force the players to download it.
Sorry, you need to Log In to post a reply to this thread.