Jump to content

SAM rocket help


Recommended Posts

Here U go SAM FISHER

Server

deathSphere = createColSphere ( 354, 2027, 25, 200 ) 
warningSphere = createColSphere ( 354, 2027, 25, 500 )  
   
function enableSam ( thePlayer ) 
        setElementPosition ( deathSphere, 354, 2027, 25 ) 
        setElementPosition ( warningSphere, 354, 2027, 25 ) 
        outputChatBox ( "You have enabled the SAM sites at AREA 69", thePlayer, 255, 0, 0 ) 
end 
   
   
   
function disableSam ( thePlayer ) 
        setElementPosition ( deathSphere, 0, 0, -9999 ) 
        setElementPosition ( warningSphere, 0, 0, -9999 ) 
        outputChatBox ( "You have disabled the SAM sites at AREA 69", thePlayer, 255, 0, 0 ) 
     
end 
   
   
   
function samSite ( thePlayer, matchingDimension ) 
        veh = getPlayerOccupiedVehicle ( thePlayer )     
        id = getVehicleID ( veh ) 
               if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 464 or id == 501 or id == 465 ) then 
               triggerClientEvent ( thePlayer, "onSamTrigger", getRootElement() ) 
               outputChatBox ( "Surface to air missiles have been fired!", thePlayer, 255, 0, 0 ) 
        end 
       
   
end 
   
function samWarn ( thePlayer, matchingDimension ) 
      veh = getPlayerOccupiedVehicle ( thePlayer )     
      id = getVehicleID ( veh ) 
      if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 464 or id == 501 or id == 465 ) then   
      outputChatBox ( "Warning! AREA 69 has SAM sites activated! Turn back!", thePlayer, 255, 0, 0 ) 
      end 
end 
  
function jetpackTrigger ( thePlayer, matchingDimension ) 
        if ( doesPlayerHaveJetPack ( thePlayer ) ) then 
        outputChatBox ( "Warning! AREA 69 will kill you with telepathy if you go in with a jetpack!", thePlayer, 255, 0, 0 ) 
        end 
     
end 
  
  
function jetpackWarn ( thePlayer, matchingDimension ) 
      if ( doesPlayerHaveJetPack ( thePlayer ) ) then 
      triggerClientEvent ( thePlayer, "onSamTrigger", getRootElement() ) 
      outputChatBox ( "I wasn't lying about the telepathy death. Enjoy the fireworks!", thePlayer, 255, 0, 0 ) 
      killPlayer ( thePlayer ) 
    
    
      end 
   
end 
   
         
   
addCommandHandler ( "asamon", enableSam ) 
addCommandHandler ( "asamoff", disableSam ) 
addEventHandler ( "onColShapeHit", deathSphere, samSite ) 
addEventHandler ( "onColShapeHit", warningSphere, samWarn ) 
addEventHandler ( "onColShapeHit", deathSphere, jetpackWarn ) 
addEventHandler ( "onColShapeHit", warningSphere, jetpackTrigger ) 

and client

function samTrigger ( thePlayer )   
        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) 
        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) 
        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) 
        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) 
        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) 
        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) 
        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) 
        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) 
        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) 
        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) 
        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) 
        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() ) 
end 
addEvent ( "onSamTrigger", true ) 
addEventHandler ( "onSamTrigger", getRootElement(), samTrigger ) 

this is just one corner sam site but should give u idea of where to put co ordinates and stuff

hope this helps :D

EDIT : U will probably want to change the createColSphere settings a bit if u put more than one sam site in because as it is the warning message comes up even when your by the abandoned desert airport

Link to comment

Here U go SAM FISHER

Server

