help with lua

hey guys, how do i make this work :

if(SERVER) then
net.Receive(“receiveddupe”, function(len, ply)
local dupe = net.ReadString()
for k, v in pairs(player.GetAll()) do
v:SendLua(“MsgN(“Received dupe:” …dupe … " from player” … ply:Nick() … “”)")
end
end)
end

so only Admins will get the notification, and not players. thanks in advance

Player:IsAdmin

i’ve tried but idk how to put it together

Your net code is semi-exploitable because of your use of SendLua. Try this:


local sDupePrint = "Received dupe: %q"

net.Receive("receiveddupe", function(_, ply)
	local sDupe = net.ReadString()
	local tPlayers = player.GetAll()
	
	for i = 1, #tPlayers do
		local pPlayer = tPlayers*
		
		if (pPlayer:IsAdmin()) then
			pPlayer:ChatPrint(string.format(sDupePrint, sDupe))
		end
	end
end)

thanks alot man, also is it possible to trigger this when another net message is called?, for example if the net message “ArmDupe” is called, can i create some code to make it run the receiveddupe whenever “ArmDupe” is called?

You can make the function local instead and register it to “receievedupe” and “ArmDupe”

how? please tell me

i dont understand, so you need me to do local ArmDupe = “ArmDupe” or something sorry i sound stupid, but could you elaborate? thanks in advance


local sDupePrint = "Received dupe: %q"

local function dupe(_, ply)
	local sDupe = net.ReadString()
	local tPlayers = player.GetAll()
	
	for i = 1, #tPlayers do
		local pPlayer = tPlayers*
		
		if (pPlayer:IsAdmin()) then
			pPlayer:ChatPrint(string.format(sDupePrint, sDupe))
		end
	end
end

net.Receive("receiveddupe", dupe )

Then do the same thing for “ArmDupe”

nono, ArmDupe is already a net message for the duplicator, i can’t just overwrite it

You can if you do it after the first Receive iirc.