
Loren_ita
Members-
Posts
31 -
Joined
-
Last visited
Everything posted by Loren_ita
-
function Binding () bindKey( "I", "down", modeIO )end function modeIO ( source, key, keyState ) if isCursorShowing ( source ) then showCursor ( false ) else showCursor ( true ) endend --function modeIO ( thePlayer )-- local currentState = isCursorShowing ( thePlayer ) -- local oppositeState = not currentState -- showCursor ( thePlayer, oppositeState ) --end function OnClick ( key, _, _, _, x, y, z ) --if keyState == "up" then return end if key == "left" then local del = getElementData ( source, "teleport" ) destroyElement ( del ) tele1 = createMarker ( x, y, z, cylinder, 1.5, 1, 255, 0, 50 ) setElementData ( tele1, "type", teleport ) setElementData ( source, "teleport", tele1 ) setElementData ( tele1, "owner", source ) elseif key == "right" then local del = getElementData ( source, "destination" ) destroyElement ( del ) tele2 = createMarker ( x, y, z, cylinder, 1.5, 1, 255, 255, 50 ) setElementData ( tele2, "type", destination ) setElementData ( source,"destination", tele2 ) setElementData ( tele2, "owner", source ) endend function MarkerHit ( thePlayer ) local x, y, z = getElementPosition ( tele2 ) setElementPosition( thePlayer, x, y + 1, z )end function Quit ( reason ) destroyElement ( getElementData ( source, "teleport" ) ) destroyElement ( getElementData ( source, "destination" ) ) end addEventHandler ( "onClientResourceStart", getRootElement(), Binding )addEventHandler ( "onClientPlayerQuit", getRootElement(), Quit )addEventHandler ( "onClientClick", getRootElement(), OnClick )addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit ) Now it work but i want to improve it. Who can help my?
-
Ok now script work but when i enter in a marker it don't teleport... I have downloaded the script tutorial N° 1 from mta web site. http://www.mtasa.com/tutorial1.html Now the script is: function Binding () bindKey( "I", "down", modeIO ) end function modeIO ( source, key, keyState ) --This function toggles the cursor on/off if isCursorShowing ( source ) then --If cursor was already showing, showCursor ( false ) --then hide it; else --if it wasn't showing, showCursor ( true ) --then show it. end end function OnClick ( key, _, _, _, x, y, z ) --if keyState == "up" then return end --Don't do anything if he's releasing the button. if key == "left" then local del = getElementData ( source, "teleport" ) --If it's left-click: destroyElement ( del ) local theMarker = createMarker ( x, y, z, cylinder, 1.5, 1, 255, 0, 50 )--Create a cylindric marker setElementData ( theMarker, "type", teleport ) --Mark the cylinder as a teleport setElementData ( source, "teleport", theMarker ) --Link the creator to the teleport setElementData ( theMarker, "owner", source ) --Link the teleport to its creator elseif key == "right" then --If it's right-click local del = getElementData ( source, "destination" ) --If it's left-click: destroyElement ( del ) --Destroy his destination point, if any local theMarker = createMarker ( x, y, z, cylinder, 1.5, 1, 255, 255, 50 ) --Create a glowing corona setElementData ( theMarker, "type", destination ) --Mark the corona as a destination point setElementData ( source,"destination", theMarker ) --Link the creator to the teleport setElementData ( theMarker, "owner", source ) --Link the teleport to its creator end end --This event tells what happens if a player steps inside a marker. function MarkerHit ( player ) if getElementData ( source, "type" ) == teleport then --If the marker is a teleport point, local owner = getElementData ( source, "owner" ) --Get the owner linked to the teleport point. local destination = getElementData ( owner, "destination" ) --Get the destination point linked to the owner. if destination then --If destination point exists, local x, y, z = getElementPosition ( destination ) --Get the destination point's position. setElementPosition ( thePlayer, x, y, z ) --Put the player there. end end end --This event tells what happens if a player disconnects. function Quit ( reason ) destroyElement ( getElementData ( source, "teleport" ) ) --Destroy his teleport point, if any destroyElement ( getElementData ( source, "destination" ) ) --Destroy his destination point, if any end addEventHandler ( "onClientResourceStart", getRootElement(), Binding ) addEventHandler ( "onClientPlayerQuit", getRootElement(), Quit ) addEventHandler ( "onClientClick", getRootElement(), OnClick ) addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit )
-
Ok now script work but when i enter in a marker it don't teleport... I have downloaded the script tutorial N° 1 from mta web site. http://www.mtasa.com/tutorial1.html Now the script is: function Binding () bindKey( "I", "down", modeIO )end function modeIO ( source, key, keyState ) --This function toggles the cursor on/off if isCursorShowing ( source ) then --If cursor was already showing, showCursor ( false ) --then hide it; else --if it wasn't showing, showCursor ( true ) --then show it. endend function OnClick ( key, _, _, _, x, y, z ) --if keyState == "up" then return end --Don't do anything if he's releasing the button. if key == "left" then local del = getElementData ( source, "teleport" ) --If it's left-click: destroyElement ( del ) local theMarker = createMarker ( x, y, z, cylinder, 1.5, 1, 255, 0, 50 )--Create a cylindric marker setElementData ( theMarker, "type", teleport ) --Mark the cylinder as a teleport setElementData ( source, "teleport", theMarker ) --Link the creator to the teleport setElementData ( theMarker, "owner", source ) --Link the teleport to its creator elseif key == "right" then --If it's right-click local del = getElementData ( source, "destination" ) --If it's left-click: destroyElement ( del ) --Destroy his destination point, if any local theMarker = createMarker ( x, y, z, cylinder, 1.5, 1, 255, 255, 50 ) --Create a glowing corona setElementData ( theMarker, "type", destination ) --Mark the corona as a destination point setElementData ( source,"destination", theMarker ) --Link the creator to the teleport setElementData ( theMarker, "owner", source ) --Link the teleport to its creator endend --This event tells what happens if a player steps inside a marker.function MarkerHit ( player ) if getElementData ( source, "type" ) == teleport then --If the marker is a teleport point, local owner = getElementData ( source, "owner" ) --Get the owner linked to the teleport point. local destination = getElementData ( owner, "destination" ) --Get the destination point linked to the owner. if destination then --If destination point exists, local x, y, z = getElementPosition ( destination ) --Get the destination point's position. setElementPosition ( thePlayer, x, y, z ) --Put the player there. end endend --This event tells what happens if a player disconnects.function Quit ( reason ) destroyElement ( getElementData ( source, "teleport" ) ) --Destroy his teleport point, if any destroyElement ( getElementData ( source, "destination" ) ) --Destroy his destination point, if anyend addEventHandler ( "onClientResourceStart", getRootElement(), Binding )addEventHandler ( "onClientPlayerQuit", getRootElement(), Quit )addEventHandler ( "onClientClick", getRootElement(), OnClick )addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit )
-
I'm learning how to script in mta. When i click with the cursor che marker isn't where i click. It appears another place of the map. why? I have copyed this script from mta site and edited it.. Client side: function Script1 () bindKey( "I", "down", modeIO ) end function modeIO ( source, key, keyState ) --This function toggles the cursor on/off if isCursorShowing ( source ) then --If cursor was already showing, showCursor ( false ) --then hide it; else --if it wasn't showing, showCursor ( true ) --then show it. end end function Script4 ( key, keyState, element, x, y, z ) --if keyState == "up" then return end --Don't do anything if he's releasing the button. if key == "left" then local del = getElementData ( source, "teleport" ) --If it's left-click: destroyElement ( del ) local screenx, screeny, worldx, worldy, worldz = getCursorPosition() local theMarker = createMarker ( worldx, worldy, worldz, cylinder, 1.5, 1, 255, 0, 50 ) --Create a cylindric marker setElementData ( theMarker, "type", teleport ) --Mark the cylinder as a teleport setElementData ( source, "teleport", theMarker ) --Link the creator to the teleport setElementData ( theMarker, "owner", source ) --Link the teleport to its creator elseif key == "right" then --If it's right-click local del = getElementData ( source, "destination" ) --If it's left-click: destroyElement ( del ) --Destroy his destination point, if any local screenx, screeny, worldx, worldy, worldz = getCursorPosition() local theMarker = createMarker ( worldx, worldy, worldz, cylinder, 1.5, 1, 255, 255, 50 ) --Create a glowing corona setElementData ( theMarker, "type", destination ) --Mark the corona as a destination point setElementData ( source,"destination", theMarker ) --Link the creator to the teleport setElementData ( theMarker, "owner", source ) --Link the teleport to its creator end end --This event tells what happens if a player steps inside a marker. function Script5 ( player ) if getElementData ( source, "type" ) == teleport then --If the marker is a teleport point, local owner = getElementData ( source, "owner" ) --Get the owner linked to the teleport point. local destination = getElementData ( owner, "destination" ) --Get the destination point linked to the owner. if destination then --If destination point exists, local x, y, z = getElementPosition ( destination ) --Get the destination point's position. setElementPosition ( thePlayer, x, y, z ) --Put the player there. end end end --This event tells what happens if a player disconnects. function Script2 ( reason ) destroyElement ( getElementData ( source, "teleport" ) ) --Destroy his teleport point, if any destroyElement ( getElementData ( source, "destination" ) ) --Destroy his destination point, if any end addEventHandler ( "onClientResourceStart", getRootElement(), Script1 ) addEventHandler ( "onClientPlayerQuit", getRootElement(), Script2 ) addEventHandler ( "onClientClick", getRootElement(), Script4 ) addEventHandler ( "onClientMarkerHit", getRootElement(), Script5 ) Please help my!
-
I'm learning how to script in mta. When i click with the cursor che marker isn't where i click. It appears another place of the map. why? I have copyed this script from mta site and edited it.. Client side: function Script1 () bindKey( "I", "down", modeIO )end function modeIO ( source, key, keyState ) --This function toggles the cursor on/off if isCursorShowing ( source ) then --If cursor was already showing, showCursor ( false ) --then hide it; else --if it wasn't showing, showCursor ( true ) --then show it. endend function Script4 ( key, keyState, element, x, y, z ) --if keyState == "up" then return end --Don't do anything if he's releasing the button. if key == "left" then local del = getElementData ( source, "teleport" ) --If it's left-click: destroyElement ( del ) local screenx, screeny, worldx, worldy, worldz = getCursorPosition() local theMarker = createMarker ( worldx, worldy, worldz, cylinder, 1.5, 1, 255, 0, 50 ) --Create a cylindric marker setElementData ( theMarker, "type", teleport ) --Mark the cylinder as a teleport setElementData ( source, "teleport", theMarker ) --Link the creator to the teleport setElementData ( theMarker, "owner", source ) --Link the teleport to its creator elseif key == "right" then --If it's right-click local del = getElementData ( source, "destination" ) --If it's left-click: destroyElement ( del ) --Destroy his destination point, if any local screenx, screeny, worldx, worldy, worldz = getCursorPosition() local theMarker = createMarker ( worldx, worldy, worldz, cylinder, 1.5, 1, 255, 255, 50 ) --Create a glowing corona setElementData ( theMarker, "type", destination ) --Mark the corona as a destination point setElementData ( source,"destination", theMarker ) --Link the creator to the teleport setElementData ( theMarker, "owner", source ) --Link the teleport to its creator endend --This event tells what happens if a player steps inside a marker.function Script5 ( player ) if getElementData ( source, "type" ) == teleport then --If the marker is a teleport point, local owner = getElementData ( source, "owner" ) --Get the owner linked to the teleport point. local destination = getElementData ( owner, "destination" ) --Get the destination point linked to the owner. if destination then --If destination point exists, local x, y, z = getElementPosition ( destination ) --Get the destination point's position. setElementPosition ( thePlayer, x, y, z ) --Put the player there. end endend --This event tells what happens if a player disconnects.function Script2 ( reason ) destroyElement ( getElementData ( source, "teleport" ) ) --Destroy his teleport point, if any destroyElement ( getElementData ( source, "destination" ) ) --Destroy his destination point, if anyend addEventHandler ( "onClientResourceStart", getRootElement(), Script1 )addEventHandler ( "onClientPlayerQuit", getRootElement(), Script2 )addEventHandler ( "onClientClick", getRootElement(), Script4 )addEventHandler ( "onClientMarkerHit", getRootElement(), Script5 ) Please help my!
-
Very Very Very Very Very Nice! Thanks