deathSphere = createColSphere ( 354, 2027, 25, 200 )warningSphere = createColSphere ( 354, 2027, 25, 500 )   function enableSam ( thePlayer )        setElementPosition ( deathSphere, 354, 2027, 25 )        setElementPosition ( warningSphere, 354, 2027, 25 )        outputChatBox ( "You have enabled the SAM sites at AREA 69", thePlayer, 255, 0, 0 )end      function disableSam ( thePlayer )        setElementPosition ( deathSphere, 0, 0, -9999 )        setElementPosition ( warningSphere, 0, 0, -9999 )        outputChatBox ( "You have disabled the SAM sites at AREA 69", thePlayer, 255, 0, 0 )    end      function samSite ( thePlayer, matchingDimension )        veh = getPlayerOccupiedVehicle ( thePlayer )            id = getVehicleID ( veh )               if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 464 or id == 501 or id == 465 ) then               triggerClientEvent ( thePlayer, "onSamTrigger", getRootElement() )               outputChatBox ( "Surface to air missiles have been fired!", thePlayer, 255, 0, 0 )        end        end  function samWarn ( thePlayer, matchingDimension )      veh = getPlayerOccupiedVehicle ( thePlayer )          id = getVehicleID ( veh )      if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 464 or id == 501 or id == 465 ) then        outputChatBox ( "Warning! AREA 69 has SAM sites activated! Turn back!", thePlayer, 255, 0, 0 )      endend function jetpackTrigger ( thePlayer, matchingDimension )        if ( doesPlayerHaveJetPack ( thePlayer ) ) then        outputChatBox ( "Warning! AREA 69 will kill you with telepathy if you go in with a jetpack!", thePlayer, 255, 0, 0 )        end    end  function jetpackWarn ( thePlayer, matchingDimension )      if ( doesPlayerHaveJetPack ( thePlayer ) ) then      triggerClientEvent ( thePlayer, "onSamTrigger", getRootElement() )      outputChatBox ( "I wasn't lying about the telepathy death. Enjoy the fireworks!", thePlayer, 255, 0, 0 )      killPlayer ( thePlayer )            end  end            addCommandHandler ( "asamon", enableSam )addCommandHandler ( "asamoff", disableSam )addEventHandler ( "onColShapeHit", deathSphere, samSite )addEventHandler ( "onColShapeHit", warningSphere, samWarn )addEventHandler ( "onColShapeHit", deathSphere, jetpackWarn )addEventHandler ( "onColShapeHit", warningSphere, jetpackTrigger )

and client

function samTrigger ( thePlayer )          createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() )        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() )        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() )        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() )        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() )        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() )        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() )        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() )        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() )        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() )        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() )        createProjectile ( getLocalPlayer(), 20, X, Y, Z, 50, getLocalPlayer() )endaddEvent ( "onSamTrigger", true )addEventHandler ( "onSamTrigger", getRootElement(), samTrigger )

this is just one corner sam site but should give u idea of where to put co ordinates and stuff

hope this helps :D

EDIT : U will probably want to change the createColSphere settings a bit if u put more than one sam site in because as it is the warning message comes up even when your by the abandoned desert airport

Link to comment

i tried changing the projectile velocity a bit but it didnt seem to help

i am messing with a few other things at the moment but i will see what i can figure out tomorrow and post any results :D

EDIT : just had a thought

perhaps make collision sphere for fire missle bigger giving more time to evade?

maybe but not sure :|

Link to comment

i tried changing the projectile velocity a bit but it didnt seem to help

i am messing with a few other things at the moment but i will see what i can figure out tomorrow and post any results :D

EDIT : just had a thought

perhaps make collision sphere for fire missle bigger giving more time to evade?

maybe but not sure :|

Link to comment

tried it and died immediately in the middle of Venturas after the text "Surface to air rockets..." :D

I saw a video of the Carrier script what I can't get working yet... but in the video the player is running from the rockets. It must be done here too somehow.

Link to comment

tried it and died immediately in the middle of Venturas after the text "Surface to air rockets..." :D

I saw a video of the Carrier script what I can't get working yet... but in the video the player is running from the rockets. It must be done here too somehow.

Link to comment

i have also tried out the carrier script by ACE_GAMBIT its pretty cool

i havent looked at the scripts for it much yet but i was hoping to do the same thing myself ( slow missles )

the barrage function is pretty awesome ( carriers use cannons against ground targets instead of missles )

if u extract the whole thing then put DEMO and the original Carrier into resources then just run demo u can see how it works

ACE_GAMBIT advised me that if U add velocity to the Z of the rocket it should give U a chance of avoiding it

