Jump to content

Getting Element Data Number Problem


LasHa

Recommended Posts

Try this one

local TimeTable = {} 
local waitTime = 3000 -- 3 seconds 
local Markers = { 
{411, 2015, 1543.4, 10.5, 5000}, -- Marker 1 
{411, 2020, 1543.4, 10.5, 5000}, -- Marker 2 
} 
  
  
  
for i , v in pairs (Markers) do 
    HitMarker = createMarker ( v[2], v[3], v[4], "corona", 2, 255, 0, 0, 255 ) 
    setElementData ( HitMarker, "model", v[1] ) 
    setElementData ( HitMarker, "cash", v[5] ) 
end 
  
function allowedVehicles( hitElement, matchingDimension ) 
    if matchingDimension and isElement(hitElement) and getElementType(hitElement) == "player" then 
        if isPedInVehicle ( hitElement ) then 
            local vehicle = getPedOccupiedVehicle ( hitElement ) 
            if vehicle then 
                if getElementModel ( vehicle ) == getElementData ( source, "model" ) then 
                TimeTable[hitElement] = setTimer(StuntComplete, waitTime, 1, hitElement,source) 
                setElementData ( hitElement, "entered.marker", true ) 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onMarkerHit", resourceRoot, allowedVehicles ) 
  
function StuntComplete ( player,marker) 
    if isElement ( player ) then 
        if getElementData ( player, "entered.marker" ) then 
            givePlayerMoney ( player, tonumber(getElementData (marker, "cash"))) 
            setMarkerColor ( marker, 0, 255, 0, 255 ) 
            outputChatBox ( "You completed the Stunt", hitElement, 0, 255, 0 ) 
        end 
    end 
end 
  
addEventHandler ( "onMarkerLeave", resourceRoot, 
    function ( leaveElement ) 
        if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then 
        if isTimer ( waitTime ) then 
        killTimer ( waitTime ) 
            setElementData ( leaveElement, "entered.marker", false ) 
            outputChatBox("You failed the Stunt!", player, 255, 0, 0) 
end 
end 
        end 
) 

Link to comment

Walid one more question. i want to use red small square as Blip its a 0(Marker) but when its higher then player its triangle with corner up and when its lower then player corner down how to freeze its with just small red square?

Link to comment
Walid one more question. i want to use red small square as Blip its a 0(Marker) but when its higher then player its triangle with corner up and when its lower then player corner down how to freeze its with just small red square?

:o sorry i don't undrestand ur english

Link to comment

okay and how to change single blip color? like if i enter in the marker with this code

local blips = getElementsByType ( "blip" ) 
for blipKey, blipValue in ipairs ( blips ) do 
    local red, green, blue, alpha = getBlipColor ( blipValue ) 
    if ( red ~= 0 or green ~= 255 or blue ~= 0 or alpha ~= 255 ) then 
        setBlipColor ( blipValue, 0, 255, 0, 255 ) 
    end 
end 
  

every blip color changes to green.

http://i.imgur.com/bpfJf1r.jpg

http://i.imgur.com/WkiAQ5m.jpg

my code

  
local TimeTable = {} 
local waitTime = 3000 -- 3 seconds 
local Markers = { 
{522, -1204, -1057, 155, 5000}, -- Marker 1 
{522, -1204, -1090, 155, 5000}, -- Marker 2 
{522, -1204, -1150, 155, 5000}, -- Marker 3 
{522, -1204, -1200, 155, 5000}, -- Marker 4 
{522, -1204, -1250, 155, 5000}, -- Marker 5 
} 
  
  
  
for i , v in pairs (Markers) do 
    HitMarker = createMarker ( v[2], v[3], v[4], "corona", 1.20, 255, 0, 0, 255 ) 
    createBlipAttachedTo( HitMarker, 0 ) 
    setElementData ( HitMarker, "model", v[1] ) 
    setElementData ( HitMarker, "cash", v[5] ) 
end 
  
function allowedVehicles( hitElement, matchingDimension ) 
    if matchingDimension and isElement(hitElement) and getElementType(hitElement) == "player" then 
        if isPedInVehicle ( hitElement ) then 
            local vehicle = getPedOccupiedVehicle ( hitElement ) 
            if vehicle then 
                if getElementModel ( vehicle ) == getElementData ( source, "model" ) then 
                TimeTable[hitElement] = setTimer(StuntComplete, waitTime, 1, hitElement,source) 
                setElementData ( hitElement, "entered.marker", true ) 
else 
outputChatBox ( "You have entered in Stunt with wrong vehicle", hitElement, 255, 0, 0 ) 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onMarkerHit", resourceRoot, allowedVehicles ) 
  
