Jump to content

Help ! , Show/hide a cursor


Annas

Recommended Posts

Hello Guys,

Today i just tried to make a script ,

do a command , show a cursor , set data .

click on any object by the cursor , set data, hide the cursor.

here is my code:

-- SERVER SIDE

function showCursor (player) 
    local adminlevel = getElementData(player, "admin.number") 
    if (adminlevel >= 2) then 
        showCursor(true) 
        setElementData(player, "CursorIsOn", true) 
        setElementData(player, "CursorIsOff", false) 
        outputChatBox("Texture Mod ON, please Select an object.", player, 255, 255, 255) 
    end 
end 
addCommandHandler("texon", showCursor) 
  
function editit ( player, clickedElement ) 
if getElementData(player, "CursorIsOff") == true then return end 
if getElementData(player, "CursorIsOn") == true then 
    if ( clickedElement ) then 
        local elementType = getElementType ( clickedElement ) 
        setElementData(player, "underEdit", true) 
        showCursor(false) 
        outputChatBox("Object Selected", player, 255, 255, 255) 
    end 
end 
addEventHandler ( "onClientClick", getRootElement(), editit ) 

It's not working .. Cursor didnt shows.. help me please

Link to comment

This is because, the function is called 'showCursor' and this already exists. Remember too, that onClientClick is Client-Side function, then you need to use localPlayer for the elementData. Try this, should work:

local player = getLocalPlayer ( ) 
  
function startEdit ( ) 
    local adminlevel = getElementData ( player, "admin.number" ) or 0 
    if ( adminlevel >= 2 ) then 
        showCursor ( true ) 
        setElementData ( player, "editing", true ) 
        outputChatBox("[Texture Mode ON] Please, select an object.", player, 255, 255, 255) 
    end 
end 
addCommandHandler ( "texon", startEdit ) 
  
addEventHandler ( "onClientClick", getRootElement ( ), 
    function ( button, state, _, _, _, _, _, clickedElement  ) 
        if ( getElementData ( source, "editing" ) == true ) then 
            if ( button == "left" ) and ( state == "down" ) then 
                if ( clickedElement ) then 
                    setElementData(player, "underEdit", true) 
                    showCursor ( false ) 
                    outputChatBox("Object selected", player, 255, 255, 255) 
                end 
            end 
        end 
    end 
) 

Link to comment

Ajá, ok. My mistake, sorry. Try this and tell me if it works:

function startEdit ( player ) 
    local adminlevel = getElementData ( player, "admin.number" ) or 0 
    if ( adminlevel >= 2 ) then 
        showCursor ( true ) 
        setElementData ( player, "editing", true ) 
        outputChatBox("[Texture Mode ON] Please, select an object.", player, 255, 255, 255) 
    end 
end 
addCommandHandler ( "texon", startEdit ) 
  
addEventHandler ( "onClientClick", getRootElement ( ), 
    function ( button, state, _, _, _, _, _, clickedElement  ) 
        if ( getElementData ( source, "editing" ) == true ) then 
            if ( button == "left" ) and ( state == "down" ) then 
                if ( clickedElement ) then 
                    setElementData ( source, "underEdit", true ) 
                    showCursor ( false ) 
                    outputChatBox("Object selected", source, 255, 255, 255) 
                end 
            end 
        end 
    end 
) 

Link to comment

:( !

Not working , i added it in CLIENT SIDE.

even it didnt shows the cursor , and it didnt show the output ..

Error in Debug script:

bad argument @ 'getElementData' [Expected element at argument 1, got string 'texon']

EDIT:

and..

Some of my players in my server got kicked for this reason:

Download error: Error downloading requested files. Couldn't connect to server. [Failed connect to 87.98.180.15:22060; No error] [CSTtex/texture_sv.lua]

Link to comment

Ehm, ¿do you edit the code that i give to you? Because, this is not normal...

bad argument @ 'getElementData' [Expected element at argument 1, got string 'texon'] 

The only getElementData's are:

getElementData ( player, "admin.number" ) or 0 

( getElementData ( source, "editing" ) == true ) 

And, for the edit... this is not my problem, the message tells you where is the error:

Download error: Error downloading requested files. Couldn't connect to server. [Failed connect to 87.98.180.15:22060; No error] [CSTtex/texture_sv.lua] 

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