Jump to content

HELP Table


LasHa

Recommended Posts

Hello guys! Today i wanna learn something like table but couldn't understand how todo it.

I want table like this

[Vehicle, x, y, z, MoneyAmount]

or like this(better this one so i could make many markers for one model)

VehicleModel(for example 411) =

[x, y, z, MoneyAmount]

VehicleModel means car which will be allowed to hit marker. x, y, z are for Markers and amount of money means that after marker hit he gets Money for example 5,000$

if its possible to be done help me please.

Link to comment
Hello guys! Today i wanna learn something like table but couldn't understand how todo it.

I want table like this

[Vehicle, x, y, z, MoneyAmount]

or like this(better this one so i could make many markers for one model)

VehicleModel(for example 411) =

[x, y, z, MoneyAmount]

VehicleModel means car which will be allowed to hit marker. x, y, z are for Markers and amount of money means that after marker hit he gets Money for example 5,000$

if its possible to be done help me please.

I'd personally build my table like;

local theTable = { 
--["vehicleid"] = {x, y, z, amountOfCash} 
["122"] = {500, 200, 20.2, 5000}, 
["119"] = {230, 600, 13.5, 4500} 
} 

and trigger the cash reward when client triggers the colshape:

https://wiki.multitheftauto.com/wiki/CreateColSquare

https://wiki.multitheftauto.com/wiki/On ... olShapeHit

Link to comment
markers = { 
    { model, x, y, z, cash }, 
    { model, x, y, z, cash }, 
    { model, x, y, z, cash }, 
    ... 
} 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for _, v in pairs ( markers ) do 
            local m = createMarker ( v[2], v[3], v[4] ) 
            setElementData ( m, "model", v[1] ) 
            setElementData ( m, "cash", v[5] ) 
        end 
         
    end 
) 
  
addEventHandler ( "onMarkerHit", resourceRoot, 
    function ( hitElement, matchingDimension ) 
        if not ( isElement ( hitElement ) or getElementType ( hitElement ) == "player" or matchingDimension ) then 
            return 
        end 
         
        if isPedInVehicle ( hitElement ) then 
            local veh = getPedOccupiedVehicle ( hitElement ) 
            if veh then 
                if getElementModel ( veh ) == getElementData ( source, "model" ) then 
                    givePlayerMoney ( hitElement, getElementData ( source, "cash" ) ) 
                end 
            end 
        end 
    end 
) 

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