Jump to content

Help


manve1

Recommended Posts

Perhaps look at your own script before asking for help for every single thing you need.

Client-side

addEvent("onClientPlayerSerialFetched", true) 
addEventHandler("onClientPlayerSerialFetched", root, 
    function(serial) 
       guiSetText(aSerial, "Serial: " .. serial) 
    end 
) 
  
addEventHandler("onClientGUIClick", aGrid, 
    function() 
    local pRow = guiGridListGetSelectedItem(aGrid) 
        if (pRow and pRow ~= -1) then 
            triggerServerEvent("onClientPlayerSerialRequested", localPlayer, guiGridListGetItemText(aGrid, pRow, 1)) 
        end 
    end 
) 

Server-side

function findPlayer(name, player) 
    if name == "*" and getElementType(player) == "player" and not isGuestAccount(getPlayerAccount(player)) then 
        return player 
    else 
        local matches = {} 
        for i,v in ipairs(getElementsByType("player")) do 
            if getPlayerName(v) == name and not isGuestAccount(getPlayerAccount(v)) then 
                return v 
            end 
            local playerName = getPlayerName(v):gsub("#%x%x%x%x%x%x", "") 
            playerName = playerName:lower() 
            if playerName:find(name:lower(), 0) and not isGuestAccount(getPlayerAccount(v)) then 
                table.insert(matches, v) 
            end 
        end 
        if #matches == 1 then 
            return matches[1] 
        end 
        return false 
    end 
end 
  
addEvent("onClientPlayerSerialRequested", true) 
addEventHandler("onClientPlayerSerialRequested", root, 
    function(player) 
        local target = findPlayer(player, source) 
        if target then 
            triggerClientEvent(source, "onClientPlayerSerialFetched", source, getPlayerSerial(getPlayerFromName(target))) 
        else 
            outputChatBox("DEBUG: 'onClientPlayerSerialRequested' returned false.", source, 245, 40, 40, false) 
        end 
    end 
) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...