Annas Posted January 13, 2016 Share Posted January 13, 2016 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
aka Blue Posted January 13, 2016 Share Posted January 13, 2016 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
Annas Posted January 13, 2016 Author Share Posted January 13, 2016 I added it , as Server Side but .. Error in debugscript attempt to call global 'getLocalPlayer' (a nil value) Link to comment
aka Blue Posted January 13, 2016 Share Posted January 13, 2016 Change it on the meta.xml. Type = client, not server. Link to comment
Annas Posted January 13, 2016 Author Share Posted January 13, 2016 Change it on the meta.xml. Type = client, not server. When i did the command , cursor will shows , but there is no outputChatBox , and when i click on any object , nothing happend , cursor stills active .. help please.... Link to comment
aka Blue Posted January 13, 2016 Share Posted January 13, 2016 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
Annas Posted January 13, 2016 Author Share Posted January 13, 2016 ! 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
aka Blue Posted January 13, 2016 Share Posted January 13, 2016 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
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