i think its like this

createProjectile ( getLocalPlayer(), 19, 354, 2027, 27, 50, getLocalPlayer(), 0, 0, 0, 0, 0, 0 )

i think U need to change the last zero in the line above to make the rocket fly up/down as well as at the player so it travels in an arc giving U a chance to get away but im still trying to figure out the details. will let U know when i get it right :D

Link to comment

i have also tried out the carrier script by ACE_GAMBIT its pretty cool

i havent looked at the scripts for it much yet but i was hoping to do the same thing myself ( slow missles )

the barrage function is pretty awesome ( carriers use cannons against ground targets instead of missles )

if u extract the whole thing then put DEMO and the original Carrier into resources then just run demo u can see how it works

ACE_GAMBIT advised me that if U add velocity to the Z of the rocket it should give U a chance of avoiding it

i think its like this

createProjectile ( getLocalPlayer(), 19, 354, 2027, 27, 50, getLocalPlayer(), 0, 0, 0, 0, 0, 0 )

i think U need to change the last zero in the line above to make the rocket fly up/down as well as at the player so it travels in an arc giving U a chance to get away but im still trying to figure out the details. will let U know when i get it right :D

Link to comment
If you want to shoot at a player while he is in the death sphere simply toggle the sphere on and off (moving it from -9999 to XYZ back and forth) every x seconds. Since your script detects hit events the sam will fire every time the player is still in the death sphere area.

i did that, i dont really know if it works, becasue it crashes my server. heres essentially how i put it.

resourceRoot = getResourceRootElement(getThisResource()) 
  
function enableSam ( ) 
     setElementPosition ( deathSphere, the coordinates ) 
     setElementPosition ( deathSphere, 0, 0, -9999 ) 
     setTimer ( enableSam, 1000, 0 ) 
  
end 
  
addCommandHandler ( "samon", enableSam ) 
addEventHandler ( "onResourceStart", resourceRoot, enableSam ) 

is there an alternative way for it to activley fire at intruders?

Link to comment
If you want to shoot at a player while he is in the death sphere simply toggle the sphere on and off (moving it from -9999 to XYZ back and forth) every x seconds. Since your script detects hit events the sam will fire every time the player is still in the death sphere area.

i did that, i dont really know if it works, becasue it crashes my server. heres essentially how i put it.

resourceRoot = getResourceRootElement(getThisResource()) function enableSam ( )     setElementPosition ( deathSphere, the coordinates )     setElementPosition ( deathSphere, 0, 0, -9999 )     setTimer ( enableSam, 1000, 0 ) end addCommandHandler ( "samon", enableSam )addEventHandler ( "onResourceStart", resourceRoot, enableSam )

is there an alternative way for it to activley fire at intruders?

Link to comment

i did that, i dont really know if it works, becasue it crashes my server. heres essentially how i put it.

resourceRoot = getResourceRootElement(getThisResource()) 
  
function enableSam ( ) 
     setElementPosition ( deathSphere, the coordinates ) 
     setElementPosition ( deathSphere, 0, 0, -9999 ) 
     setTimer ( enableSam, 1000, 0 ) 
  
end 
  
addCommandHandler ( "samon", enableSam ) 
addEventHandler ( "onResourceStart", resourceRoot, enableSam ) 

is there an alternative way for it to activley fire at intruders?

I don't really understand the part where you say:

  
   setElementPosition ( deathSphere, the coordinates ) 
  

Is that a typo? Anyway, this is how I would have done it in your case (using the spheres):

  
resourceRoot = getResourceRootElement(getThisResource()) 
  
sphereX, sphereY, sphereZ = 1202, 909, 4 -- just some random values 
offWorldX, offWorldY, offWorldZ = 7000, 7000, 0 -- again, just some random values 
   
 function enableSam ( ) 
     currentX, currentY, currentZ = getElementPosition(deathSphere) 
      if (currentX == sphereX and currentY == sphereY and currentZ == sphereZ) then 
          setElementPosition ( deathSphere, offWorldX, offWorldY, offWorldZ ) 
      else 
          setElementPosition ( deathSphere, sphereX, sphereY, sphereZ ) 
      end 
      setTimer ( enableSam, 1000, 1 ) 
