Jump to content

Errors (bad argument, attempt to perform)


FSXTim

Recommended Posts

Hello,

I have a small problem with my script. The firework starts and I can hear/see the first explosion, but the second explosion doesn't start.

Errors:

Line 13: Bad argument @ 'getElementPosition'

Line 14: attempt to perform arithmetic on local 'z' (a nil value)

function Feuerwerk () 
    fire1 ( player ) 
end 
addEvent ( "Feuerwerk", true ) 
addEventHandler ( "Feuerwerk", getRootElement(), Feuerwerk ) 
  
function fire1 ( player ) 
    local x,y,z = getElementPosition ( player ) 
    createExplosion ( x, y, z + 15, 0 )  
    setTimer(fire2, 500, 1, 0) 
end 
  
function fire2 ( player ) 
    local x,y,z = getElementPosition ( player ) 
    createExplosion ( x, y, z + 13, 0 )  
    setTimer(fire3, 500, 1, 0) 
end  

Can anybody help me?

Greets

Link to comment

Try this

function Feuerwerk ( thePlayer) 
    fire1 ( thePlayer ) 
end 
addEvent ( "Feuerwerk", true ) 
addEventHandler ( "Feuerwerk", getRootElement(), Feuerwerk ) 
  
function fire1 ( thePlayer ) 
    local position = getElementPosition ( thePlayer ) 
    createExplosion ( x, y, z + 15, 0 )  
    setTimer(fire2, 500, 1, 0) 
end 
  
function fire2 ( thePlayer ) 
    local position1 = getElementPosition ( thePlayer ) 
    createExplosion ( x, y, z + 13, 0 )  
    setTimer(fire3, 500, 1, 0) 
end  

Link to comment

That doesn't work, now the first explosion doesn't start, too!

Errors:

Line 8: Bad argument @ 'getElementPosition'

Line 9: attempt to perform arithmetic on local 'z' (a nil value)

Greets

Edited by Guest
Link to comment

Partly serverside and partly clientside.

clientside:

function bombe10_Button (state) 
    if state == "left" then 
        if source == GUIEditor_Button[12] then 
            local vehicle = getPedOccupiedVehicle (getLocalPlayer())  
            local x,y,z = getElementPosition (getLocalPlayer())      
            triggerServerEvent ( "Feuerwerk", root )                 
        end 
    end 
end  
addEventHandler("onClientGUIClick", getRootElement(), bombe10_Button) 

serverside:

function Feuerwerk ( thePlayer) 
    fire1 ( thePlayer ) 
end 
addEvent ( "Feuerwerk", true ) 
addEventHandler ( "Feuerwerk", getRootElement(), Feuerwerk ) 
  
function fire1 ( thePlayer ) 
    local position1 = getElementPosition ( thePlayer ) 
    createExplosion ( x, y, z + 15, 0 )  
    setTimer(fire2, 500, 1, 0) 
end 
  
function fire2 ( thePlayer ) 
    local position2 = getElementPosition ( thePlayer ) 
    createExplosion ( x, y, z + 13, 0 )  
    setTimer(fire3, 500, 1, 0) 
end  

Greets

Link to comment
--ClientSide 
function bombe10_Button (state) 
    if state == "left" then 
        if (source == GUIEditor_Button[12]) then 
            local vehicle = getPedOccupiedVehicle (localPlayer) 
            local x,y,z = getElementPosition (localPlayer)      
            triggerServerEvent ( "Feuerwerk", source )                 
        end 
    end 
end  
addEventHandler("onClientGUIClick", getRootElement(), bombe10_Button) 

--ServerSide 
  
function Feuerwerk () 
end 
addEvent ( 'Feuerwerk', true ) 
addEventHandler ( "Feuerwerk", root , Feuerwerk ) 
  
function fire1 ( thePlayer ) 
    local x, y, z = getElementPosition ( thePlayer ) 
    createExplosion ( x, y, z + 15, 0 )  
    setTimer(fire2, 500, 1, 0) 
end 
  
function fire2 ( thePlayer ) 
    local x,y,z = getElementPosition ( thePlayer ) 
    createExplosion ( x, y, z + 13, 0 )  
    setTimer(fire3, 500, 1, 0) 
end  

Link to comment

-- client side:

function bombe10_Button ( state ) 
    if ( state == "left" ) then 
        if ( source == GUIEditor_Button[12] ) then 
            triggerServerEvent ( "Feuerwerk", localPlayer ) 
        end 
    end 
end  
addEventHandler ( "onClientGUIClick", getRootElement(), bombe10_Button ) 

-- server side:

function Feuerwerk ( ) 
    fire1 ( source ) 
end 
addEvent ( "Feuerwerk", true ) 
addEventHandler ( "Feuerwerk", getRootElement(), Feuerwerk ) 
  
function fire1 ( thePlayer ) 
    local x, y, z = getElementPosition ( thePlayer ) 
    createExplosion ( x, y, z + 15, 0 ) 
    setTimer ( fire2, 500, 1, thePlayer  ) 
end 
  
function fire2 ( thePlayer ) 
    local x, y, z = getElementPosition ( thePlayer ) 
    createExplosion ( x, y, z + 13, 0 ) 
    setTimer ( fire3, 500, 1, thePlayer ) 
end 

@X-SHADOW: Please don't post useless stuff.

Link to comment
-- client side:
function bombe10_Button ( state ) 
    if ( state == "left" ) then 
        if ( source == GUIEditor_Button[12] ) then 
            triggerServerEvent ( "Feuerwerk", localPlayer ) 
        end 
    end 
end  
addEventHandler ( "onClientGUIClick", getRootElement(), bombe10_Button ) 

-- server side:

function Feuerwerk ( ) 
    fire1 ( source ) 
end 
addEvent ( "Feuerwerk", true ) 
addEventHandler ( "Feuerwerk", getRootElement(), Feuerwerk ) 
  
function fire1 ( thePlayer ) 
    local position1 = getElementPosition ( thePlayer ) 
    createExplosion ( x, y, z + 15, 0 ) 
    setTimer ( fire2, 500, 1, 0 ) 
end 
  
function fire2 ( thePlayer ) 
    local position2 = getElementPosition ( thePlayer ) 
    createExplosion ( x, y, z + 13, 0 ) 
    setTimer ( fire3, 500, 1, 0 ) 
end 

@X-SHADOW: Please don't post useless stuff.

SoldSnake iam trying to help just like you its free to help others if it wrong or right |~

~| You write CreateExploison ( x,y,z ) ??

where is x,y,z defined ?

Link to comment
function Feuerwerk ( ) 
    fire1 ( source ) 
end 
addEvent ( "Feuerwerk", true ) 
addEventHandler ( "Feuerwerk", getRootElement(), Feuerwerk ) 
  
function fire1 ( thePlayer ) 
    local x, y, z = getElementPosition ( thePlayer ) 
    createExplosion ( x, y, z + 7, 1 ) 
    setTimer ( fire2, 500, 1, 0, thePlayer ) 
end 
  
function fire2 ( thePlayer ) 
    local x, y, z = getElementPosition ( thePlayer ) 
    createExplosion ( x, y, z + 7, 1 ) 
    setTimer ( fire3, 1000, 1, 0, thePlayer ) 
end 

There is still one explosions and not two!

Errors:

Line 14: Bad argument @ 'getElementPosition'

Line 15: attempt to perform arithmetic on local 'z' (a nil value)

Greets

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