1LoL1 Posted August 18, 2015 Posted August 18, 2015 (edited) Hello, anyone can help me with this code? or how to change ACTIVE only to "VIP" and when i dont have VIP text will NOT ACTIVE local C8 = guiCreateLabel(80,25,500,500,"ACTIVE",false,VipWindow) guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 0, 255, 0) else local C8 = guiCreateLabel(80,25,500,500,"NOT ACTIVE", false,VipWindow) guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 255, 0, 0) end Edited August 21, 2015 by Guest
t3wz Posted August 18, 2015 Posted August 18, 2015 Check if player is vip and then use guiSetEnabled.
1LoL1 Posted August 18, 2015 Author Posted August 18, 2015 Check if player is vip and then use guiSetEnabled. can you get me please example? its hard for me.
Mr.Loki Posted August 18, 2015 Posted August 18, 2015 create the label then set the text if the player's vip status is changed function asdf() local C8 = guiCreateLabel(80,25,500,500,"",false,VipWindow) if getElementData(localPlayer, "vip") then-- If the player is vip then put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 0, 255, 0) guiSetText(C8,"ACTIVE") else-- else if the player isn't vip put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 255, 0, 0) guiSetText(C8,"NOT ACTIVE") end end
1LoL1 Posted August 18, 2015 Author Posted August 18, 2015 create the label then set the text if the player's vip status is changed function asdf() local C8 = guiCreateLabel(80,25,500,500,"",false,VipWindow) if getElementData(localPlayer, "vip") then-- If the player is vip then put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 0, 255, 0) guiSetText(C8,"ACTIVE") else-- else if the player isn't vip put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 255, 0, 0) guiSetText(C8,"NOT ACTIVE") end end this is when player is in acl.xml in "VIP" ?
1LoL1 Posted August 18, 2015 Author Posted August 18, 2015 and why this not work? if getElementData(localPlayer, "lang") == "EN" then local C1 = guiCreateLabel(10,50,500,500,"",false,VipWindow) guiSetText (C1, "TEST1") guiLabelSetColor ( C1, 0, 255, 0 ) guiSetFont(C1, "default-bold-small") else local C1 = guiCreateLabel(10,50,500,500,"",false,VipWindow) guiSetText (C1, "TEST2") guiLabelSetColor ( C1, 0, 255, 0 ) guiSetFont(C1, "default-bold-small") i change language to "else" but text is again in EN i must restart resource when i want to change language.
Mr.Loki Posted August 18, 2015 Posted August 18, 2015 If you are using the acl for a vip group you need to trigger it from the server side then send the info to client side so the server file you would need to check if the player is in an acl group, I just used a timer for example!: setTimer(function() for i,plr in pairs(getElementsByType"player")do inAcl = x if isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "vip" ) ) then inAcl = true else inAcl = false end triggerClientEvent( plr, "aaaaaa", plr, inAcl) end end,5000,0) when the client file is triggered it will be updated function asdf(vip) local C8 = guiCreateLabel(80,25,500,500,"",false,VipWindow) if vip then-- If the player is vip then put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 0, 255, 0) guiSetText(C8,"ACTIVE") else-- else if the player isn't vip put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 255, 0, 0) guiSetText(C8,"NOT ACTIVE") end end addEvent("aaaaaa",true) addEventHandler( "aaaaaa", root, asdf ) edit: I'm not that good with acl... i barely use it
1LoL1 Posted August 18, 2015 Author Posted August 18, 2015 Put the full code function CreateShopWindow() VipWindow = guiCreateWindow(350,225,320,375,"TEST",false) guiSetAlpha ( VipWindow, 5.00 ) if getElementData(localPlayer, "lang") == "EN" then local C1 = guiCreateLabel(10,50,500,500,"",false,VipWindow) guiSetText (C1, "TEST1") guiLabelSetColor ( C1, 0, 255, 0 ) guiSetFont(C1, "default-bold-small") local C2 = guiCreateLabel(10,75,500,500,"",false,VipWindow) guiSetText (C2, "TEST2") guiLabelSetColor ( C2, 0, 255, 0 ) local C3 = guiCreateLabel(10,100,500,500,"",false,VipWindow) guiSetText (C3, "TEST3") guiLabelSetColor ( C3, 0, 255, 0 ) local C4 = guiCreateLabel(10,125,500,500,"",false,VipWindow) guiSetText (C4, "TEST4") guiLabelSetColor ( C4, 0, 255, 0 ) local C5 = guiCreateLabel(10,150,500,500,"",false,VipWindow) guiSetText (C5, "TEST5") guiLabelSetColor ( C5, 0, 255, 0 ) local C6 = guiCreateLabel(10,175,500,500,"",false,VipWindow) guiSetText (C6, "TEST6") guiLabelSetColor ( C6, 0, 255, 0 ) local C7 = guiCreateLabel(10,25,500,500,"",false,VipWindow) guiSetText (C7, "TEST7") guiSetFont(C7, "default-bold-small") local C8 = guiCreateLabel(80,25,500,500,"",false,VipWindow) guiSetText (C8, "TEST8") guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 255, 0, 0) guiCreateStaticImage(10, 225, 20, 16, ":admin/client/images/flags/test.png",false,VipWindow) test9 = guiCreateLabel(40, 225, 500, 500, "TEST9",false,VipWindow) guiSetText (text9, "TEST") guiSetFont(test9, "default-bold-small") guiCreateStaticImage(10, 250, 20, 16, ":admin/client/images/flags/test.png",false,VipWindow) test10 = guiCreateLabel(40,250, 500, 500, "TEST10",false,VipWindow) setGuiText (text10, "TEST10") guiSetFont(test10, "default-bold-small") local C9 = guiCreateLabel(10, 350, 500, 500, "",false,VipWindow) guiSetText (C9, "TEST11") guiSetFont(C9, "default-bold-small") local C10 = guiCreateLabel(10, 295, 500, 500, "",false,VipWindow) guiSetText (C10, "TEST12") guiSetFont(C10, "default-bold-small") local C11 = guiCreateLabel(10, 315, 500, 500, "",false,VipWindow) guiSetText (C11, "TEST13") guiSetFont(C11, "default-bold-small") else local C1 = guiCreateLabel(10,50,500,500,"",false,VipWindow) guiSetText (C1, "TEST1") guiLabelSetColor ( C1, 0, 255, 0 ) guiSetFont(C1, "default-bold-small") local C2 = guiCreateLabel(10,75,500,500,"",false,VipWindow) guiSetText (C2, "TEST2") guiLabelSetColor ( C2, 0, 255, 0 ) local C3 = guiCreateLabel(10,100,500,500,"",false,VipWindow) guiSetText (C3, "TEST3") guiLabelSetColor ( C3, 0, 255, 0 ) local C4 = guiCreateLabel(10,125,500,500,"",false,VipWindow) guiSetText (C4, "TEST4") guiLabelSetColor ( C4, 0, 255, 0 ) local C5 = guiCreateLabel(10,150,500,500,"",false,VipWindow) guiSetText (C5, "TEST5") guiLabelSetColor ( C5, 0, 255, 0 ) local C6 = guiCreateLabel(10,175,500,500,"",false,VipWindow) guiSetText (C6, "TEST6") guiLabelSetColor ( C6, 0, 255, 0 ) local C7 = guiCreateLabel(10,25,500,500,"",false,VipWindow) guiSetText (C7, "TEST7") guiSetFont(C7, "default-bold-small") local C8 = guiCreateLabel(80,25,500,500,"", false,VipWindow) guiSetText (C8, "TEST8") guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 0, 255, 0) guiCreateStaticImage(10, 225, 20, 16, ":admin/client/images/flags/cz.png",false,VipWindow) local TesT = guiCreateLabel(40, 225, 500, 500, "",false,VipWindow) guiSetText (TesT, "TesT") guiSetFont(TesT, "default-bold-small") guiCreateStaticImage(10, 250, 20, 16, ":admin/client/images/flags/sk.png",false,VipWindow) local tESt = guiCreateLabel(40, 250, 500, 500, "",false,VipWindow) guiSetText (tESt, "TEST") guiSetFont(tESt, "default-bold-small") local C9 = guiCreateLabel(10, 350, 500, 500, "",false,VipWindow) guiSetText (C9, "TEST9") guiSetFont(C9, "default-bold-small") local C10 = guiCreateLabel(10, 295, 500, 500, "",false,VipWindow) guiSetText (C10, "TEST10") guiSetFont(C10, "default-bold-small") local C11 = guiCreateLabel(10, 315, 500, 500, "",false,VipWindow) guiSetText (C11, "TEST11") guiSetFont(C11, "default-bold-small") end guiWindowSetSizable(VipWindow,false) guiSetVisible(VipWindow,false) end addEventHandler("onClientResourceStart", getRootElement(), CreateShopWindow) function ShowGUI ( ) guiSetVisible ( VipWindow, not guiGetVisible ( VipWindow ) ) showCursor ( not isCursorShowing( ) ) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(VipWindow,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(VipWindow,x,y,false) end bindKey ( "F2","down", ShowGUI )
Moderators Citizen Posted August 18, 2015 Moderators Posted August 18, 2015 And where do you use the setElementData for "lang" ? Because we can see you are trying to GET it but you never explained/shown us how you set that element data.
1LoL1 Posted August 18, 2015 Author Posted August 18, 2015 And where do you use the setElementData for "lang" ?Because we can see you are trying to GET it but you never explained/shown us how you set that element data. function test (button, state) if button == "left" and state == "up" then setElementData(getLocalPlayer(), "lang", "EN") guiSetInputEnabled(false) guiSetVisible(GUIEditor_Window[1], false) showCursor(false) end end
1LoL1 Posted August 18, 2015 Author Posted August 18, 2015 [00:28:53] WARNING: [gameplay]/BB/server.lua:4: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [00:28:53] WARNING: [gameplay]/BB/server.lua:4: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] [00:28:53] ERROR: [gameplay]/BB/server.lua:4: attempt to concatenate a boolean value
JR10 Posted August 18, 2015 Posted August 18, 2015 setTimer(function() for i,plr in pairs(getElementsByType"player")do local inAcl if isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( plr ) ), aclGetGroup ( "vip" ) ) then inAcl = true else inAcl = false end triggerClientEvent( plr, "aaaaaa", plr, inAcl) end end,5000,0) thePlayer wasn't defined. I also localized inAcl.
1LoL1 Posted August 18, 2015 Author Posted August 18, 2015 setTimer(function() for i,plr in pairs(getElementsByType"player")do local inAcl if isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( plr ) ), aclGetGroup ( "vip" ) ) then inAcl = true else inAcl = false end triggerClientEvent( plr, "aaaaaa", plr, inAcl) end end,5000,0) thePlayer wasn't defined. I also localized inAcl. lol work thanks but when i delete player in acl.xml there is text ACTIVE and NOT ACTIVE too
KariiiM Posted August 18, 2015 Posted August 18, 2015 lol work thanks but when i delete player in acl.xml there is text ACTIVE and NOT ACTIVE too What you mean?
1LoL1 Posted August 18, 2015 Author Posted August 18, 2015 lol work thanks but when i delete player in acl.xml there is text ACTIVE and NOT ACTIVE too What you mean? When i delete vip i see there ACTIVE and NOT ACTIVE too or when i joined server and i have VIP i see there ACTIVE 3x and NOT ACTIVE 4x all in 1.
JR10 Posted August 18, 2015 Posted August 18, 2015 Because you're creating a gui-label each time the event is triggered, just set the text of the label, you don't have to create a new one each time.
1LoL1 Posted August 18, 2015 Author Posted August 18, 2015 Because you're creating a gui-label each time the event is triggered, just set the text of the label, you don't have to create a new one each time. so guiSetText all delete?
Mr.Loki Posted August 18, 2015 Posted August 18, 2015 change this: function asdf(vip) local C8 = guiCreateLabel(80,25,500,500,"",false,VipWindow) if vip then-- If the player is vip then put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 0, 255, 0) guiSetText(C8,"ACTIVE") else-- else if the player isn't vip put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 255, 0, 0) guiSetText(C8,"NOT ACTIVE") end end addEvent("aaaaaa",true) addEventHandler( "aaaaaa", root, asdf ) to this: C8 = guiCreateLabel(80,25,500,500,"",false,VipWindow)-- putting the label outside the function so it wont be craeated each time the function is called function asdf(vip) if vip then-- If the player is vip then put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 0, 255, 0) guiSetText(C8,"ACTIVE") else-- else if the player isn't vip put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 255, 0, 0) guiSetText(C8,"NOT ACTIVE") end end addEvent("aaaaaa",true) addEventHandler( "aaaaaa", root, asdf )
1LoL1 Posted August 18, 2015 Author Posted August 18, 2015 change this: function asdf(vip) local C8 = guiCreateLabel(80,25,500,500,"",false,VipWindow) if vip then-- If the player is vip then put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 0, 255, 0) guiSetText(C8,"ACTIVE") else-- else if the player isn't vip put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 255, 0, 0) guiSetText(C8,"NOT ACTIVE") end end addEvent("aaaaaa",true) addEventHandler( "aaaaaa", root, asdf ) to this: C8 = guiCreateLabel(80,25,500,500,"",false,VipWindow)-- putting the label outside the function so it wont be craeated each time the function is called function asdf(vip) if vip then-- If the player is vip then put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 0, 255, 0) guiSetText(C8,"ACTIVE") else-- else if the player isn't vip put this label guiSetFont(C8, "default-bold-small") guiLabelSetColor(C8, 255, 0, 0) guiSetText(C8,"NOT ACTIVE") end end addEvent("aaaaaa",true) addEventHandler( "aaaaaa", root, asdf ) lol work thanks but how to change text now
1LoL1 Posted August 18, 2015 Author Posted August 18, 2015 You're already doing that with guiSetText. //EDIT: Now i using guiSetTexts and when i change language nothing only when i restarted resource.
1LoL1 Posted August 19, 2015 Author Posted August 19, 2015 ok this work but when i change language text is not changed i think problem is in GUI. When i want change text i must restart resource. Now its GUI: F2 = Open F2 = Close i think must be: F2 = CreateWindow F2 = DestroyWindow or i dont know function ShowGUI ( ) guiSetVisible ( VipWindow, not guiGetVisible ( VipWindow ) ) showCursor ( not isCursorShowing( ) ) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(VipWindow,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(VipWindow,x,y,false) end bindKey ( "F2","down", ShowGUI )
KariiiM Posted August 20, 2015 Posted August 20, 2015 ok this work but when i change language text is not changed i think problem is in GUI. When i want change text i must restart resource. Now its GUI:F2 = Open F2 = Close i think must be: F2 = CreateWindow F2 = DestroyWindow or i dont know I didn't get your point, explain more better
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