🟪sam.Net.start

Example #1

if SERVER then
    -- This sends it for all players on the server.
    sam.Net.start("test", {
        target = "*",
        1, true, "xd", {1}, {a = 1}
    })

    -- This sends it to all players INSIDE the array.
    sam.Net.start("test", {
        target = {Entity(1), Entity(2), Entity(3)},
        1, true, "xd", {1}, {a = 1}
    })
    
    -- This sends it for just one player.
    sam.Net.start("test", {
        target = Entity(1),
        1, true, "xd", {1}, {a = 1}
    })
end

if CLIENT then
    sam.Net.hook("test", function(number, boolean, string, array, object)
        print(number, boolean, string, array, object)
    end)
end

Example #2

if SERVER then
    sam.Net.start("test", {
        target = Entity(1)
    })
end

if CLIENT then
    sam.Net.hook("test", function()
        print("Received an empty message from server!")
    end)
end

Example #3

if SERVER then
    sam.Net.hook("test", function(ply, message)
        -- even if they are an admin, always add checks for everything
        -- sent from the client
        if not message then return end

        print("Client is asking us to " .. message)
    end, function(ply, message_length)
        if not ply:IsAdmin() then
            return false
        end
    end)
end

if CLIENT then
    sam.Net.start("test", {"do something crazy!"})
end

Last updated