Jump to content

help me to check conditions


emuk

Recommended Posts

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

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

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 :wink:

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

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

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

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

thank you for your patience :D

I think I understand it is one problem getElementData :lol:

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

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