General > Developers Corner
LUA request
Michael:
I've searched for hours, and cannot code LUA to save my life.
Im looking for a script, or something that i can implement to have like an into song for specific users that join my server, namely admins.
I'm half asleep at the moment, lol so i dont know if i make sense.
Like me, and two other people would have specific sounds when we enter the server.
Can that even be done?
Michael:
Im sorry, i should specify. Its for a Gmod server (TTT)
Michael:
ORRR better yet. is there a way i can addapt this code to ONLY work with one user? then i /should/ be able to use more than one application of this code for the other users...
--- Code: ----- Simple lua script written by Ayv, feel free to edit it! :D --
resource.AddFile("sound/admin_alert.mp3")
if SERVER then
AddCSLuaFile("autorun/admin_alert.lua")
end
function AdminAlert( pl )
if pl:IsAdmin() then
for k, v in pairs(player.GetAll()) do
v:PrintMessage(HUD_PRINTCENTER,"Admin has joined the server!")
v:ConCommand("play admin_alert.mp3")
end
end
end
hook.Add( "PlayerInitialSpawn", "playerInitialSpawn", AdminAlert )
--- End code ---
Megiddo:
This is a very basic script. Try starting with a Lua tutorial such as this, then flex your Lua muscles by trying to figure this out on your own. :)
MrPresident:
Completely untested... if the script you posted works then this should work too...
Add the SteamIDs of the people you want this to chime in for in the table (the first line in the AdminAlert function..
--- Code: ----- Simple lua script written by Ayv, feel free to edit it! :D --
resource.AddFile("sound/admin_alert.mp3")
if SERVER then
AddCSLuaFile("autorun/admin_alert.lua")
end
function AdminAlert( pl )
local admins = { "STEAM_0:1:12345678", "STEAM_0:1:9876543" }
for _, v in pairs( admins ) do
if pl:SteamID() == v then
for _, v2 in pairs(player.GetAll()) do
v2:PrintMessage(HUD_PRINTCENTER,"Admin has joined the server!")
v2:ConCommand("play admin_alert.mp3")
end
end
end
end
hook.Add( "PlayerInitialSpawn", "playerInitialSpawn", AdminAlert )
--- End code ---
--You should still try and learn though. There is no reason why any server operator should not be able to make simple modifications to little scripts like this on his/her own. Learning a little lua WILL be what sets you and your server(s) apart from the other 9999 servers out there running the same gamemode as you.
Navigation
[0] Message Index
[#] Next page
Go to full version