Chickelon12 Posted March 30, 2014 Posted March 30, 2014 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 )
WhoAmI Posted March 30, 2014 Posted March 30, 2014 Okey, well. You are tirggering to server, getting data and what's next?
Chickelon12 Posted March 30, 2014 Author Posted March 30, 2014 setting the arrests label text, to the player's data local getdata = getAccountData(theAccount, "Arrests.count") guiSetText ( arrests_lab2, getdata )
Jaysds1 Posted March 30, 2014 Posted March 30, 2014 (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 March 30, 2014 by Guest
Chickelon12 Posted March 30, 2014 Author Posted March 30, 2014 Not working bad argument @ 'guiSetText' [expected string at argument 2, got boolean]
Jaysds1 Posted March 30, 2014 Posted March 30, 2014 Try the code above again. The only reason why you're getting that error is because the Account Data "Arrest.Count" is false, or doesn't exist, so I made the script return either the number of arrests or 0.
Chickelon12 Posted March 30, 2014 Author Posted March 30, 2014 bad argument @ 'getPlayerTeam' [expected player argument 1, got nil] bad argument @ 'getTeamName'
Jaysds1 Posted March 30, 2014 Posted March 30, 2014 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)
Chickelon12 Posted March 31, 2014 Author Posted March 31, 2014 Now it's working thanks,, just a question is anyone going to open the gui will find his account data (arrests.count) or mine ??
$@!m HeRO Posted March 31, 2014 Posted March 31, 2014 ofc his own, if he's logged in with his own account... your account data will be save in your account!
Chickelon12 Posted March 31, 2014 Author Posted March 31, 2014 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 ?
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