Jump to content

[Help]Police comp


Recommended Posts

I have made a police computer to tell me how many arrests i got and to show all criminals online in the server,, problem is that it totally not working, i checked the code many times cannot get the problem..

  
--Client 
function createwindow(theAccount, getdata) 
    if ( guiGetVisible ( window1 ) == false ) then 
    playerTeam = getPlayerTeam ( source ) 
    if getTeamName(playerTeam) == "Police" then  
    guiSetVisible (window1, true) 
    triggerServerEvent ( "setarrests", localPlayer, playerTeam)  
    guiSetText ( arrests_lab2, getdata ) 
else 
    if ( guiGetVisible ( window1 ) == true ) then 
    guiSetVisible (window1, false) 
end 
end 
end 
end 
addCommandHandler ( "pcomp", createwindow ) 

  
--Server 
function getdatas() 
    theAccount = getPlayerAccount ( source ) 
    local getdata = getAccountData(theAccount, "Arrests.count") 
end 
addEvent("setarrests", true) 
addEventHandler("setarrests", root, getdatas) 

There is no shown errors

( i know my code is nasty, i am still learning )

Link to comment

If you want to set a text on the client-side, you should be triggering over to the client-side event.

try this:

--Client 
function createwindow() 
    if not guiGetVisible ( window1 ) then 
        local playerTeam = getPlayerTeam ( localPlayer ) 
        if getTeamName(playerTeam) == "Police" then 
            guiSetVisible (window1, true) 
            triggerServerEvent ( "setarrests", localPlayer, playerTeam) 
        end 
    else 
        guiSetVisible (window1, false) 
    end 
end 
addCommandHandler ( "pcomp", createwindow ) 
  
addEvent("getArrestData",true) 
function getArrestData(data) 
    guiSetText ( arrests_lab2, data ) 
end 
addEventHandler("getArrestData",root,getArrestData) 
  
--Server 
function getdatas() 
    local theAccount = getPlayerAccount ( source ) 
    local getdata = getAccountData(theAccount, "Arrests.count") or "0" 
    triggerClientEvent(client,"getArrestData",client,tostring(getdata)) 
end 
addEvent("setarrests", true) 
addEventHandler("setarrests", root, getdatas) 

Edited by Guest
Link to comment

Try this now:

--Client 
function createwindow() 
    if not guiGetVisible ( window1 ) then 
        local playerTeam = getPlayerTeam ( localPlayer ) 
        if getTeamName(playerTeam) == "Police" then 
            guiSetVisible (window1, true) 
            triggerServerEvent ( "setarrests", localPlayer, playerTeam) 
        end 
    else 
        guiSetVisible (window1, false) 
    end 
end 
addCommandHandler ( "pcomp", createwindow ) 
  
addEvent("getArrestData",true) 
function getArrestData(data) 
    guiSetText ( arrests_lab2, data ) 
end 
addEventHandler("getArrestData",root,getArrestData) 
  
--Server 
function getdatas() 
    local theAccount = getPlayerAccount ( source ) 
    local getdata = getAccountData(theAccount, "Arrests.count") or "0" 
    triggerClientEvent(client,"getArrestData",client,tostring(getdata)) 
end 
addEvent("setarrests", true) 
addEventHandler("setarrests", root, getdatas) 

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