Jump to content

BindKey and Marker


Scommer

Recommended Posts

I'm trying to make that when player hit the marker and press "f" button he will be teleported to interior,but i doing something wrong cuz when i hit marker it teleports me to interior,but i wanna make that if i press "f" button only then marker teleport me to interior.

local enterLSPD = createMarker ( 1554.7901611328, -1675.5651855469, 15.116052627563, "cylinder", 1.1, 0, 255, 0, 175  )
function MarkerHit ( player, hitPlayer, matchingDimensio, key, keyState )
if bindKey ( player, "f", "down", MarkerHit ) and getElementType(hitPlayer)=="player" and source == enterLSPD   then
setElementInterior( hitPlayer, 6, 246.78932189941 , 62.632732391357, 1002.6146240234 )
setElementPosition(hitPlayer,247.78932189941,65.632732391357,1004.6146240234)
setPedRotation(hitPlayer,90)
end
end
 
function bindKeyLSPD ( player, commandName )
bindKey ( player, "f", "down", MarkerHit )
end
addEventHandler ( "onPlayerJoin", getRootElement(), bindKeyLSPD )

Link to comment

thats my way of a code like your, should work :) i think you need to bind your key when you hit marker so i did a function for that and also function to unbind key, when you leave marker.

local enterLSPD = createMarker ( 1554.7901611328, -1675.5651855469, 15.116052627563, "cylinder", 1.1, 0, 255, 0, 175  )
 
function markerHit( player )
if getElementType( player ) == "player" and source == enterLSPD then
bindKey( player, "f", "down", teleport )
outputChatBox( "Press 'f' button to teleport somewhere..", player, 0, 255, 0 ) 
end
end
addEventHandler( "onMarkerHit", getRootElement(), markerHit )
 
function markerLeave( player )
if getElementType( player ) == "player" and source == enterLSPD then
unbindKey( player, "f", "down", teleport )
end
end
addEventHandler( "onMarkerLeave", getRootElement(), markerLeave )
 
function teleport( player, key, keyState )
setElementInterior( player, 6, 246.78932189941 , 62.632732391357, 1002.6146240234 )
setElementPosition( player, 247.78932189941, 65.632732391357, 1004.6146240234 )
setPedRotation( player, 90 )
end

Link to comment

In DaK script unbindkey doesn't work so i made it working after long time thinking :D

local enterLSPD = createMarker ( 1554.7901611328, -1675.5651855469, 15.116052627563, "cylinder", 1.1, 0, 255, 0, 175  )
 
function markerHit( player )
if getElementType( player ) == "player" and source == enterLSPD then
bindKey( player, "f", "down", teleport )
end
end
addEventHandler( "onMarkerHit", getRootElement(), markerHit )
 
function teleport( player, key, keyState )
setElementInterior( player, 6, 246.78932189941 , 62.632732391357, 1002.6146240234 )
setElementPosition( player, 247.78932189941, 65.632732391357, 1004.6146240234 )
setPedRotation( player, 90 )
unbindKey ( player, "f", "down", teleport )
end

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