end 
  
 addCommandHandler ( "samon", enableSam ) 
addEventHandler ( "onResourceStart", resourceRoot, enableSam ) 
  

This is just an alternative method. In my latest implementation of SAM sites I am no longer using collision shapes. Instead the SAM site is calculating the angle between the line of sight vector and the target vector. If this is within a certain angle (thus within the field of sight) the SAM is fired.

Link to comment

i did that, i dont really know if it works, becasue it crashes my server. heres essentially how i put it.

resourceRoot = getResourceRootElement(getThisResource()) function enableSam ( )     setElementPosition ( deathSphere, the coordinates )     setElementPosition ( deathSphere, 0, 0, -9999 )     setTimer ( enableSam, 1000, 0 ) end addCommandHandler ( "samon", enableSam )addEventHandler ( "onResourceStart", resourceRoot, enableSam )

is there an alternative way for it to activley fire at intruders?

I don't really understand the part where you say:

    setElementPosition ( deathSphere, the coordinates ) 

Is that a typo? Anyway, this is how I would have done it in your case (using the spheres):

 resourceRoot = getResourceRootElement(getThisResource()) sphereX, sphereY, sphereZ = 1202, 909, 4 -- just some random valuesoffWorldX, offWorldY, offWorldZ = 7000, 7000, 0 -- again, just some random values   function enableSam ( )     currentX, currentY, currentZ = getElementPosition(deathSphere)      if (currentX == sphereX and currentY == sphereY and currentZ == sphereZ) then          setElementPosition ( deathSphere, offWorldX, offWorldY, offWorldZ )      else          setElementPosition ( deathSphere, sphereX, sphereY, sphereZ )      end      setTimer ( enableSam, 1000, 1 )end  addCommandHandler ( "samon", enableSam )addEventHandler ( "onResourceStart", resourceRoot, enableSam ) 

This is just an alternative method. In my latest implementation of SAM sites I am no longer using collision shapes. Instead the SAM site is calculating the angle between the line of sight vector and the target vector. If this is within a certain angle (thus within the field of sight) the SAM is fired.

Link to comment

That's great. It functions well now. But the projectile still useless. If I use simple rocket (19) it can be fired different directions by changing the 0's. But these rockets can't do anything with the intruders. If I change the projectile to heatseeker (20) than it will be fired and immediately disapperars if I'm right. Maybe we are close now but still need help. I would be glad to see a clientside script by Ace_Gambit to help us out.

Link to comment

That's great. It functions well now. But the projectile still useless. If I use simple rocket (19) it can be fired different directions by changing the 0's. But these rockets can't do anything with the intruders. If I change the projectile to heatseeker (20) than it will be fired and immediately disapperars if I'm right. Maybe we are close now but still need help. I would be glad to see a clientside script by Ace_Gambit to help us out.

Link to comment

seem to be getting there

this is quite fun

server-side

deathSphere = createColSphere ( 0, 0, -250, 200 ) 
warningSphere = createColSphere ( 0, 0, -250, 500 ) 
element = getRootElement()  
   
function enableSam ( element ) 
        setElementPosition ( deathSphere, 354, 2027, 25 ) 
        setElementPosition ( warningSphere, 354, 2027, 25 ) 
        outputChatBox ( "You have enabled the SAM sites at AREA 69", thePlayer, 255, 0, 0 ) 
end 
   
   
   
function disableSam ( element ) 
        setElementPosition ( deathSphere, 0, 0, -9999 ) 
        setElementPosition ( warningSphere, 0, 0, -9999 ) 
        outputChatBox ( "You have disabled the SAM sites at AREA 69", thePlayer, 255, 0, 0 ) 
     
end 
   
   
   
function samSite ( element, matchingDimension ) 
   if ( getElementType ( element ) == "player" ) then 
    veh = getPlayerOccupiedVehicle ( element )     
    id = getVehicleID ( veh ) 
               if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 464 or id == 501 or id == 465 ) then 
                triggerClientEvent ( element, "onSamTrigger", getRootElement() ) 
                outputChatBox ( "Surface to air missiles have been fired!", element, 255, 0, 0 ) 
               end 
    end   
   
