Xperia Posted July 4, 2013 Posted July 4, 2013 ¿Que funciones necesitaria para poder hacer que un Patriot tenga un arma y cuando se suba un player al pulsar por ejemplo "CTRL" dispare?
Chaz-CR Posted July 4, 2013 Posted July 4, 2013 puedes usar createProjectile bindKey getPedOccupiedVehicle creas la function y la bindeas con CNTRL EDIT: olvide el getPedOccupiedVehicle
Xperia Posted July 4, 2013 Author Posted July 4, 2013 puedes usar createProjectile bindKey getPedOccupiedVehicle creas la function y la bindeas con CNTRL EDIT: olvide el getPedOccupiedVehicle Pero createProjectile no crea balas M4 o Minigun.
Chaz-CR Posted July 4, 2013 Posted July 4, 2013 Ah no especificaste! Que quieres exactamente que el jugador se suba atras de la patriot y dispare con la M4 o que el jugador entre al auto y dispare desde adentro?
Xperia Posted July 4, 2013 Author Posted July 4, 2013 (edited) Cuando el player este ya dentro del Patriot pueda disparar como si fuese la torreta un arma como la Minigun. EDIT: Algo como . Edited July 4, 2013 by Guest
BorderLine Posted July 4, 2013 Posted July 4, 2013 No hasta donde puede funcionar, pero va mas o menos asi function checkVehicles() local v = getPedOccupiedVehicle(source) if getElementModel(v) == 470 then w = createWeapon ( "m4", 0, 0, 0 ) attachElements ( w,v) if getKeyState ( "lctrl" ) then setWeaponState ( w, "firing") end end end addEventHandler("onClientPlayerVehicleEnter",getRootElement(),checkVehicles)
Xperia Posted July 4, 2013 Author Posted July 4, 2013 No hasta donde puede funcionar, pero va mas o menos asi function checkVehicles() local v = getPedOccupiedVehicle(source) if getElementModel(v) == 470 then w = createWeapon ( "m4", 0, 0, 0 ) attachElements ( w,v) if getKeyState ( "lctrl" ) then setWeaponState ( w, "firing") end end end addEventHandler("onClientPlayerVehicleEnter",getRootElement(),checkVehicles) Lo que pasa es que no para de disparar lol.
Alexs Posted July 4, 2013 Posted July 4, 2013 usa bindKey y en el argumento de 'state' utiliza 'both' para ir alternando al presionar y soltar la tecla.
Xperia Posted July 5, 2013 Author Posted July 5, 2013 function checkVehicles() local v = getPedOccupiedVehicle(source) if ( getElementModel( v ) == 470 ) then w = createWeapon ( "minigun", 0, 0, 0 ) setWeaponAmmo( w, 99999999 ) attachElements ( w, v, 0, 0, 1.38, 0, 30, 90) if getKeyState ( "lctrl" ) == true then setWeaponState ( w, "firing") end end end addEventHandler( "onClientPlayerVehicleEnter", getRootElement( ), checkVehicles ) bindKey("lctrl","both",checkVehicles) Asi no funciona, y sin el bindKey, solo funciona cuando matengo pulsado lctrl al entrar.
Sasu Posted July 5, 2013 Posted July 5, 2013 addEventHandler("onClientVehicleEnter", root, function() if getElementModel( source ) == 470 ) then w = createWeapon ( "minigun", 0, 0, 0 ) setWeaponAmmo( w, 99999999 ) attachElements ( w, v, 0, 0, 1.38, 0, 30, 90) end end ) function checkVehicles() local v = getPedOccupiedVehicle(source) if ( v and getElementModel( v ) == 470 ) then setWeaponState ( w, "firing") end end bindKey("lctrl","both",checkVehicles)
Xperia Posted July 5, 2013 Author Posted July 5, 2013 Da error en attachElements addEventHandler("onClientVehicleEnter", root, function() if ( getElementModel( source ) == 470 ) then w = createWeapon ( "minigun", 0, 0, 0 ) end end ) function checkVehicles() local v = getPedOccupiedVehicle(source) if ( v and getElementModel( v ) == 470 ) then setWeaponState ( w, "firing") end end bindKey("lctrl","both",checkVehicles) addEventHandler("onClientVehicleEnter",root, function() attachElements ( w, v, 0, 0, 1.38, 0, 30, 90) end ) Si lo pongo como me diste, tambien me da error.
BorderLine Posted July 5, 2013 Posted July 5, 2013 Prueba con eso addEventHandler("onClientVehicleEnter", root, function(p) if getElementModel( source ) == 470 ) then w = createWeapon ( "minigun", 0, 0, 0 ) setWeaponAmmo( w, 99999999 ) attachElements ( w, source, 0, 0, 1.38, 0, 30, 90) end end ) function checkVehicles() local v = getPedOccupiedVehicle(getLocalPlayer()) if v and getElementModel( v ) == 470 then setWeaponState ( w, "firing") end end bindKey("lctrl","both",checkVehicles)
Xperia Posted July 5, 2013 Author Posted July 5, 2013 Prueba con eso addEventHandler("onClientVehicleEnter", root, function(p) if getElementModel( source ) == 470 ) then w = createWeapon ( "minigun", 0, 0, 0 ) setWeaponAmmo( w, 99999999 ) attachElements ( w, source, 0, 0, 1.38, 0, 30, 90) end end ) function checkVehicles() local v = getPedOccupiedVehicle(getLocalPlayer()) if v and getElementModel( v ) == 470 then setWeaponState ( w, "firing") end end bindKey("lctrl","both",checkVehicles) Le edite un par de cosas y me sirvio, gracias a todos por la ayuda.
Xperia Posted July 5, 2013 Author Posted July 5, 2013 ¿Y que para se moviera y un player pudiera controlarla?
Sasu Posted July 5, 2013 Posted July 5, 2013 Si te refieres a la rotacion, puedes usar esto ( No se si funcionara ): addEventHandler("onClientRender", root, function() if isPedInVehicle(localPlayer) and isElement(w) then local rotcam = math.rad (360 - getPedCameraRotation (localPlayer)) local xpos,ypos,zpos = getPedBonePosition (localPlayer,8) local xlook,ylook,zlook = xpos - 300*math.sin(rotcam), ypos + 300*math.cos(rotcam), zpos setElementRotation( w, xlook,ylook,zlook ) end end )
Xperia Posted July 5, 2013 Author Posted July 5, 2013 Unir al player al lugar de la torreta, y entrar como si fuera un sitio del "no-conductor", que cuando estes cerca, y pulses G, entres o te posiciones en la torreta y para salir igual.
Plate Posted July 6, 2013 Posted July 6, 2013 bindKey -- supongo attachElements Nose si con esas 2 basta
BorderLine Posted July 6, 2013 Posted July 6, 2013 Ya entiendo para donde va tu idea Xperia. La Patriot de XGN tiene un espacio donde cabe un player, y hay una minigun. Tu idea es que al entrar hay se active el script para disparar? cierto? Creo que como dices biene bien un marker usando attachElements y que quede justo en ese espacio del vehiculo Y que al entrar se active el Bind para disparar.
Xperia Posted July 6, 2013 Author Posted July 6, 2013 Ya entiendo para donde va tu idea Xperia.La Patriot de XGN tiene un espacio donde cabe un player, y hay una minigun. Tu idea es que al entrar hay se active el script para disparar? cierto? Creo que como dices biene bien un marker usando attachElements y que quede justo en ese espacio del vehiculo Y que al entrar se active el Bind para disparar. Exacto, lo intentare con la informacion que me habeis dado y si algo falla, publico.
Recommended Posts