function StuntComplete ( player,marker) 
    if isElement ( player ) then 
        if getElementData ( player, "entered.marker" ) then 
            givePlayerMoney ( player, tonumber(getElementData (marker, "cash"))) 
            outputChatBox ( "You have completed the Stunt", hitElement, 0, 255, 0 ) 
local blips = getElementsByType ( "blip" ) 
for blipKey, blipValue in ipairs ( blips ) do 
    local red, green, blue, alpha = getBlipColor ( blipValue ) 
    if ( red ~= 0 or green ~= 255 or blue ~= 0 or alpha ~= 255 ) then 
        setBlipColor ( blipValue, 0, 255, 0, 255 ) 
    end 
end 
        end 
end 
end 
  
addEventHandler ( "onMarkerLeave", resourceRoot, 
    function ( leaveElement ) 
        if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then 
        if isTimer ( waitTime ) then 
        killTimer ( waitTime ) 
            setElementData ( leaveElement, "entered.marker", false ) 
            outputChatBox("You failed the Stunt!", player, 255, 0, 0) 
end 
end 
        end 
) 
  

Link to comment

try this :

local TimeTable = {} 
local waitTime = 3000 -- 3 seconds 
local Blips = {} 
local Markers = { 
{522, -1204, -1057, 155, 5000}, -- Marker 1 
{522, -1204, -1090, 155, 5000}, -- Marker 2 
{522, -1204, -1150, 155, 5000}, -- Marker 3 
{522, -1204, -1200, 155, 5000}, -- Marker 4 
{522, -1204, -1250, 155, 5000}, -- Marker 5 
} 
  
  
  
for i , v in pairs (Markers) do 
    HitMarker = createMarker ( v[2], v[3], v[4], "corona", 1.20, 255, 0, 0, 255 ) 
    Blips[HitMarker] = createBlipAttachedTo( HitMarker, 0 ) 
    setElementData ( HitMarker, "model", v[1] ) 
    setElementData ( HitMarker, "cash", v[5] ) 
end 
  
function allowedVehicles( hitElement, matchingDimension ) 
    if matchingDimension and isElement(hitElement) and getElementType(hitElement) == "player" then 
        if isPedInVehicle ( hitElement ) then 
            local vehicle = getPedOccupiedVehicle ( hitElement ) 
            if vehicle then 
                if getElementModel ( vehicle ) == getElementData ( source, "model" ) then 
                TimeTable[hitElement] = setTimer(StuntComplete, waitTime, 1, hitElement,source) 
                setElementData ( hitElement, "entered.marker", true ) 
                else 
                outputChatBox ( "You have entered in Stunt with wrong vehicle", hitElement, 255, 0, 0 ) 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onMarkerHit", resourceRoot, allowedVehicles ) 
  
function StuntComplete ( player,marker) 
    if isElement ( player ) then 
        if getElementData ( player, "entered.marker" ) then 
            givePlayerMoney ( player, tonumber(getElementData (marker, "cash"))) 
            outputChatBox ( "You have completed the Stunt", hitElement, 0, 255, 0 ) 
            if isElement(Blips[marker]) then  
            setBlipColor (Blips[marker], 0, 255, 0, 255 ) 
        end  
    end 
end 
end  
  
addEventHandler ( "onMarkerLeave", resourceRoot, 
    function ( leaveElement ) 
        if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then 
        if isTimer ( waitTime ) then 
            killTimer ( waitTime ) 
            setElementData ( leaveElement, "entered.marker", false ) 
            outputChatBox("You failed the Stunt!", player, 255, 0, 0) 
        end 
    end 
end 
) 

Link to comment
Thanks it works. and the last the last :D Question can you add in function StuntComplete that the Marker which i will enter it will become green? please :*

add

function StuntComplete ( player,marker) 
    if isElement ( player ) then 
        if getElementData ( player, "entered.marker" ) then 
            givePlayerMoney ( player, tonumber(getElementData (marker, "cash"))) 
            outputChatBox ( "You have completed the Stunt", hitElement, 0, 255, 0 ) 
            if isElement(Blips[marker]) then 
            setBlipColor (Blips[marker], 0, 255, 0, 255 ) 
            end 
            setMarkerColor (marker,0, 255, 0, 255 ) 
        end 
    end 
end 

Link to comment
Okay thank you much with every single help <3 can i add you in skype? i have few more questions :D and please delete all of your comments to prevent scamers from st ealing this simple script :|

Sorry for the Off-topic but ...

If it's a simple script then what's the problem to let the others see how the problem was solved ?

You don't deserve to get helped anymore!

Link to comment
Okay thank you much with every single help <3 can i add you in skype? i have few more questions :D and please delete all of your comments to prevent scamers from st ealing this simple script :|

Your script is nothing why i need to delete it let the others see how the problem was solved .

Anyways i can't gave you my skype , if u have a question ask it here

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