end 
   
function samWarn ( element, matchingDimension ) 
   if ( getElementType ( element ) == "player" ) then 
    veh = getPlayerOccupiedVehicle ( element )     
    id = getVehicleID ( veh ) 
         if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 464 or id == 501 or id == 465 ) then   
         outputChatBox ( "Warning! AREA 69 has SAM sites activated! Turn back!", element, 255, 0, 0 ) 
         end   
   end 
end 
  
function jetpackTrigger ( element, matchingDimension ) 
   if ( getElementType ( element ) == "player" ) then 
        if ( doesPlayerHaveJetPack ( element ) ) then 
        outputChatBox ( "Warning! AREA 69 will kill you with telepathy if you go in with a jetpack!", element, 255, 0, 0 ) 
        end 
   end  
end 
  
  
function jetpackWarn ( element, matchingDimension ) 
   if ( getElementType ( element ) == "player" ) then 
      if ( doesPlayerHaveJetPack ( element ) ) then 
         triggerClientEvent ( element, "onSamTrigger", getRootElement() ) 
          outputChatBox ( "I wasn't lying about the telepathy death. Enjoy the fireworks!", thePlayer, 255, 0, 0 ) 
          killPlayer ( element ) 
    
    
      end 
   end 
end 
   
         
   
addCommandHandler ( "asamon", enableSam ) 
addCommandHandler ( "asamoff", disableSam ) 
addEventHandler ( "onColShapeHit", deathSphere, samSite ) 
addEventHandler ( "onColShapeHit", warningSphere, samWarn ) 
addEventHandler ( "onColShapeHit", deathSphere, jetpackWarn ) 
addEventHandler ( "onColShapeHit", warningSphere, jetpackTrigger ) 

client-side

element = getRootElement 
function samTrigger ( element )   
         local missle1 = createObject ( 3786, 354, 2028, 26 ) 
         local missle2 = createObject ( 3786, 354, 2026, 26 ) 
         local x,y,z = getElementPosition ( getLocalPlayer () ) 
         setTimer ( moveObject, 200, 1, missle1, 1800, x, y, z ) 
end 
addEvent ( "onSamTrigger", true ) 
addEventHandler ( "onSamTrigger", getRootElement(), samTrigger ) 

looks quite rough at the moment but i will try to make it look better

it creates a couple of missles on top of sam site ( will set them up so their inside the sam )

launches them at the coordinates of the player when they enter the collision sphere giving u time to avoid

u will need to alter the moveobject time depending how hard u want to make it to avoid and next i will add a create explosion on a timer so i can make anti aircraft barrage sort of thing

im still trying to get the hang of createprojectile but i like this because i have control over missle speed and u can see the missle coming at you which i thought is pretty cool

only thing im struggling to figure is how to set rotation of the missle so its pointed at the target

added the explosion now

client-side

element = getRootElement

function samTrigger ( element )

local missle1 = createObject ( 3786, 354, 2028, 26 )

local missle2 = createObject ( 3786, 354, 2026, 26 )

local x,y,z = getElementPosition ( getLocalPlayer () )

setTimer ( moveObject, 100, 1, missle1, 400, x, y, z )

setTimer ( createExplosion, 500, 1, x, y, z, 2 )

end

addEvent ( "onSamTrigger", true )

addEventHandler ( "onSamTrigger", getRootElement(), samTrigger )

have noticed that u end up with missles left all over the place but i cant get destroyElement to work

tried putting it on a timer and then i tried using a check in the function to see where the missle is and destroy it if its at the target coordinates but that didnt work either

element = getRootElement 
function samTrigger ( element )   
         local missle1 = createObject ( 3786, 354, 2028, 26 ) 
         local missle2 = createObject ( 3786, 354, 2026, 26 ) 
         local x,y,z = getElementPosition ( getLocalPlayer () ) 
         setTimer ( moveObject, 100, 1, missle1, 400, x, y, z ) 
         setTimer ( createExplosion, 500, 1, x, y, z, 2 ) 
            if getElementPosition ( missle1 ) == x, y, z then 
            destroyElement ( missle1 ) 
            end 
