Javier Posted July 17, 2013 Share 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 Link to comment
Castillo Posted July 17, 2013 Share Posted July 17, 2013 createColRectangle bindKey unbindKey setElementPosition onColShapeHit onColShapeLeave Link to comment
Javier Posted July 17, 2013 Author Share 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 ) Link to comment
Javier Posted July 17, 2013 Author Share Posted July 17, 2013 Alguien puede ayudarme? Link to comment
Castillo Posted July 17, 2013 Share Posted July 17, 2013 'thePlayer' no esta definido, ademas de que no tiene sentido. Link to comment
Javier Posted July 17, 2013 Author Share 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 Link to comment
Castillo Posted July 17, 2013 Share Posted July 17, 2013 Estas creando un bind ( mal hecho ) para que ponga un event handler, es alrevez. Link to comment
AlvareZ_ Posted July 17, 2013 Share Posted July 17, 2013 Primero que nada el thePlayer se define en la funcion function (thePlayer) Link to comment
Javier Posted July 17, 2013 Author Share Posted July 17, 2013 Primero que nada el thePlayer se define en la funcion function (thePlayer) Siempre estuvo en la funcion... Link to comment
AlvareZ_ Posted July 17, 2013 Share 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 ) Link to comment
Javier Posted July 17, 2013 Author Share Posted July 17, 2013 Me dice : bad argument at line 19: @bindKey. PD Lo tengo en server-side. Link to comment
AlvareZ_ Posted July 17, 2013 Share Posted July 17, 2013 Claro por eso, es Client-Side Link to comment
Alexs Posted July 17, 2013 Share Posted July 17, 2013 Claro por eso, es Client-Side Esos eventos son server-side. Link to comment
Alexs Posted July 17, 2013 Share Posted July 17, 2013 Es client y server. pero hay esta como client No... lee la Wiki: onColShapeHit. PD: Evita borrar tus mensajes. Link to comment
AlvareZ_ Posted July 17, 2013 Share 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 ) Link to comment
Alexs Posted July 17, 2013 Share 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'. Link to comment
AlvareZ_ Posted July 17, 2013 Share 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 ) Link to comment
Alexs Posted July 17, 2013 Share 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. Link to comment
AlvareZ_ Posted July 17, 2013 Share 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 ) Link to comment
Alexs Posted July 17, 2013 Share 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'. Link to comment
AlvareZ_ Posted July 17, 2013 Share 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 ) Link to comment
Alexs Posted July 17, 2013 Share 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. Link to comment
AlvareZ_ Posted July 17, 2013 Share Posted July 17, 2013 Hm que raro, Pero no me da error debug y se cancela el bindkey. Link to comment
Alexs Posted July 17, 2013 Share 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 Link to comment
AlvareZ_ Posted July 17, 2013 Share Posted July 17, 2013 esta haciendo exactamente lo mismo que el mio. Cual es la diferencia ? Link to comment
Recommended Posts