Jump to content

createProjectile // Error


papam77

Recommended Posts

Posted
function mapa () 
rocket = createMarker ( 3412.8688964844, -1652.7664794922, 13.254596710205 ) 
setMarkerSize ( rocket, 5 ) 
  
  
  
  
function MarkerHit (element) 
if (element == getLocalPlayer()) then 
   if (getElementType(element) == "player") then 
    if (isPedInVehicle(element)) then 
     
    if (source==rocket) then 
    outputChatBox ("#ff9900WARNING!", 255,255,255, true ) 
    createProjectile ( RocketLauncher1, "58", 3440.1625976563, -1543.6124267578, 32.850193023682, 1.0, nil, 3514.0498046875, -1665.0322265625, 18.988582611084, 0, 0, 0 )  
        end         
    end 
    end 
end 
end 
addEventHandler ( "onClientMarkerHit", getRootElement() ,MarkerHit) 
  
  
  
  
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), mapa ) 
  

Hello guys why this projectiles doesn't work? When i hit marker nothing happend :C

  • Moderators
Posted

This is the bug I could see by creating the projectile, pls learn to debug your code and write down the warning.

/debugscript 3

createProjectile ( RocketLauncher1, "58", 3440.1625976563, -1543.6124267578, 32.850193023682, 1.0, nil, 3514.0498046875, -1665.0322265625, 18.988582611084, 0, 0, 0 )
    createProjectile ( RocketLauncher1, 58, 3440.1625976563, -1543.6124267578, 32.850193023682, 1.0, nil, 3514.0498046875, -1665.0322265625, 18.988582611084, 0, 0, 0 ) 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted

The creator doesn't exist, it is required that the creator does exist.

createProjectile (nil, 58, 3440.1625976563, -1543.6124267578, 32.850193023682, 1.0, nil, 3514.0498046875, -1665.0322265625, 18.988582611084, 0, 0, 0 )

    createProjectile ( localPlayer, 58, 3440.1625976563, -1543.6124267578, 32.850193023682, 1.0, nil, 3514.0498046875, -1665.0322265625, 18.988582611084, 0, 0, 0 ) 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

Doesn't work when i hit with vehicle marker called rocket. Nothing shooted from 3440.1625976563, -1543.6124267578, 32.850193023682 to 3514.0498046875, -1665.0322265625, 18.988582611084

  • Moderators
Posted

Why don't you read things before you use them?

Optional Arguments


  • NOTE: When using optional arguments, you must supply all arguments before the one you wish to use. For more information on optional arguments, see Optional Arguments.
    • posX,posY,posZ: float starting coordinates for the projectile. They are coordinates of creator by default.
      force: float representing the starting force of the projectile.
      target: element target used for heat seeking rockets.
      rotX,rotY,rotZ: float starting rotation for the projectile.
      velX,velY,velZ: float starting velocity for the projectile.
      model: Integer representing the projectile's model, uses default model for weaponType if not specified.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

'localPlayer' is defined by default by MTA.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I was reading it, but I've changed it now to this

function mapa () 
rocket = createMarker ( 3412.8688964844, -1652.7664794922, 13.254596710205 ) 
setMarkerSize ( rocket, 5 ) 
  
  
  
  
  
  
function MarkerHit (element) 
local vehilce = getVehicleName() 
if (element == getLocalPlayer()) then 
   if (getElementType(element) == "player") then 
    if (isPedInVehicle(element)) then 
     
    if (source==rocket) then 
    outputChatBox ("#ff9900WARNING!", 255,255,255, true ) 
    createProjectile ( localPlayer, 58, 3440.1625976563, -1543.6124267578, 32.850193023682, 1.0, nil, 3514.0498046875, -1665.0322265625, 18.988582611084, 1, 1, 1 ) 
        end         
    end 
    end 
end 
end 
addEventHandler ( "onClientMarkerHit", getRootElement() ,MarkerHit) 
  
  
  
  
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), mapa ) 
  

and still nothing happend.

Posted

You want to create a rocket missile to target the player that hit the marker? or a hydra flare?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Moderators
Posted

createProjectile ( localPlayer, 58, 3440.1625976563, -1543.6124267578, 32.850193023682, 1.0, nil, 3514.0498046875, -1665.0322265625, 18.988582611084, 1, 1, 1 )

Position here we start the rocket, but you already knew that.

Rotation this doesn't change anything about the direction of the thing, unless it is a rocket with ID 19 or 20.

Direction of speed the starting direction of the projectile, makes it possible to move it to the right direction.

Note:

Rotations are from 0 t/m 360 degrees.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

I wanna create rocket when player hit a defined marker called 'rocket' and shoot to stone which is defined on 3514.0498046875, -1665.0322265625, 18.988582611084 and from rocket launcher 3440.1625976563, -1543.6124267578, 32.850193023682 with hydra rockets

Posted
function mapa ( ) 
    rocket = createMarker ( 3412.8688964844, -1652.7664794922, 13.254596710205 ) 
    setMarkerSize ( rocket, 5 ) 
  
    function MarkerHit ( element ) 
        if ( element == localPlayer and getElementType ( element ) == "player" and isPedInVehicle ( element ) ) then 
            outputChatBox ( "#ff9900WARNING!", 255, 255, 255, true ) 
            createProjectile ( localPlayer, 19, 3440.1625976563, -1543.6124267578, 32.850193023682, 1.0, localPlayer ) 
        end 
    end 
    addEventHandler ( "onClientMarkerHit", rocket, MarkerHit ) 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, mapa ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

First: creator

Second: target

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

It works, ty :)

function mapa ( ) 
    rocket = createMarker ( 3412.8688964844, -1652.7664794922, 13.254596710205 ) 
    setMarkerSize ( rocket, 5 ) 
  
    function MarkerHit ( element ) 
        if ( element == localPlayer and getElementType ( element ) == "player" and isPedInVehicle ( element ) ) then 
            outputChatBox ( "#ff9900Rocket minigun overheated! Give it a rest pal!", 255, 255, 255, true ) 
            launcher = createProjectile ( localPlayer, 20, 3440.1625976563, -1543.6124267578, 36.850193023682, 100.0, localPlayer, 3514.0498046875, -1665.0322265625, 18.988582611084, 70, -320, -70, Cil ) 
            setProjectileCounter (launcher, 250 ) 
        end 
    end 
    addEventHandler ( "onClientMarkerHit", rocket, MarkerHit ) 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, mapa ) 

And where can set projectile Speed ?

Posted

You can set the projectile velocity arguments:

velX, velY, velZ: float starting velocity for the projectile.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Well, is not for that, there's also rotation arguments.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Moderators
Posted

createProjectile ( creator, weaponType , posX, posY, posZ, force = 1.0, target, rotX, rotY, rotZ, velX, velY, velZ, model )

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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