Javier Posted July 17, 2013 Posted July 17, 2013 Hola. Queria saber como puedo hacer para que cuando un player entra en una zona y si aprieta determinada tecla, le mande a ese player a una ubicacion determinada?? Gracias
Castillo Posted July 17, 2013 Posted July 17, 2013 createColRectangle bindKey unbindKey setElementPosition onColShapeHit onColShapeLeave
Javier Posted July 17, 2013 Author Posted July 17, 2013 Lo intenté así pero me dice bad argument en la linea 19. Area = createColRectangle ( -2535.9562988281, 1498.9573974609, 300, 800 ) Radar = createRadarArea ( -2535.9562988281, 1498.9573974609, 300, 800, 255, 0, 0, 150 ) posX = 0 posY = 0 posZ = 0 function Boat ( thePlayer, matchingDimension ) if (getElementType(thePlayer) == "player") then outputChatBox( getPlayerName(thePlayer) .. "Estás en la Zona.Presiona F7 si queres entrar.", thePlayer, 0, 200, 0 ) setElementPosition( thePlayer, posX, posY, posZ) end end function StartKey() addEventHandler ( "onColShapeHit", Area, Boat ) end bindKey(thePlayer,"F7","down", StartKey) function outBoat ( thePlayer, matchingDimension ) if (getElementType(thePlayer) == "player") then unbindKey(thePlayer,"F7","down", outBoat) end end addEventHandler ( "onColShapeLeave", Area, outBoat )
Castillo Posted July 17, 2013 Posted July 17, 2013 'thePlayer' no esta definido, ademas de que no tiene sentido.
Javier Posted July 17, 2013 Author Posted July 17, 2013 'thePlayer' no esta definido, ademas de que no tiene sentido. Porqué no tiene sentido? Me guié por el ejemplo de la wiki de dxDrawText... Ademas esto no es definir thePlayer?? if (getElementType(thePlayer) == "player") then
Castillo Posted July 17, 2013 Posted July 17, 2013 Estas creando un bind ( mal hecho ) para que ponga un event handler, es alrevez.
AlvareZ_ Posted July 17, 2013 Posted July 17, 2013 Primero que nada el thePlayer se define en la funcion function (thePlayer)
Javier Posted July 17, 2013 Author Posted July 17, 2013 Primero que nada el thePlayer se define en la funcion function (thePlayer) Siempre estuvo en la funcion...
AlvareZ_ Posted July 17, 2013 Posted July 17, 2013 Perdona me guie por el Comentario de Castillo. Sabes todo esta en client-side no necesita definir thePlayer en el bindkey, Intenta esto: Area = createColRectangle ( -2535.9562988281, 1498.9573974609, 300, 800 ) Radar = createRadarArea ( -2535.9562988281, 1498.9573974609, 300, 800, 255, 0, 0, 150 ) posX = 0 posY = 0 posZ = 0 function Boat ( thePlayer, matchingDimension ) if (getElementType(thePlayer) == "player") then outputChatBox( getPlayerName(thePlayer) .. "Estás en la Zona.Presiona F7 si queres entrar.", 0, 200, 0, false ) setElementPosition( thePlayer, posX, posY, posZ) end end function StartKey() addEventHandler ( "onColShapeHit", Area, Boat ) end bindKey("F7","down", StartKey) function outBoat ( thePlayer, matchingDimension ) if (getElementType(thePlayer) == "player") then unbindKey("F7","down", startKey) end end addEventHandler ( "onColShapeLeave", Area, outBoat )
Javier Posted July 17, 2013 Author Posted July 17, 2013 Me dice : bad argument at line 19: @bindKey. PD Lo tengo en server-side.
Alexs Posted July 17, 2013 Posted July 17, 2013 Claro por eso, es Client-Side Esos eventos son server-side.
Alexs Posted July 17, 2013 Posted July 17, 2013 Es client y server. pero hay esta como client No... lee la Wiki: onColShapeHit. PD: Evita borrar tus mensajes.
AlvareZ_ Posted July 17, 2013 Posted July 17, 2013 Hm si, Tienes razón nunca me fijo de los eventos: Area = createColRectangle ( -2535.9562988281, 1498.9573974609, 300, 800 ) Radar = createRadarArea ( -2535.9562988281, 1498.9573974609, 300, 800, 255, 0, 0, 150 ) posX = 0 posY = 0 posZ = 0 function Boat ( thePlayer, matchingDimension ) if (getElementType(thePlayer) == "player") then outputChatBox( getPlayerName(thePlayer) .. "Estás en la Zona.Presiona F7 si queres entrar.", thePlayer, 0, 200, 0, false ) setElementPosition( thePlayer, posX, posY, posZ) end end function StartKey() addEventHandler ( "onColShapeHit", Area, Boat ) end bindKey(source, "F7","down", StartKey) function outBoat ( ) if (getElementType(source) == "player") then unbindKey(source, "F7","down", startKey) end end addEventHandler ( "onColShapeLeave", Area, outBoat )
Alexs Posted July 17, 2013 Posted July 17, 2013 Hm si, Tienes razón nunca me fijo de los eventos: Area = createColRectangle ( -2535.9562988281, 1498.9573974609, 300, 800 ) Radar = createRadarArea ( -2535.9562988281, 1498.9573974609, 300, 800, 255, 0, 0, 150 ) posX = 0 posY = 0 posZ = 0 function Boat ( thePlayer, matchingDimension ) if (getElementType(thePlayer) == "player") then outputChatBox( getPlayerName(thePlayer) .. "Estás en la Zona.Presiona F7 si queres entrar.", thePlayer, 0, 200, 0, false ) setElementPosition( thePlayer, posX, posY, posZ) end end function StartKey() addEventHandler ( "onColShapeHit", Area, Boat ) end bindKey(source, "F7","down", StartKey) function outBoat ( ) if (getElementType(source) == "player") then unbindKey(source, "F7","down", startKey) end end addEventHandler ( "onColShapeLeave", Area, outBoat ) No defines 'source'.
AlvareZ_ Posted July 17, 2013 Posted July 17, 2013 Area = createColRectangle ( -2535.9562988281, 1498.9573974609, 300, 800 ) Radar = createRadarArea ( -2535.9562988281, 1498.9573974609, 300, 800, 255, 0, 0, 150 ) posX = 0 posY = 0 posZ = 0 function Boat ( thePlayer, matchingDimension ) if (getElementType(thePlayer) == "player") then outputChatBox( getPlayerName(thePlayer) .. "Estás en la Zona.Presiona F7 si queres entrar.", thePlayer, 0, 200, 0, false ) setElementPosition( thePlayer, posX, posY, posZ) end end function StartKey(source) addEventHandler ( "onColShapeHit", Area, Boat ) end bindKey(source, "F7","down", StartKey) function outBoat ( source ) if (getElementType(source) == "player") then unbindKey(source, "F7","down", startKey) end end addEventHandler ( "onColShapeLeave", Area, outBoat )
Alexs Posted July 17, 2013 Posted July 17, 2013 Area = createColRectangle ( -2535.9562988281, 1498.9573974609, 300, 800 ) Radar = createRadarArea ( -2535.9562988281, 1498.9573974609, 300, 800, 255, 0, 0, 150 ) posX = 0 posY = 0 posZ = 0 function Boat ( thePlayer, matchingDimension ) if (getElementType(thePlayer) == "player") then outputChatBox( getPlayerName(thePlayer) .. "Estás en la Zona.Presiona F7 si queres entrar.", thePlayer, 0, 200, 0, false ) setElementPosition( thePlayer, posX, posY, posZ) end end function StartKey(source) addEventHandler ( "onColShapeHit", Area, Boat ) end bindKey(source, "F7","down", StartKey) function outBoat ( source ) if (getElementType(source) == "player") then unbindKey(source, "F7","down", startKey) end end addEventHandler ( "onColShapeLeave", Area, outBoat ) Sigue sin estar definido, 'bindKey' esta fuera de esa función.
AlvareZ_ Posted July 17, 2013 Posted July 17, 2013 Area = createColRectangle ( -2535.9562988281, 1498.9573974609, 300, 800 ) Radar = createRadarArea ( -2535.9562988281, 1498.9573974609, 300, 800, 255, 0, 0, 150 ) posX = 0 posY = 0 posZ = 0 function Boat ( source ) bindKey(source, "F7","down", function(source, matchingDimension) if (getElementType(source) == "player") then outputChatBox( getPlayerName(source) .. "Estás en la Zona.Presiona F7 si queres entrar.", source, 0, 200, 0, false ) setElementPosition(source, posX, posY, posZ) end end) end addEventHandler ( "onColShapeHit", Area, Boat ) function outBoat ( source ) if (getElementType(source) == "player") then unbindKey(source, "F7","down", startKey) end end addEventHandler ( "onColShapeLeave", Area, outBoat )
Alexs Posted July 17, 2013 Posted July 17, 2013 Area = createColRectangle ( -2535.9562988281, 1498.9573974609, 300, 800 ) Radar = createRadarArea ( -2535.9562988281, 1498.9573974609, 300, 800, 255, 0, 0, 150 ) posX = 0 posY = 0 posZ = 0 function Boat ( source ) bindKey(source, "F7","down", function(source, matchingDimension) if (getElementType(source) == "player") then outputChatBox( getPlayerName(source) .. "Estás en la Zona.Presiona F7 si queres entrar.", source, 0, 200, 0, false ) setElementPosition(source, posX, posY, posZ) end end) end addEventHandler ( "onColShapeHit", Area, Boat ) function outBoat ( source ) if (getElementType(source) == "player") then unbindKey(source, "F7","down", startKey) end end addEventHandler ( "onColShapeLeave", Area, outBoat ) No estoy seguro de que sea buena idea llamar al jugador igual que al colShape y eso hace que al salir la tecla no se desbindee ya que eliminaste la función 'startKey'.
AlvareZ_ Posted July 17, 2013 Posted July 17, 2013 A mi me funciona perfectamente, Solo que estaba mal el output, Bueno en difinitivo es: Area = createColRectangle ( -2535.9562988281, 1498.9573974609, 300, 800 ) Radar = createRadarArea ( -2535.9562988281, 1498.9573974609, 300, 800, 255, 0, 0, 150 ) posX = 0 posY = 0 posZ = 0 function Boat ( source ) bindKey(source, "F7","down", function(source, matchingDimension) if (getElementType(source) == "player") then setElementPosition(source, posX, posY, posZ) end end) outputChatBox( getPlayerName(source) .. "Estás en la Zona.Presiona F7 si queres entrar.", source, 0, 200, 0, false ) end addEventHandler ( "onColShapeHit", Area, Boat ) function outBoat ( source ) if (getElementType(source) == "player") then unbindKey(source, "F7","down", startKey) end end addEventHandler ( "onColShapeLeave", Area, outBoat )
Alexs Posted July 17, 2013 Posted July 17, 2013 A mi me funciona perfectamente Linea 22: unbindKey(source, "F7","down", startKey) Eso daría error constantemente por que 'startKey' no existe en tu código.
AlvareZ_ Posted July 17, 2013 Posted July 17, 2013 Hm que raro, Pero no me da error debug y se cancela el bindkey.
Alexs Posted July 17, 2013 Posted July 17, 2013 (edited) Area = createColRectangle ( -2535.9562988281, 1498.9573974609, 300, 800 ) Radar = createRadarArea ( -2535.9562988281, 1498.9573974609, 300, 800, 255, 0, 0, 150 ) posX = 0 posY = 0 posZ = 0 function startKey (thePlayer) setElementPosition(thePlayer, posX, posY, posZ) end function Boat ( thePlayer ) if (getElementType(thePlayer) == "player") then bindKey(thePlayer, "F7","down", starKey ) outputChatBox( getPlayerName(thePlayer) .. "Estás en la Zona.Presiona F7 si queres entrar.", thePlayer, 0, 200, 0, false ) end end addEventHandler ( "onColShapeHit", Area, Boat ) function outBoat ( thePlayer ) if (getElementType(thePlayer) == "player") then unbindKey(thePlayer, "F7","down", startKey) end end addEventHandler ( "onColShapeLeave", Area, outBoat ) Edited July 17, 2013 by Guest
AlvareZ_ Posted July 17, 2013 Posted July 17, 2013 esta haciendo exactamente lo mismo que el mio. Cual es la diferencia ?
Recommended Posts