Jump to content

[Help]Police comp


Recommended Posts

Posted

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 )

Posted (edited)

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

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

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) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

ofc his own, if he's logged in with his own account... your account data will be save in your account! :D

it'S Go0D To Be BaD ! ! !

[Owner of [EgO] Gang : www.egoteam.site.bz]

[Old Online Gamer , Scripter and programmer]

[Contacts : [skype]saim.zia26 - [xfire]saimrock26]

Posted

i am not talking about the data, i am talking about the 'guiSetText', will it change the text to the my data so i only can see it, or it changes the text to everyone ?

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