end 
addEvent ( "onSamTrigger", true ) 
addEventHandler ( "onSamTrigger", getRootElement(), samTrigger ) 

like this it just stops the whole function ( wont make missles or anything ) and does the same with this

element = getRootElement 
function samTrigger ( element )   
         local missle1 = createObject ( 3786, 354, 2028, 26 ) 
         local missle2 = createObject ( 3786, 354, 2026, 26 ) 
         local x,y,z = getElementPosition ( getLocalPlayer () ) 
         setTimer ( moveObject, 100, 1, missle1, 400, x, y, z ) 
         setTimer ( createExplosion, 500, 1, x, y, z, 2 ) 
         settImer ( destroyElement, 1100, 1, missle1 ) 
end 
addEvent ( "onSamTrigger", true ) 
addEventHandler ( "onSamTrigger", getRootElement(), samTrigger ) 

i think i need to define the MISSLE1 as the element to destroy but im not sure how else to word it

anybody got any ideas THANX IN ADVANCE :D

EDIT : sorry about hijacking your thread VERCETTI 1010 but i thought as this is all related it would be better than starting new topic :lol:

Link to comment

seem to be getting there

this is quite fun

server-side

deathSphere = createColSphere ( 0, 0, -250, 200 )warningSphere = createColSphere ( 0, 0, -250, 500 )element = getRootElement()   function enableSam ( element )        setElementPosition ( deathSphere, 354, 2027, 25 )        setElementPosition ( warningSphere, 354, 2027, 25 )        outputChatBox ( "You have enabled the SAM sites at AREA 69", thePlayer, 255, 0, 0 )end      function disableSam ( element )        setElementPosition ( deathSphere, 0, 0, -9999 )        setElementPosition ( warningSphere, 0, 0, -9999 )        outputChatBox ( "You have disabled the SAM sites at AREA 69", thePlayer, 255, 0, 0 )    end      function samSite ( element, matchingDimension )   if ( getElementType ( element ) == "player" ) then    veh = getPlayerOccupiedVehicle ( element )        id = getVehicleID ( veh )               if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 464 or id == 501 or id == 465 ) then                triggerClientEvent ( element, "onSamTrigger", getRootElement() )                outputChatBox ( "Surface to air missiles have been fired!", element, 255, 0, 0 )               end    end    end  function samWarn ( element, matchingDimension )   if ( getElementType ( element ) == "player" ) then    veh = getPlayerOccupiedVehicle ( element )        id = getVehicleID ( veh )         if ( id == 592 or id == 577 or id == 511 or id == 548 or id == 512 or id == 593 or id == 417 or id == 487 or id == 553 or id == 488 or id == 497 or id == 563 or id == 476 or id == 447 or id == 519 or id == 460 or id == 469 or id == 513 or id == 464 or id == 501 or id == 465 ) then           outputChatBox ( "Warning! AREA 69 has SAM sites activated! Turn back!", element, 255, 0, 0 )         end     endend function jetpackTrigger ( element, matchingDimension )   if ( getElementType ( element ) == "player" ) then        if ( doesPlayerHaveJetPack ( element ) ) then        outputChatBox ( "Warning! AREA 69 will kill you with telepathy if you go in with a jetpack!", element, 255, 0, 0 )        end   end end  function jetpackWarn ( element, matchingDimension )   if ( getElementType ( element ) == "player" ) then      if ( doesPlayerHaveJetPack ( element ) ) then         triggerClientEvent ( element, "onSamTrigger", getRootElement() )          outputChatBox ( "I wasn't lying about the telepathy death. Enjoy the fireworks!", thePlayer, 255, 0, 0 )          killPlayer ( element )            end   endend            addCommandHandler ( "asamon", enableSam )addCommandHandler ( "asamoff", disableSam )addEventHandler ( "onColShapeHit", deathSphere, samSite )addEventHandler ( "onColShapeHit", warningSphere, samWarn )addEventHandler ( "onColShapeHit", deathSphere, jetpackWarn )addEventHandler ( "onColShapeHit", warningSphere, jetpackTrigger )

client-side

