Booo Posted April 25, 2012 Share Posted April 25, 2012 (edited) hi my script have errors ... can any one fix it please .! function see() local players = getElementsByType ( "player" ) for k,v in ipairs(players) do local seemark = getElementData(v,"seemark") if seemark then return v else return false end end end function consoleCreateMarker ( thePlayer, commandName ) if ( thePlayer ) then local x, y, z = getElementPosition ( thePlayer ) setElementData(thePlayer,"seemark",true) local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170,see) end end addCommandHandler ( "createmarker", consoleCreateMarker ) Edited April 25, 2012 by Guest Link to comment
BorderLine Posted April 25, 2012 Share Posted April 25, 2012 and what are the errors?? use /debugscript 3 nextime to show scriptings errors Link to comment
Booo Posted April 25, 2012 Author Share Posted April 25, 2012 and what are the errors?? use /debugscript 3 nextime to show scriptings errors I can see the Marker, and I did not use Command : ( Link to comment
Axel Posted April 25, 2012 Share Posted April 25, 2012 I fixed it for you and added some help: function see() local players = getElementsByType ( "player" ) for k,v in ipairs(players) do local seemark = getElementData(v,"seemark") if seemark == true then -- If the element data is true return v else return false end end end function consoleCreateMarker ( thePlayer, commandName ) if ( thePlayer ) then local x, y, z = getElementPosition ( thePlayer ) setElementData(thePlayer,"seemark","true") -- set it true local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170,see) end end addCommandHandler ( "createmarker", consoleCreateMarker ) (tested) Link to comment
Booo Posted April 25, 2012 Author Share Posted April 25, 2012 I fixed it for you and added some help: function see() local players = getElementsByType ( "player" ) for k,v in ipairs(players) do local seemark = getElementData(v,"seemark") if seemark == true then -- If the element data is true return v else return false end end end function consoleCreateMarker ( thePlayer, commandName ) if ( thePlayer ) then local x, y, z = getElementPosition ( thePlayer ) setElementData(thePlayer,"seemark","true") -- set it true local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170,see) end end addCommandHandler ( "createmarker", consoleCreateMarker ) (tested) not work !! Link to comment
Axel Posted April 25, 2012 Share Posted April 25, 2012 Did u add it serverside? It works fine for me.. Link to comment
Booo Posted April 25, 2012 Author Share Posted April 25, 2012 Did u add it serverside? It works fine for me.. yes serverside , but not work .! Link to comment
Axel Posted April 25, 2012 Share Posted April 25, 2012 Try now: function see() local players = getElementsByType ( "player" ) for k,v in ipairs(players) do local seemark = getElementData(v,"seemark") if seemark == "true" then -- If the element data is true return v else return false end end end function consoleCreateMarker ( thePlayer, commandName ) if ( thePlayer ) then local x, y, z = getElementPosition ( thePlayer ) setElementData(thePlayer,"seemark","true") -- set it true local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170,see) end end addCommandHandler ( "createmarker", consoleCreateMarker ) Link to comment
Kenix Posted April 25, 2012 Share Posted April 25, 2012 It's wrong. In last argument you attach function Here local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170,see) Also if ( thePlayer ) then This condition not needed. This command triggered when you type this command. So if you type this command player is element in any case. Better way addCommandHandler ( 'createmarker', function( uPlayer ) local nX, nY, nZ = getElementPosition ( uPlayer ) local uMarker = createMarker ( nX + 2, nY + 2, nZ, 'cylinder', 1.5, 255, 255, 0, 170, uPlayer ) end ) Link to comment
Castillo Posted April 25, 2012 Share Posted April 25, 2012 What I understand is that you want to show the marker to the player who created it, if so you can use setElementVisibleTo. function consoleCreateMarker ( thePlayer ) local x, y, z = getElementPosition ( thePlayer ) local theMarker = createMarker ( x + 2, y + 2, z, "cylinder", 1.5, 255, 255, 0, 170 ) setElementVisibleTo ( theMarker, root, false ) -- Hide the marker to everyone. setElementVisibleTo ( theMarker, thePlayer, true ) -- Show the marker to the player. end addCommandHandler ( "createmarker", consoleCreateMarker ) Link to comment
Booo Posted April 25, 2012 Author Share Posted April 25, 2012 Yakuza.Real , Axel, Kenix, Solidsnake14 thx for help , Anyways I fixed my script .. close topic Link to comment
Castillo Posted April 25, 2012 Share Posted April 25, 2012 You're welcome. Topic locked. Link to comment
Recommended Posts