emuk Posted January 28, 2013 Share Posted January 28, 2013 it is possible to check some conditions ? for example: function true () while abc == true do outputChatBox( "Is true." ) end end addCommandHandler ( "true", true ) function setTrue () abc = true end addCommandHandler ( "settrue", settrue ) then until abc is true it outputChatBox and when is false it stops automatically (break) outputChatBox is an example, I do not want is that every second one written in chat thanks Link to comment
myonlake Posted January 28, 2013 Share Posted January 28, 2013 Yes, of course. But remember to initialize the variable outside the functions first so it'll return something else than errors. Remember to break the while-loop. Link to comment
3NAD Posted January 28, 2013 Share Posted January 28, 2013 of course it's possible, Like this Example : visible = false addCommandHandler ( "show", function ( ) if ( visible == false ) then guiSetVisible ( Window, true ) else guiSetVisible ( Window, false ) end end ) Link to comment
emuk Posted January 28, 2013 Author Share Posted January 28, 2013 thanks but I need something like this: visible = false addCommandHandler ( "show", function ( ) if ( visible == false ) then guiSetVisible ( Window, true ) else (here something to stop what happens before) end end ) basically I need to stop the resource for a player Do this until that happens otherwise stops. EDIT or if it possible to add a setting for client and everyone chooses if start it or not. Link to comment
3NAD Posted January 28, 2013 Share Posted January 28, 2013 Actually, I didn't understand what do you need ! Did you mean like this ? visible = false addCommandHandler ( "show", function ( ) if ( visible == false ) then guiSetVisible ( Window, true ) visible = true else guiSetVisible ( Window, false ) visible = false end end ) Or this addCommandHandler ( "show", function ( ) if ( visible == false ) then guiSetVisible ( Window, true ) else guiSetVisible ( Window, false ) end end ) addCommandHandler ( "chgValue", function ( ) if ( visible == false ) then visible = true outputChatBox ( "* Changed To 'True' !!", 0, 255, 0, true ) else visible = false outputChatBox ( "* Changed To 'False' !!", 255, 0, 0, true ) end end ) Link to comment
emuk Posted January 28, 2013 Author Share Posted January 28, 2013 excuse my explanation, I need to stop the resource for one person and not for the entire server. I try to explain better: for example, a resource that is started automatically change hud and a player don't want it so with a command stop this function only for him. or I could put an option where each player decides whether or not to automatically start (but I do not know how to do) however i'll try it in another way Link to comment
3NAD Posted January 28, 2013 Share Posted January 28, 2013 Hmm.. You can't Stop resource for 1 person ! But you can use some Codes to make the HUD starting with somebody's, Like This : addEventHandler ( "onPlayerJoin", root, function ( ) if ( getPlayerName ( source ) == "emuk" ) then setElementData ( source, "VIP.person", true ) end end ) addEventHandler ( "onPlayerChat", root, function ( ) if getElementData ( source, "VIP.person" ) then cancelEvent ( ) local r, g, b = getPlayerNametagColor ( source ) outputChatBox ( "[VIP] "..getPlayerName ( source ).." : ", root, r, g, b, true ) else cancelEvent ( ) local r, g, b = getPlayerNametagColor ( source ) outputChatBox ( getPlayerName ( source ).." : ", root, r, g, b, true ) end end ) You Can Edit The HUD Script, To make it With ElementData, If Player has the ElementData, Change his HUD. Did you understand ? Link to comment
emuk Posted January 28, 2013 Author Share Posted January 28, 2013 thanks but I did not understand how to use ElementData, I tried to set something but it's like it does not save Link to comment
emuk Posted January 29, 2013 Author Share Posted January 29, 2013 thank you for your patience I think I understand it is one problem getElementData if i write this it work: local localPlayerName = getPlayerName(getLocalPlayer()) function vip () if (localPlayerName == "emuk") then --and we output it to the chatbox setElementData ( source, "VIP.person", true ) outputChatBox( "work." ) end end addCommandHandler ( "setvip", vip ) when i add this it say always no: function vip2 () if getElementData ( localPlayerName, "VIP.person" ) then outputChatBox( "yes." ) else outputChatBox( "no." ) end end addCommandHandler ( "s2", vip2 ) edit now i fixed some error Link to comment
TAPL Posted January 29, 2013 Share Posted January 29, 2013 change this if getElementData ( localPlayerName, "VIP.person" ) then to if getElementData ( localPlayer, "VIP.person" ) then 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