General > Developers Corner
Admin sounds, tools and other code chat.
Chironex:
His code play the sound for everyone, while yours just play it for yourself (the admins)
As he don't use 'i', don't care about it, and 'v' will be each player, as players.GetAll() return a table of connected players.
Out of subject: I'm not Lua expert, but isn't it better to store players.GetAll() in a new variable, instead of calling the function at each iteration of the loop? Or it's already stored at first iteration with Lua?
jay209015:
Thank you for clarifying!
PhaxeNor:
--- Quote from: MrPresident on April 07, 2008, 04:06:18 PM ---Here you go..! =)
--- Code: ---if SERVER then
function AdminJoins(ply)
if ply:IsAdmin() then
for i, v in ipairs(player.GetAll()) do
v:SendLua("surface.PlaySound(\"npc/turret_floor/active.wav\")")
end
end
end
hook.Add( "PlayerInitialSpawn", "adminjoins", AdminJoins );
end
--- End code ---
Simply replace npc/turret_floor/active.wav with whatever the path of your sound file is.
Save it to adminjoin.lua and put it in your lua/autorun folder on your server.
If the sound is custom, make sure you distribute it to your clients, you can do that with ULX in the server.ini file.
--- End quote ---
If I want this to work with more than just admins, say VIP can I just add ply:IsUserGroup("vip") (from your post) or do I need to modify something first to get the IsUserGroup working?
I want to have it to post a custom Message when a VIP, Admin, SuperAdmin or Server Owner joins
MrPresident:
You can add whatever groups you want.. the easiest way for you to do that, would be to do this.
if ply:IsAdmin() or ply:IsUserGroup("groupname") or ... etc
You can add as many groups as you want, just seperate them with 'or'
edit: And Kyzer, I don't believe that storing players.GetAll() in a variable would do anything special.
PhaxeNor:
ok, thank you MrPresident :)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version