Jump to content

Errors (bad argument, attempt to perform)


FSXTim

Recommended Posts

Posted

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

430x73.png
Posted

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  

MTA Scripter.

If you want scripter PM me and i will accept every job for fair price.

Posted (edited)

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
430x73.png
Posted

This is a client or a server side script?

P.S: Can you post the rest of the script?

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

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

430x73.png
Posted
--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  

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

Posted

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

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

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

Posted
Thanks, I will test it.

Greets

Copy the server side code again, I fixed some bugs.

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

430x73.png
Posted

Found the problem, you we're passing another argument "0" in setTimer, so at the other functions it wasn't sending the first argument as a player element, but a number.

Copy server side again.

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

You're welcome.

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.

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