Jump to content

[HELP] Serverside functions to client...


lolman

Recommended Posts

Hello,

Im stuck on a server side function which I want that it responds to the client side... The server side function what I want to the clientside is getPlayerIP... I want it like, that you can see other people IP as text.

I tried triggerServerEvent and such but nothing works...

if someone could help me out

Link to comment

One and only way is to use triggerServerEvent/triggerClientEvent.

Show what you tried.

An example:

Client:

triggerClientEvent("getIP", localPlayer) 
  
function sendIP(ip) 
    outputChatBox(getPlayerName(source).."'s IP is: "..ip) 
end 
addEvent("sendIP", true) 
addEventHandler("sendIP", root, sendIP) 

Server:

  
function getIP() 
    local ip = getPlayerIP(source) 
    triggerClientEvent(source, "sendIP", source, ip) 
end 
addEvent("getIP", true) 
addEventHandler("getIP", root, getIP) 

Link to comment

client:

local number = dxCreateFont("number.ttf",15) 
local zx, zy = guiGetScreenSize ( ) 
local resWtes,resHtes = 1280,720 
local sWtes,sHtes =  (zx/resWtes), (zy/resHtes) 
  
  
function deta() 
local BoneX,BoneY,BoneZ = getPedBonePosition(getLocalPlayer(), 4) 
local SBX,SBY = getScreenFromWorldPosition ( BoneX,BoneY,BoneZ ) 
local ip = triggerServerEvent("ip", getLocalPlayer()) 
    if SBX and SBY then  
        if getPedWeapon (getLocalPlayer()) ~= 0 then 
            dxDrawText("IP"..ip, SBX,SBY-230, 290*sWtes, 250*sHtes, tocolor (200,31, 31, 150), 0.8*sWtes,0.8*sHtes,number,"left","top",false,false,false,true) 
        end 
    end 
end 
addEventHandler("onClientRender", root, deta) 

server :

function ip(thePlayer, oponent) 
    getPlayerIP(oponent) 
end 
addEvent("ip", true) 
addEventHandler("ip", getRootElement(), ip) 

Link to comment

Client:

local number = dxCreateFont("number.ttf",15) 
local zx, zy = guiGetScreenSize ( ) 
local resWtes,resHtes = 1280,720 
local sWtes,sHtes =  (zx/resWtes), (zy/resHtes) 
  
  
function deta() 
local BoneX,BoneY,BoneZ = getPedBonePosition(getLocalPlayer(), 4) 
local SBX,SBY = getScreenFromWorldPosition ( BoneX,BoneY,BoneZ ) 
local ip = getElementData(localPlayer, "ip") or "N/A" 
    if SBX and SBY then  
        if getPedWeapon (getLocalPlayer()) ~= 0 then 
            dxDrawText("IP"..ip, SBX,SBY-230, 290*sWtes, 250*sHtes, tocolor (200,31, 31, 150), 0.8*sWtes,0.8*sHtes,number,"left","top",false,false,false,true) 
        end 
    end 
end 
addEventHandler("onClientRender", root, deta) 

Server:

function ip() 
    setElementData(source, "ip", getPlayerIP(source)) 
end 
addEventHandler("onPlayerJoin", getRootElement(), ip) 
  
function start() 
    for i, v in ipairs(getElementsByType"player") do 
        setElementData(v, "ip", getPlayerIP(v)) 
    end 
end 
addEventHandler("onResourceStart", resourceRoot, start) 

Link to comment

one word : WOW... Dude you're amazing as always again !! thank you very much ! :D

But how can I lock this on admin. I want it like if you are in the acl group admin (for i, player in ipairs(getElementsByType("player")) do

accountname = getAccountName (getPlayerAccount(player))

if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "admin" ) ) then) then you're able to see the IP of the person and other people can't see their IP's nor from other people.

Link to comment
one word : WOW... Dude you're amazing as always again !! thank you very much ! :D

But how can I lock this on admin. I want it like if you are in the acl group admin (for i, player in ipairs(getElementsByType("player")) do

accountname = getAccountName (getPlayerAccount(player))

if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "admin" ) ) then) then you're able to see the IP of the person and other people can't see their IP's nor from other people.

Your code isn't wrong just the group - it is "Admin" not "admin".

Link to comment

Client:

local number = dxCreateFont("number.ttf",15) 
local zx, zy = guiGetScreenSize ( ) 
local resWtes,resHtes = 1280,720 
local sWtes,sHtes =  (zx/resWtes), (zy/resHtes) 
  
function deta() 
    if getElementData(localPlayer, "admin") ~= true then return end 
    for i, v in ipairs(getElementsByType"player") do 
        if v == localPlayer then return end 
        local BoneX,BoneY,BoneZ = getPedBonePosition(v, 4) 
        local SBX,SBY = getScreenFromWorldPosition ( BoneX,BoneY,BoneZ ) 
        local ip = getElementData(v, "ip") or "N/A" 
        if SBX and SBY then 
            if getPedWeapon (v) ~= 0 then 
                dxDrawText("IP"..ip, SBX,SBY-230, 290*sWtes, 250*sHtes, tocolor (200,31, 31, 150), 0.8*sWtes,0.8*sHtes,number,"left","top",false,false,false,true) 
            end 
        end 
    end 
end 
addEventHandler("onClientRender", root, deta) 

Server:

function ip() 
    setElementData(source, "ip", getPlayerIP(source)) 
end 
addEventHandler("onPlayerJoin", getRootElement(), ip) 
  
function onLogin(_, acc, _) 
    if isObjectInACLGroup("user."..getAccountName(acc), aclGetGroup("Admin")) then 
        setElementData(source, "admin", true) 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onLogin) 
  
function start() 
    for i, v in ipairs(getElementsByType"player") do 
        setElementData(v, "ip", getPlayerIP(v)) 
        if not isGuestAccount(v) and isObjectInACLGroup("user."..getAccountName(getPlayerAccount(v)), aclGetGroup("Admin")) then 
            setElementData(v, "admin", true) 
        end 
    end 
end 
addEventHandler("onResourceStart", resourceRoot, start) 

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...