Jump to content

[HELP] ACC


1LoL1

Recommended Posts

Hello, i created script but i don't know really how i can get accname of server-side to client-side so triggerServerEvent

Please can anyone help me? :(

client

function www () 
    Window = guiCreateWindow(350,225,200,200,"Account",false) 
    guiSetAlpha ( Window, 5.00 ) 
    guiWindowSetMovable ( Window, false ) 
   
  local C1 = guiCreateLabel(10,95,500,500,"",false,Window) 
  
  guiSetText (C1, "Account: "..acc.."") 
   
  guiSetFont(C1, "default-bold-small") 
   
   
   
  guiWindowSetSizable(Window,false) 
end 
  
function convertNumber ( number )   
 local formatted = number   
 while true do       
  formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')     
  if ( k==0 ) then       
   break    
  end   
 end   
 return formatted 
end 
  
function ShowGUI ( ) 
www () 
showCursor (true) 
local screenW,screenH = guiGetScreenSize() 
local windowW,windowH = guiGetSize(Window,false) 
local x,y = (screenW-windowW)/2,(screenH-windowH)/2 
guiSetPosition(Window,x,y,false) 
end 
  
function window () 
  if isElement(Window) then 
    HideGUI() 
  else 
    ShowGUI() 
  end 
end 
bindKey("F5","down",window) 
  
function HideGUI () 
destroyElement (Window) 
showCursor(false) 
end 

server

addEvent("ACC", true) 
addEventHandler("ACC", root,  
function (source) 
acc = getAccountName(getPlayerAccount(source)) 
end) 

Link to comment

Client:

function www () 
  Window = guiCreateWindow(350,225,200,200,"Account",false) 
  guiSetAlpha ( Window, 5.00 ) 
  guiWindowSetMovable ( Window, false ) 
  C1 = guiCreateLabel(10,95,500,500,"",false,Window) 
  guiSetText (C1, "Account: loading...") 
  guiSetFont(C1, "default-bold-small") 
  guiWindowSetSizable(Window,false) 
end 
  
function convertNumber ( number )   
  local formatted = number   
  while true do       
    formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')     
    if ( k==0 ) then       
      break   
    end   
  end   
  return formatted 
end 
  
function ShowGUI ( ) 
  www () 
  showCursor (true) 
  local screenW,screenH = guiGetScreenSize() 
  local windowW,windowH = guiGetSize(Window,false) 
  local x,y = (screenW-windowW)/2,(screenH-windowH)/2 
  guiSetPosition(Window,x,y,false) 
end 
  
function window () 
  if isElement(Window) then 
    HideGUI() 
  else 
    ShowGUI() 
    guiSetText (C1, "Account: loading...") -- reset the account label 
    triggerServerEvent("ACC", localPlayer) -- request account name from the server 
  end 
end 
bindKey("F5","down",window) 
  
function HideGUI () 
  destroyElement (Window) 
  showCursor(false) 
end 
  
addEvent("ACC callback", true) 
addEventHandler("ACC callback", localPlayer, -- account name received from server 
  function(acc) 
    guiSetText (C1, "Account: "..acc) -- update the account label 
  end 
) 

Server:

addEvent("ACC", true) 
addEventHandler("ACC", root, -- account name request received by server 
  function () 
    local acc = getAccountName(getPlayerAccount(client)) -- collect client's account name 
    triggerClientEvent(client, "ACC callback", client, acc) -- send the account name the client 
  end 
) 

Link to comment
Client:
function www () 
  Window = guiCreateWindow(350,225,200,200,"Account",false) 
  guiSetAlpha ( Window, 5.00 ) 
  guiWindowSetMovable ( Window, false ) 
  C1 = guiCreateLabel(10,95,500,500,"",false,Window) 
  guiSetText (C1, "Account: loading...") 
  guiSetFont(C1, "default-bold-small") 
  guiWindowSetSizable(Window,false) 
end 
  
function convertNumber ( number )   
  local formatted = number   
  while true do       
    formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')     
    if ( k==0 ) then       
      break   
    end   
  end   
  return formatted 
end 
  
function ShowGUI ( ) 
  www () 
  showCursor (true) 
  local screenW,screenH = guiGetScreenSize() 
  local windowW,windowH = guiGetSize(Window,false) 
  local x,y = (screenW-windowW)/2,(screenH-windowH)/2 
  guiSetPosition(Window,x,y,false) 
end 
  
function window () 
  if isElement(Window) then 
    HideGUI() 
  else 
    ShowGUI() 
    guiSetText (C1, "Account: loading...") -- reset the account label 
    triggerServerEvent("ACC", localPlayer) -- request account name from the server 
  end 
end 
bindKey("F5","down",window) 
  
function HideGUI () 
  destroyElement (Window) 
  showCursor(false) 
end 
  
addEvent("ACC callback", true) 
addEventHandler("ACC callback", localPlayer, -- account name received from server 
  function(acc) 
    guiSetText (C1, "Account: "..acc) -- update the account label 
  end 
) 

Server:

addEvent("ACC", true) 
addEventHandler("ACC", root, -- account name request received by server 
  function () 
    local acc = getAccountName(getPlayerAccount(client)) -- collect client's account name 
    triggerClientEvent(client, "ACC callback", client, acc) -- send the account name the client 
  end 
) 

Thanks works.

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