element = getRootElementfunction samTrigger ( element )           local missle1 = createObject ( 3786, 354, 2028, 26 )         local missle2 = createObject ( 3786, 354, 2026, 26 )         local x,y,z = getElementPosition ( getLocalPlayer () )         setTimer ( moveObject, 200, 1, missle1, 1800, x, y, z )endaddEvent ( "onSamTrigger", true )addEventHandler ( "onSamTrigger", getRootElement(), samTrigger )

looks quite rough at the moment but i will try to make it look better

it creates a couple of missles on top of sam site ( will set them up so their inside the sam )

launches them at the coordinates of the player when they enter the collision sphere giving u time to avoid

u will need to alter the moveobject time depending how hard u want to make it to avoid and next i will add a create explosion on a timer so i can make anti aircraft barrage sort of thing

im still trying to get the hang of createprojectile but i like this because i have control over missle speed and u can see the missle coming at you which i thought is pretty cool

only thing im struggling to figure is how to set rotation of the missle so its pointed at the target

added the explosion now

client-side

element = getRootElement

function samTrigger ( element )

local missle1 = createObject ( 3786, 354, 2028, 26 )

local missle2 = createObject ( 3786, 354, 2026, 26 )

local x,y,z = getElementPosition ( getLocalPlayer () )

setTimer ( moveObject, 100, 1, missle1, 400, x, y, z )

setTimer ( createExplosion, 500, 1, x, y, z, 2 )

end

addEvent ( "onSamTrigger", true )

addEventHandler ( "onSamTrigger", getRootElement(), samTrigger )

have noticed that u end up with missles left all over the place but i cant get destroyElement to work

tried putting it on a timer and then i tried using a check in the function to see where the missle is and destroy it if its at the target coordinates but that didnt work either

element = getRootElementfunction samTrigger ( element )           local missle1 = createObject ( 3786, 354, 2028, 26 )         local missle2 = createObject ( 3786, 354, 2026, 26 )         local x,y,z = getElementPosition ( getLocalPlayer () )         setTimer ( moveObject, 100, 1, missle1, 400, x, y, z )         setTimer ( createExplosion, 500, 1, x, y, z, 2 )            if getElementPosition ( missle1 ) == x, y, z then            destroyElement ( missle1 )            endendaddEvent ( "onSamTrigger", true )addEventHandler ( "onSamTrigger", getRootElement(), samTrigger )

like this it just stops the whole function ( wont make missles or anything ) and does the same with this

element = getRootElementfunction samTrigger ( element )           local missle1 = createObject ( 3786, 354, 2028, 26 )         local missle2 = createObject ( 3786, 354, 2026, 26 )         local x,y,z = getElementPosition ( getLocalPlayer () )         setTimer ( moveObject, 100, 1, missle1, 400, x, y, z )         setTimer ( createExplosion, 500, 1, x, y, z, 2 )         settImer ( destroyElement, 1100, 1, missle1 )endaddEvent ( "onSamTrigger", true )addEventHandler ( "onSamTrigger", getRootElement(), samTrigger )

i think i need to define the MISSLE1 as the element to destroy but im not sure how else to word it

anybody got any ideas THANX IN ADVANCE :D

EDIT : sorry about hijacking your thread VERCETTI 1010 but i thought as this is all related it would be better than starting new topic :lol:

Link to comment
Can it be possible to script the SAM to ignore one of the playing teams, and fire only the other teams? And is it possible to make a script that starts/stops some resources for example when you reach a marker?

If you would like to ignore players that are in a team, you'd need to do a simple check if player is in the team that should not be fired missiles at. It's possible to start/stop resources from different resources. You may have to modify acl.xml to allow resource to call functions such as startResource, stopResource or restartResource.

Link to comment
Can it be possible to script the SAM to ignore one of the playing teams, and fire only the other teams? And is it possible to make a script that starts/stops some resources for example when you reach a marker?

If you would like to ignore players that are in a team, you'd need to do a simple check if player is in the team that should not be fired missiles at. It's possible to start/stop resources from different resources. You may have to modify acl.xml to allow resource to call functions such as startResource, stopResource or restartResource.

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