lolman Posted July 13, 2015 Share Posted July 13, 2015 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
GTX Posted July 13, 2015 Share Posted July 13, 2015 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
lolman Posted July 13, 2015 Author Share Posted July 13, 2015 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
GTX Posted July 13, 2015 Share Posted July 13, 2015 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
lolman Posted July 13, 2015 Author Share Posted July 13, 2015 one word : WOW... Dude you're amazing as always again !! thank you very much ! 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
SpecT Posted July 13, 2015 Share Posted July 13, 2015 one word : WOW... Dude you're amazing as always again !! thank you very much ! 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
GTX Posted July 13, 2015 Share Posted July 13, 2015 Do you want IPs (of other people & you) to be seen only by admins but regular people can't see anyone's IP? Explain a bit better. Link to comment
lolman Posted July 13, 2015 Author Share Posted July 13, 2015 Admins cant see their IP If youre an admin (in the acl admin) then you can see other ppls IP other people can't see anyones IP even their own IP not Link to comment
GTX Posted July 13, 2015 Share Posted July 13, 2015 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now