Jump to content

createProjectile (fail)


HunT

Recommended Posts

Posted (edited)

local sorry = sorry for my patetic eng.

findPlayer = namepart

-------------------------

hi guys :fadein: i have problem for stop function createProjectile :cry:

This script give granate to player with command.But give granate for ever and no one time (one map)

serverside :

function granate (thePlayer, commandName, ...) 
     player = findPlayer(...) 
      if not player then 
        outputChatBox("* /givegran: player not found", thePlayer) 
      elseif isPedInVehicle(player) then 
        local vehicle = getPedOccupiedVehicle(player) 
        local x, y, z = getElementPosition ( vehicle )  
        local rx, ry, rz = getVehicleRotation ( vehicle )  
         
            local shark = createObject ( 1608, x, y, z, rx, ry, rz ) 
            attachElements ( shark, vehicle, 0, -3.5, 0, 0, 0, 0)  
            setElementAlpha(vehicle, 0) 
            setElementAlpha(player, 0) 
         
            triggerClientEvent ("shark_key", getRootElement (), object) 
     end 
   end 
   addCommandHandler("givegran", granate) 

client side :

addEvent ("shark_key", true)  
  
   
 function fire_rocket () 
     local x, y, z = getElementPosition (getPedOccupiedVehicle (getLocalPlayer())) 
     createProjectile ( getLocalPlayer(), 16, x, y, z + 1, 1.0, 0, rx, ry, rz)  
      
          
 end 
   
 function bind_key_function () 
     bindKey ("mouse2", "down", fire_rocket)  
     local attachedElements = getAttachedElements ( getPedOccupiedVehicle (getLocalPlayer()) )  
    for ElementKey, ElementValue in ipairs ( attachedElements ) do 
         setElementCollisionsEnabled (ElementValue, false) 
     end 
         
 end 
   
 addEventHandler ("shark_key", getLocalPlayer(), bind_key_function)  
  

help please and "sorry" :|

Edited by Guest
Posted

please use

 tags! it helps a lot seeing isn't there a syntax error, etc.

rx,ry,rz is not defined,

and theres no object defined, use triggerClientEvent ("shark_key", getRootElement (),player)

Posted
please use
 tags! it helps a lot seeing isn't there a syntax error, etc.

rx,ry,rz is not defined,

and theres no object defined, use triggerClientEvent ("shark_key", getRootElement (),player)

The script work with and without rx,ry,rz.

getRootElement (),player)

or

getRootElement (),object)

Player have granate for ever :evil::evil:

Posted

getRootElement (),player) no work :roll:

and setTimer (destroyElement no work

The Player have always granate :twisted::twisted: why?

Posted
1)your now talking about code we don't see, show it

2)use

[ /code] or i refuse to help you.

Karlis i edit the code in lua :D

This script work.The problem is stop function on nextmap in race mode.

createObject stop

setElementAlpha stop

createProjectile no stop

why createProjectile is client?

Posted
omg, then POST the script

theres no timer in that code

timer :scratch::scratch::scratch: ??

I have more commands with minigun ramp etc.. and automatic remove the mg or ramp on nextmap.

  • Moderators
Posted

Hi,

Try this ( not tested ):

Server:

function granate (thePlayer, commandName, ...) 
    local player = findPlayer(...) 
    if not player then 
        outputChatBox("* /givegran: player not found", thePlayer) 
    elseif isPedInVehicle(player) then 
        local vehicle = getPedOccupiedVehicle(player) 
        local x, y, z = getElementPosition ( vehicle ) 
        local rx, ry, rz = getVehicleRotation ( vehicle ) 
  
        local shark = createObject ( 1608, x, y, z, rx, ry, rz ) 
        attachElements ( shark, vehicle, 0, -3.5, 0, 0, 0, 0) 
        setElementAlpha(vehicle, 0) 
        setElementAlpha(player, 0) 
      
        triggerClientEvent (player, "shark_key", getRootElement ()) 
    end 
end 
addCommandHandler("givegran", granate) 

Client:

addEvent ("shark_key", true) 
  
function fire_rocket () -- is it a rocket or a grenade ??? 
   local x, y, z = getElementPosition (getPedOccupiedVehicle (getLocalPlayer())) 
   local rx, ry, rz = getElementRotation(getPedOccupiedVehicle (getLocalPlayer())) 
   createProjectile ( getLocalPlayer(), 16, x, y, z + 1, 1.0, 0, rx, ry, rz) 
end 
  
function bind_key_function () 
    bindKey ("mouse2", "down", fire_rocket) 
    local attachedElements = getAttachedElements ( getPedOccupiedVehicle (getLocalPlayer()) ) 
    for ElementKey, ElementValue in ipairs ( attachedElements ) do 
        setElementCollisionsEnabled (ElementValue, false) 
    end 
end 
addEventHandler ("shark_key", getLocalPlayer(), bind_key_function) 

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