Monty Posted July 13, 2012 Share Posted July 13, 2012 hi why this gui doesn't set visible since i used get account data? line 14-15 GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} function guiMyCwindow(w,h,t) local x,y = guiGetScreenSize() return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) end windowjob = guiMyCwindow(301,250,"SAPD agent") guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,140,108,35,"Take job",false,windowjob) GUIEditor_Label[2] = guiCreateLabel(179,140,108,35,"Arrests:" ..tonumber(getAccountData(getPlayerAccount ( source ), "arrest")) ,false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,200,110,36,"Close",false,windowjob) GUIEditor_Button[3] = guiCreateButton(22,200,110,36,"Quit Job",false,windowjob) GUIEditor_Memo[1] = guiCreateLabel(19,33,273,20,"are you sure you want to take this job?",false,windowjob) function SAPDjob(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", marker, SAPDjob) function FBIjobleave(leaveElement) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, SAPDjobleave) function joinTeam() triggerServerEvent("setSAPD",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeSAPDWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeSAPDWindow, false) Link to comment
TAPL Posted July 13, 2012 Share Posted July 13, 2012 getAccountData and getPlayerAccount is server side function Link to comment
Kenix Posted July 13, 2012 Share Posted July 13, 2012 Trigger to client side when you login and set text to this label with account data. Link to comment
TAPL Posted July 13, 2012 Share Posted July 13, 2012 what !?!? what? getAccountData and getPlayerAccount is server side function Link to comment
Al3grab Posted July 13, 2012 Share Posted July 13, 2012 addEventHandler("onPlayerLogin",root,function() local data = getAccountData() -- you should finish it triggerClientEvent(source,"myEvent",source,data) end ) addEvent("myEvent",true) addEventHandler("myEvent",root,function(data) outputChatBox(data) -- or guiSetText end ) Link to comment
HunT Posted July 13, 2012 Share Posted July 13, 2012 -- server side getAccountData setElementData --with event onPlayerLogin spawn wasted etc... --client side data = getElementData --and set the GUI element with "data" Link to comment
Jaysds1 Posted July 14, 2012 Share Posted July 14, 2012 or you could use this function: callServerFunction Link to comment
TAPL Posted July 14, 2012 Share Posted July 14, 2012 or you could use this function: callServerFunction there no benefit of it because it won't return anything. Link to comment
Jaysds1 Posted July 14, 2012 Share Posted July 14, 2012 true, nevermind that post then everyone Link to comment
Monty Posted July 14, 2012 Author Share Posted July 14, 2012 using the way suggested by alegrab how do I use that client code in a gui? (line 15) local marker = createMarker( 1552.4996337891, -1677.3264160156, 15.1953125, "Cylinder", 1.5, 0, 0, 255, 150) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} function guiMyCwindow(w,h,t) local x,y = guiGetScreenSize() return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) end windowjob = guiMyCwindow(301,250,"SAPD agent") guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,140,108,35,"Take job",false,windowjob) GUIEditor_Label[2] = guiCreateLabel(179,140,108,35,"Arrests:" ,false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,200,110,36,"Close",false,windowjob) GUIEditor_Button[3] = guiCreateButton(22,200,110,36,"Quit Job",false,windowjob) GUIEditor_Memo[1] = guiCreateLabel(19,33,273,20,"are you sure you want to take this job?",false,windowjob) function SAPDjob(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", marker, SAPDjob) function FBIjobleave(leaveElement) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, SAPDjobleave) function joinTeam() triggerServerEvent("setSAPD",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeTeam() triggerServerEvent("removeSAPD",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[3] , removeTeam, false) function removeSAPDWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeSAPDWindow, false) Link to comment
Al3grab Posted July 14, 2012 Share Posted July 14, 2012 guiSetText(GUIEditor_Label[2],"Arrests :"..data) Link to comment
Monty Posted July 15, 2012 Author Share Posted July 15, 2012 why doesn't work ? server createBlip ( 1552.4996337891, -1677.3264160156, 15.1953125, 30 ) addEventHandler("onPlayerLogin",root,function() local playeraccount = getPlayerAccount ( source ) local data = getAccountData(playeraccount, "arrest") -- you should finish it local acc = getAccountNamee(playeraccount) triggerClientEvent(source,"myEvent",source,data,acc) end ) function createSAPDTeam () SAPDteam = createTeam ("police", 100, 149, 237) end addEventHandler ("onResourceStart", resourceRoot, createSAPDTeam) function joinSAPD() setPlayerTeam(source,SAPDteam) setElementModel(source, 280) giveWeapon ( source, 3 ) setAccountData( playeraccount, "Occupation", "police") outputChatBox("You are now policeman.",source,0,255,0) end addEvent("setSAPD", true) addEventHandler("setSAPD",root,joinSAPD) function removeSAPD() setPlayerTeam(source,0) setAccountData( playeraccount, "Occupation", "unemployed") outputChatBox("you left your job.",source,0,255,0) end addEvent("removeSAPD", true) addEventHandler("removeSAPD",root,removeSAPD) function policeJob ( attacker, attackerweapon, bodypart, loss ) theTeam = getPlayerTeam ( attacker ) theWL = getPlayerWantedLevel ( source ) theSkin = getElementModel ( attacker ) if (attackerweapon == 3) and (loss > 2 ) and (theWL > 0) then if getTeamName( theTeam ) == "police" or getTeamName( theTeam ) == "SWAT" or getTeamName( theTeam ) == "FBI" then setElementPosition (source, 4076.3999023438, -1788.5, 3.511967, true) theName = getPlayerName ( source ) theCop = getPlayerName ( attacker ) outputChatBox ( "You have been jailed by "..theCop.. " for 10 seconds.", source ) local playeraccount = getPlayerAccount ( attacker ) arrests = tonumber(getAccountData(playeraccount, "arrest")) setAccountData(playeraccount, "arrest", arrests + 1 ) givePlayerMoney (attacker, 100) setTimer ( setElementPosition, 10000, 1, source, 1544.4332275391, -1674.7698974609, 13.688399200439) setPlayerWantedLevel (source, 0) end end end addEventHandler ("onPlayerDamage", getRootElement(), policeJob) client local marker = createMarker( 1552.4996337891, -1677.3264160156, 15.1953125, "Cylinder", 1.5, 0, 0, 255, 150) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} function guiMyCwindow(w,h,t) local x,y = guiGetScreenSize() return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) end windowjob = guiMyCwindow(301,250,"police job") guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,140,108,35,"Take job",false,windowjob) GUIEditor_Label[2] = guiCreateLabel(19,59,108,35,"Arrests : " ,false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,200,110,36,"Close",false,windowjob) GUIEditor_Button[3] = guiCreateButton(22,200,110,36,"Quit Job",false,windowjob) GUIEditor_Memo[1] = guiCreateLabel(19,19,273,20,"are you sure you want to take this job?",false,windowjob) theTeam = getTeamFromName("police") GUIEditor_Memo[2] = guiCreateLabel(19,45,273,20,"On-duty officers : "..countPlayersInTeam(theTeam),false,windowjob) addEvent("myEvent",true) addEventHandler("myEvent",root,function(data, acc) guiSetText(GUIEditor_Label[2],"Arrests : "..data) guiSetText(GUIEditor_Label[2],"Account : "..acc) end ) function SAPDjob(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", marker, SAPDjob) function FBIjobleave(leaveElement) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, SAPDjobleave) function joinTeam() triggerServerEvent("setSAPD",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeTeam() triggerServerEvent("removeSAPD",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[3] , removeTeam, false) function removeSAPDWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeSAPDWindow, false) Link to comment
TAPL Posted July 15, 2012 Share Posted July 15, 2012 line 6 in server local acc = getAccountNamee(playeraccount) should be local acc = getAccountName(playeraccount) Link to comment
Monty Posted July 15, 2012 Author Share Posted July 15, 2012 sorry my bad, but no working anyway Link to comment
TwiX! Posted July 15, 2012 Share Posted July 15, 2012 server local root = getRootElement() createBlip ( 1552.4996337891, -1677.3264160156, 15.1953125, 30 ) addEventHandler("onPlayerLogin",root, function() local playeraccount = getPlayerAccount (source) local data = tonumber(getAccountData(playeraccount, "arrest")) -- you should finish it local acc = getAccountName(playeraccount) triggerClientEvent(source,"myEvent",data,acc) end ) function createSAPDTeam () SAPDteam = createTeam ("police", 100, 149, 237) end addEventHandler ("onResourceStart", resourceRoot, createSAPDTeam) function joinSAPD() if (isGuestAccount(getPlayerAccount(source)) == false) then local playeraccount = getPlayerAccount (source) if not getAccountData(playeraccount,"Occupation") == "police" then setPlayerTeam(source,SAPDteam) setElementModel(source, 280) giveWeapon ( source, 3 ) setAccountData( playeraccount, "Occupation", "police") outputChatBox("You are now policeman.",source,0,255,0) else outputChatBox("Error: You already have this work",source,255,0,0) end else outputChatBox ('Error: Please login or register!',source,255,255,255,true) end end addEvent("setSAPD", true) addEventHandler("setSAPD",root,joinSAPD) function removeSAPD() if (isGuestAccount(getPlayerAccount(source)) == false) then local playeraccount = getPlayerAccount (source) if not getAccountData(playeraccount,"Occupation") == "unemployed" then setPlayerTeam(source,0) setAccountData( playeraccount, "Occupation", "unemployed") outputChatBox("you left your job.",source,0,255,0) else outputChatBox ('Error: You not have work',source,255,255,255,true) end else outputChatBox ('Error: Please login or register!',source,255,255,255,true) end end addEvent("removeSAPD", true) addEventHandler("removeSAPD",root,removeSAPD) function policeJob ( attacker, attackerweapon, bodypart, loss ) theTeam = getPlayerTeam ( attacker ) theWL = getPlayerWantedLevel ( source ) theSkin = getElementModel ( attacker ) if (attackerweapon == 3) and (loss > 2 ) and (theWL > 0) then if getTeamName( theTeam ) == "police" or getTeamName( theTeam ) == "SWAT" or getTeamName( theTeam ) == "FBI" then setElementPosition (source, 4076.3999023438, -1788.5, 3.511967, true) theName = getPlayerName ( source ) theCop = getPlayerName ( attacker ) outputChatBox ( "You have been jailed by "..theCop.. " for 10 seconds.", source ) local playeraccount = getPlayerAccount ( attacker ) arrests = tonumber(getAccountData(playeraccount, "arrest")) setAccountData(playeraccount, "arrest", arrests + 1 ) givePlayerMoney (attacker, 100) setTimer ( setElementPosition, 10000, 1, source, 1544.4332275391, -1674.7698974609, 13.688399200439) setPlayerWantedLevel (source, 0) end end end addEventHandler ("onPlayerDamage", getRootElement(), policeJob) client local root = getRootElement() local marker = createMarker( 1552.4996337891, -1677.3264160156, 15.1953125, "Cylinder", 1.5, 0, 0, 255, 150) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} function guiMyCwindow(w,h,t) local x,y = guiGetScreenSize() return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) end windowjob = guiMyCwindow(301,250,"police job") guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,140,108,35,"Take job",false,windowjob) GUIEditor_Label[2] = guiCreateLabel(19,59,108,35,"Arrests : " ,false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,200,110,36,"Close",false,windowjob) GUIEditor_Button[3] = guiCreateButton(22,200,110,36,"Quit Job",false,windowjob) GUIEditor_Memo[1] = guiCreateLabel(19,19,273,20,"are you sure you want to take this job?",false,windowjob) theTeam = getTeamFromName("police") GUIEditor_Memo[2] = guiCreateLabel(19,45,273,20,"On-duty officers : "..countPlayersInTeam(theTeam),false,windowjob) addEvent("myEvent",true) addEventHandler("myEvent",root, function(data, acc) guiSetText(GUIEditor_Label[2],"Arrests : "..data) guiSetText(GUIEditor_Label[2],"Account : "..acc) -- you need make other label, now you set text on 1 label 2 times end ) function SAPDjob(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", marker, SAPDjob) function FBIjobleave(leaveElement) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, SAPDjobleave) function joinTeam() triggerServerEvent("setSAPD",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeTeam() triggerServerEvent("removeSAPD",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[3] , removeTeam, false) function removeSAPDWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeSAPDWindow, false) Link to comment
TAPL Posted July 15, 2012 Share Posted July 15, 2012 but it won't be updated, -- server side -- local root = getRootElement() createBlip ( 1552.4996337891, -1677.3264160156, 15.1953125, 30 ) addEventHandler("onPlayerLogin",root, function() local playeraccount = getPlayerAccount (source) local data = tonumber(getAccountData(playeraccount, "arrest")) -- you should finish it local acc = getAccountName(playeraccount) triggerClientEvent(source,"myEvent",data,acc) end ) function createSAPDTeam () SAPDteam = createTeam ("police", 100, 149, 237) end addEventHandler ("onResourceStart", resourceRoot, createSAPDTeam) function joinSAPD() if (isGuestAccount(getPlayerAccount(source)) == false) then local playeraccount = getPlayerAccount (source) if not getAccountData(playeraccount,"Occupation") == "police" then setPlayerTeam(source,SAPDteam) setElementModel(source, 280) giveWeapon ( source, 3 ) setAccountData( playeraccount, "Occupation", "police") outputChatBox("You are now policeman.",source,0,255,0) else outputChatBox("Error: You already have this work",source,255,0,0) end else outputChatBox ('Error: Please login or register!',source,255,255,255,true) end end addEvent("setSAPD", true) addEventHandler("setSAPD",root,joinSAPD) function removeSAPD() if (isGuestAccount(getPlayerAccount(source)) == false) then local playeraccount = getPlayerAccount (source) if not getAccountData(playeraccount,"Occupation") == "unemployed" then setPlayerTeam(source,0) setAccountData( playeraccount, "Occupation", "unemployed") outputChatBox("you left your job.",source,0,255,0) else outputChatBox ('Error: You not have work',source,255,255,255,true) end else outputChatBox ('Error: Please login or register!',source,255,255,255,true) end end addEvent("removeSAPD", true) addEventHandler("removeSAPD",root,removeSAPD) function policeJob ( attacker, attackerweapon, bodypart, loss ) theTeam = getPlayerTeam ( attacker ) theWL = getPlayerWantedLevel ( source ) theSkin = getElementModel ( attacker ) if (attackerweapon == 3) and (loss > 2 ) and (theWL > 0) then if getTeamName( theTeam ) == "police" or getTeamName( theTeam ) == "SWAT" or getTeamName( theTeam ) == "FBI" then setElementPosition (source, 4076.3999023438, -1788.5, 3.511967, true) theName = getPlayerName ( source ) theCop = getPlayerName ( attacker ) outputChatBox ( "You have been jailed by "..theCop.. " for 10 seconds.", source ) local playeraccount = getPlayerAccount ( attacker ) arrests = tonumber(getAccountData(playeraccount, "arrest")) setAccountData(playeraccount, "arrest", arrests + 1 ) setElementData(attacker, "arrest", arrests + 1 ) givePlayerMoney (attacker, 100) setTimer ( setElementPosition, 10000, 1, source, 1544.4332275391, -1674.7698974609, 13.688399200439) setPlayerWantedLevel (source, 0) end end end addEventHandler ("onPlayerDamage", getRootElement(), policeJob) -- client side -- local root = getRootElement() local marker = createMarker( 1552.4996337891, -1677.3264160156, 15.1953125, "Cylinder", 1.5, 0, 0, 255, 150) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} function guiMyCwindow(w,h,t) local x,y = guiGetScreenSize() return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) end windowjob = guiMyCwindow(301,250,"police job") guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,140,108,35,"Take job",false,windowjob) GUIEditor_Label[2] = guiCreateLabel(19,59,108,35,"Arrests : " ,false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,200,110,36,"Close",false,windowjob) GUIEditor_Button[3] = guiCreateButton(22,200,110,36,"Quit Job",false,windowjob) GUIEditor_Memo[1] = guiCreateLabel(19,19,273,20,"are you sure you want to take this job?",false,windowjob) theTeam = getTeamFromName("police") GUIEditor_Memo[2] = guiCreateLabel(19,45,273,20,"On-duty officers : "..countPlayersInTeam(theTeam),false,windowjob) addEvent("myEvent",true) addEventHandler("myEvent",root, function(data, acc) guiSetText(GUIEditor_Label[2],"Arrests : "..data) guiSetText(GUIEditor_Label[2],"Account : "..acc) -- you need make other label, now you set text on 1 label 2 times end ) addEventHandler("onClientElementDataChange",root, function(dataName) if getElementType(source) == "player" and dataName == "arrest" then guiSetText(GUIEditor_Label[2],"Arrests : "..getElementData(source,dateName)) end end) function SAPDjob(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", marker, SAPDjob) function FBIjobleave(leaveElement) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, SAPDjobleave) function joinTeam() triggerServerEvent("setSAPD",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeTeam() triggerServerEvent("removeSAPD",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[3] , removeTeam, false) function removeSAPDWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeSAPDWindow, false) Link to comment
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