Jump to content

setElementPosition bad D:


iFoReX

Recommended Posts

Posted

why the setElementPosition is bad ?

    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "ElMota[Gold]~x" then 
    setElementPosition( source, -1960.53528, 127.29656, 27.68750 ) 
    else 
        if ( money >= 10000 ) then 
            takePlayerMoney ( source, 10000 ) 
            setElementPosition( source, -1960.53528, 127.29656, 27.68750 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "qd2", true ) 
addEventHandler( "qd2", getRootElement(), qm2 ) 
  
local table = {{2851.87793, 1290.40491, 11.39063},{1433.50720, 2620.47266, 11.39261}} -- Una tabla con diferentes modelos de vehiculos. 
function qm4 ( ) 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "ElMota[Gold]~x" then 
     setElementPosition ( source, table[ math.random ( #table ) ] ) 
    else 
        if ( money >= 10000 ) then 
            takePlayerMoney ( source, 10000 ) 
                 setElementPosition ( source, table[ math.random ( #table ) ] ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "qd4", true ) 
addEventHandler( "qd4", getRootElement(), qm4 ) 
  
addEventHandler("onResourceStart",Vehiculocrear) 
  
function qm3 ( ) 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "ElMota[Gold]~x" then 
    setElementPosition( source, 1056.44568, -2724.47437, 8.48407 ) 
    else 
        if ( money >= 10000 ) then 
            takePlayerMoney ( source, 10000 ) 
            setElementPosition( source, 1056.44568, -2724.47437, 8.48407 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "qd3", true ) 
addEventHandler( "qd3", getRootElement(), qm3 ) 

elMota/elFoReX De Vuelta En MTA *---------*

Cuenta De Youtube En La Que Subo Tutoriales Acerca De MTA :3

https://www.youtube.com/user/KillersGPs

430x73_FFFFFF_FF9900_000000_000000.png
Guest Guest4401
Posted (edited)

Because in your case, the 2nd argument in setElementPosition is a table. It's not unpacking the x,y,z positions as you're trying to do.

EDIT : There are a lot of other basic errors too, you must try to fix those first. (No offense)

Edited by Guest4401
Posted

You have

addEventHandler("onResourceStart",Vehiculocrear) 

Which triggers nothing...

EDIT:

parameters = unpack(Table) 

in your case, you use:

x,y,z = unpack(Table[math.random(#Table)]) 

try this:

addEvent( "qd2", true ) 
addEventHandler( "qd2", root,function() 
   local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "ElMota[Gold]~x" then 
    setElementPosition( source, -1960.53528, 127.29656, 27.68750 ) 
    else 
        if ( money >= 10000 ) then 
            takePlayerMoney ( source, 10000 ) 
            setElementPosition( source, -1960.53528, 127.29656, 27.68750 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end) 
  
local table = {{2851.87793, 1290.40491, 11.39063},{1433.50720, 2620.47266, 11.39261}} -- Una tabla con diferentes modelos de vehiculos. 
  
addEvent( "qd4", true ) 
addEventHandler( "qd4", root,function() 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "ElMota[Gold]~x" then 
     setElementPosition ( source, table[ math.random ( #table ) ] ) 
    else 
        if ( money >= 10000 ) then 
            takePlayerMoney ( source, 10000 ) 
            x,y,z = unpack(table[math.random(#table)]) 
            setElementPosition ( source, x,y,z) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end) 
  
addEventHandler("onResourceStart",resourceRoot,Vehiculocrear) 
  
addEvent( "qd3", true ) 
addEventHandler( "qd3", root,function() 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "ElMota[Gold]~x" then 
    setElementPosition( source, 1056.44568, -2724.47437, 8.48407 ) 
    else 
        if ( money >= 10000 ) then 
            takePlayerMoney ( source, 10000 ) 
            setElementPosition( source, 1056.44568, -2724.47437, 8.48407 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

??

local table = {{2851.87793, 1290.40491, 11.39063},{1433.50720, 2620.47266, 11.39261}} -- Una tabla con diferentes modelos de vehiculos. 
function qm4 ( ) 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "ElMota[Gold]~x" then 
     setElementPosition ( source, unpack(table)table[ math.random ( #table ) ] ) 
    else 
        if ( money >= 10000 ) then 
            takePlayerMoney ( source, 10000 ) 
                 setElementPosition ( source, unpack(table)table[ math.random ( #table ) ] ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "qd4", true ) 
addEventHandler( "qd4", getRootElement(), qm4 ) 

elMota/elFoReX De Vuelta En MTA *---------*

Cuenta De Youtube En La Que Subo Tutoriales Acerca De MTA :3

https://www.youtube.com/user/KillersGPs

430x73_FFFFFF_FF9900_000000_000000.png
Posted

no, like this:

local table = {{2851.87793, 1290.40491, 11.39063},{1433.50720, 2620.47266, 11.39261}} -- Una tabla con diferentes modelos de vehiculos. 
  
addEvent( "qd4", true ) 
addEventHandler( "qd4", root,function() 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    local x,y,z = unpack(table[math.random(#table)]) 
    if name == "ElMota[Gold]~x" then 
     setElementPosition ( source,x,y,z ) 
    else 
        if ( money >= 10000 ) then 
            takePlayerMoney ( source, 10000 ) 
            setElementPosition ( source, x,y,z) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

Use MTA Script Editor from 50p. It have some bugs, but it's better than Notepad++ xD

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

I want when theKiller had 6 stars in wanted level appear a blip in he and appear in chatbox to all the manhunt and the player to kill and the money, and if he again kill to RandomPlayer he when stop the manhunt give more money, if a RandomPlayer kill to theKiller giveMoney 10000

xD

elMota/elFoReX De Vuelta En MTA *---------*

Cuenta De Youtube En La Que Subo Tutoriales Acerca De MTA :3

https://www.youtube.com/user/KillersGPs

430x73_FFFFFF_FF9900_000000_000000.png
Posted
addEventHandler("onResourceStart",Vehiculocrear) 

omg ...

I did give you links for learning, but you not want learn. Ok

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

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