Jump to content

Walking Underwater


GerardWay

Recommended Posts

Server
addEventHandler ( 'onResourceStart', resourceRoot, 
    function ( ) 
        for _,p in next, getElementsByType ( 'player' ) do 
            local acc = getPlayerAccount ( p ); 
            if isGuestAccount ( acc ) then return end; 
            local accName = getAccountName ( acc ); 
            if isObjectInACLGroup ( 'user.'..accName, aclGetGroup ( 'Admin' ) ) then 
                setElementData ( p, 'isAdmin', true ); 
            end 
        end 
    end 
); 
  
addEventHandler ( 'onPlayerLogin', root, 
    function ( _,acc ) 
        local accName = getAccountName ( acc ) 
        if isObjectInACLGroup ( 'user.'..accName, aclGetGroup ( 'Admin' ) ) then 
            setElementData ( source, 'isAdmin', true ); 
        end 
    end 
); 
  
addEventHandler ( 'onPlayerLogout', root, 
    function ( ) 
        setElementData ( source, 'isAdmin', false ); 
    end 
); 

Client

function noDamage ( ) 
    if isElementInWater ( localPlayer ) and getElementData ( localPlayer, 'isAdmin' ) == true then 
        cancelEvent ( ); 
    end 
end 
  
cancel = false; 
  
addCommandHandler ( 'water', 
    function ( ) 
        if cancel == false then 
            addEventHandler ( 'OnClientPlayerDamage', root, noDamage ); 
            cancel = true; 
        else 
            removeEventHandler ( 'OnClientPlayerDamage', root, noDamage ); 
        end 
    end 
); 

We know you're a professional, but why not let him learn a little bit?

Link to comment

1) 'OnClientPlayerDamage' event doesn't existed. You should know. Right is 'onClientPlayerDamage'

2) You just cancel damage in water but author this topic wants to walk underwater. Why? So you need just change a position of player.

3) Better storage in element data player's acl group instead of isAdmin/Moderator, ...

Edited by Guest
Link to comment
1) 'OnClientPlayerDamage' event doesn't existed. You should know. Right is 'onClientPlayerDamage'

2) You just cancel damage in water but author this topic wants to walk underwater.

About the "On" thing, It's just a typing mistake, But you're right, All i thought about was the damage and not the ability to walk .

Abologise =D + Thanx for the info ..

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