General > Developers Corner

Admin sounds, tools and other code chat.

<< < (15/31) > >>

jay209015:
Ok, I'm getting this error for the ULib.play3DSound timer.

--- Code: ---Timer Error: ULib/server/util.lua:104: bad argument #1 to 'SetPos' (Vector expec
ted, got nil)
--- End code ---
I tried 0, but it gave me an Nil error.

I'm still getting the same error with the effects timer aswell.

--- Code: ---local function MakeEffect( ply )
local effectdata = EffectData()
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
util.Effect( "Sparks", effectdata, true, true )
end
function AdminJoin( ply)
if ( !ply:IsAdmin() ) then return end
timer.Simple( 4, ULib.play3DSound, "admin.mp3, ply:GetPos(), 1, 1")
timer.Simple( 5, game.ConsoleCommand, "ulx csay admin " ..ply:Nick().. " has connected \n")
if ply:IsConnected( ) then
timer.Create( "AdminJoin", 1, 0, MakeEffect, ply )
else
timer.Destroy("AdminJoin")
end
end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin );

--- End code ---

Megiddo:
timer.Simple( 4, ULib.play3DSound, "admin.mp3", ply:GetPos(), 1, 1)

jay209015:
Still trying to get rid of the timer error.


--- Code: ---Timer Error: autorun/Ajoin.lua:2: Tried to use a NULL entity!
--- End code ---


--- Code: ---local function MakeEffect( ply )
if ply:IsConnected()  then
local effectdata = EffectData()
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
util.Effect( "Sparks", effectdata, true, true )
else
timer.Destroy( "Admin" ..ply:Nick() )
end
end
function AdminJoin( ply)
if ( !ply:IsAdmin() ) then return end
timer.Simple( 3, game.ConsoleCommand, "ulx playsound admin.mp3 \n")
timer.Simple( 5, game.ConsoleCommand, "ulx csay admin " ..ply:Nick().. " has connected \n")
if ply:IsConnected( ) then
timer.Create( "Admin" ..ply:Nick(), 1, 0, MakeEffect, ply )
end
end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin )
concommand.Add( "Ajoin", AdminJoin )
--- End code ---

I tested this:


--- Code: ---lua_run timer.Destroy("AdminJay209015")
> timer.Destroy("AdminJay209015")...
--- End code ---

and it worked fine, so obviously it's something in my code :'(

Also tested this:


--- Code: ---local function MakeEffect( ply )
local effectdata = EffectData()
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
util.Effect( "Sparks", effectdata, true, true )
end
function AdminJoin( ply)
if ( !ply:IsAdmin() ) then return end
timer.Simple( 3, game.ConsoleCommand, "ulx playsound admin.mp3 \n")
timer.Simple( 5, game.ConsoleCommand, "ulx csay admin " ..ply:Nick().. " has connected \n")
if ply:IsConnected( ) then
timer.Create( "Admin" ..ply:Nick(), 1, 0, MakeEffect, ply )
end
if ( !ply:IsConnected() ) then
timer.Destroy( "Admin" ..ply:Nick() )
end
end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin )
concommand.Add( "Ajoin", AdminJoin )
--- End code ---

failed.

spbogie:
instead of ply:IsConnected() use ply:IsValid() or ValidEntity( ply ).

jay209015:
Same Error new code:


--- Code: ---local function MakeEffect( ply )
local effectdata = EffectData()
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
util.Effect( "Sparks", effectdata, true, true )
end
function AdminJoin( ply)
if ( !ply:IsAdmin() ) then return end
timer.Simple( 3, game.ConsoleCommand, "ulx playsound admin.mp3 \n")
timer.Simple( 5, game.ConsoleCommand, "ulx csay admin " ..ply:Nick().. " has connected \n")
if ply:IsValid() then
timer.Create( "Admin" ..ply:Nick(), 1, 0, MakeEffect, ply )
else
timer.Destroy( "Admin" ..ply:Nick() )
end
end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin )
concommand.Add( "Ajoin", AdminJoin )

--- End code ---

Same error here two Different code:


--- Code: ---local function MakeEffect( ply )
local effectdata = EffectData()
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
util.Effect( "Sparks", effectdata, true, true )
end
function AdminJoin( ply)
if ( !ply:IsAdmin() ) then return end
timer.Simple( 3, game.ConsoleCommand, "ulx playsound admin.mp3 \n")
timer.Simple( 5, game.ConsoleCommand, "ulx csay admin " ..ply:Nick().. " has connected \n")
if ValidEntity( ply ) then
timer.Create( "Admin" ..ply:Nick(), 1, 0, MakeEffect, ply )
else
timer.Destroy( "Admin" ..ply:Nick() )
end
end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin )
concommand.Add( "Ajoin", AdminJoin )

--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version