Jump to content

triggerClientEvent Problem


Recommended Posts

Here are the scripts:-

The label doesn't shows the rank and deliveries.

Server:-

function bindRankInfo(player) 
    local accountPlayer = getPlayerAccount(player) 
    local rank = getAccountData(accountPlayer, "Rank") 
    if (rank) then 
    else 
        setAccountData(accountPlayer, "Rank", "Novice") 
    end 
    local deliveries = getAccountData(accountPlayer, "deliveries") 
    if (deliveries) then 
    else 
        setAccountData(accountPlayer, "deliveries", "0") 
    end 
    local team = getPlayerTeam(player) 
    local teamName = getTeamName(team) 
    if ( teamName == "Freight") then 
        triggerClientEvent("rankShow", player, deliveries, rank) 
    end 
end 
function binding() 
    bindKey(source,"F5", "up", bindRankInfo) 
end 
  
addEventHandler("onPlayerJoin", getRootElement(), binding) 

Client :-

function jobRankInfo(arg1, arg2) 
     
    guiSetVisible(GUIEditor.window[2], not guiGetVisible(GUIEditor.window[2])) 
    guiSetText(GUIEditor.label[1], "Your Current Deliveries are :-"..arg1.." You Rank:-"..arg2) 
    guiSetInputEnabled(not guiGetInputEnabled) 
    showCursor ( not isCursorShowing ()) 
end 
  
addEvent("rankShow", true) 
addEventHandler("rankShow", getRootElement(), jobRankInfo) 

Link to comment

Replace your code with mine and tell me what does it debugs.

function bindRankInfo(player) 
    local accountPlayer = getPlayerAccount(player) 
    local rank = getAccountData(accountPlayer, "Rank") 
    if (rank) then 
    else 
        setAccountData(accountPlayer, "Rank", "Novice") 
    end 
    local deliveries = getAccountData(accountPlayer, "deliveries") 
    if (deliveries) then 
    else 
        setAccountData(accountPlayer, "deliveries", "0") 
    end 
    local team = getPlayerTeam(player) 
    local teamName = getTeamName(team) 
    if ( teamName == "Freight") then 
       if triggerClientEvent(player,"rankShow", player, tostring(deliveries), tostring( rank) ) then 
     outputDebugString(' Event rankShow has been triggered with data: '..tostring(deliveries)..', '..tostring(rank)) 
          end 
     end 
end 
function binding() 
    bindKey(source,"F5", "up", bindRankInfo) 
end 
  
addEventHandler("onPlayerJoin", getRootElement(), binding) 
outputDebugString('Server side: Code Loaded!') 

client:

function jobRankInfo(arg1, arg2) 
   outputDebugString('Client side: Data has been sent from server to client side!') 
    guiSetVisible(GUIEditor.window[2], not guiGetVisible(GUIEditor.window[2])) 
    guiSetText(GUIEditor.label[1], "Your Current Deliveries are :-".. arg1 .." You Rank:-".. arg2) 
    guiSetInputEnabled(not guiGetInputEnabled) 
    showCursor ( not isCursorShowing ()) 
end 
  
addEvent("rankShow", true) 
addEventHandler("rankShow", getRootElement(), jobRankInfo) 
outputDebugString('Client side: Code Loaded!') 

If still this doesn't work then go to your server and login ( you must be an admin ) and type /debugscript 3

Link to comment
function bindRankInfo(player) 
    local accountPlayer = getPlayerAccount(player) 
    local rank = getAccountData(accountPlayer, "Rank") 
    if (rank) then 
    else 
        rank = "Novice" 
        setAccountData(accountPlayer, "Rank", "Novice") 
    end 
    local deliveries = getAccountData(accountPlayer, "deliveries") 
    if (deliveries) then 
    else 
        deliveries = 0 
        setAccountData(accountPlayer, "deliveries", 0) 
    end 
    local team = getPlayerTeam(player) 
    local teamName = getTeamName(team) 
    if ( teamName == "Freight") then 
        triggerClientEvent(player, "rankShow", player, deliveries, rank) 
    end 
end 
function binding() 
    bindKey(source,"F5", "up", bindRankInfo) 
end 
  
addEventHandler("onPlayerJoin", getRootElement(), binding) 

Client:

function jobRankInfo(arg1, arg2) 
     
    guiSetVisible(GUIEditor.window[2], not guiGetVisible(GUIEditor.window[2])) 
    guiSetText(GUIEditor.label[1], "Your Current Deliveries are :-"..arg1.." You Rank:-"..arg2) 
    guiSetInputEnabled(not guiGetInputEnabled) 
    showCursor ( not isCursorShowing ()) 
end 
  
addEvent("rankShow", true) 
addEventHandler("rankShow", getRootElement(), jobRankInfo) 

Link to comment
function bindRankInfo(player) 
    local accountPlayer = getPlayerAccount(player) 
    local rank = getAccountData(accountPlayer, "Rank") 
    if (rank) then 
    else 
        rank = "Novice" 
        setAccountData(accountPlayer, "Rank", "Novice") 
    end 
    local deliveries = getAccountData(accountPlayer, "deliveries") 
    if (deliveries) then 
    else 
        deliveries = 0 
        setAccountData(accountPlayer, "deliveries", 0) 
    end 
    local team = getPlayerTeam(player) 
    local teamName = getTeamName(team) 
    if ( teamName == "Freight") then 
        triggerClientEvent(player, "rankShow", player, deliveries, rank) 
    end 
end 
function binding() 
    bindKey(source,"F5", "up", bindRankInfo) 
end 
  
addEventHandler("onPlayerJoin", getRootElement(), binding) 

Client:

function jobRankInfo(arg1, arg2) 
     
    guiSetVisible(GUIEditor.window[2], not guiGetVisible(GUIEditor.window[2])) 
    guiSetText(GUIEditor.label[1], "Your Current Deliveries are :-"..arg1.." You Rank:-"..arg2) 
    guiSetInputEnabled(not guiGetInputEnabled) 
    showCursor ( not isCursorShowing ()) 
end 
  
addEvent("rankShow", true) 
addEventHandler("rankShow", getRootElement(), jobRankInfo) 

Not Working, now the GUI is also not opening.

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