Jump to content

Help Markers


LasHa

Recommended Posts

Hello guys! Today i've decided to create very nice script :D the problem is i am begginer. so in what i need help. i want to create markers list with definations of car. i mean create some markers for only infernus hit and some for nrg. after hit if player stays inside for 2 sec i want to store in account data that the player hitted the marker. :) Each of help by you would be useful for me and infuture works it will be uswful too :D

Link to comment

really? :D are you kidding me? even wiki has better information than you :P i asked for another thing i need to create many markers i want to create list like this

markers = {ls marker,

sf marker,

lv marker}

and also for that markers i want that only by infernus can be hitted and on hit write account data

Link to comment
really? :D are you kidding me? even wiki has better information than you :P i asked for another thing i need to create many markers i want to create list like this

markers = {ls marker,

sf marker,

lv marker}

and also for that markers i want that only by infernus can be hitted and on hit write account data

you need to create a table with all marker then check the vehicle model onMarkerHit.

Example

local Markers = { 
{x,y,z}, -- Marker 1 
{x,y,z} -- marker 2  
} 
  
for i , v in pairs (Markers) do 
local theMarker = createMarker ( v[1], v[2], v[3], "cylinder", 1.5, 255, 255, 0, 170 ) 
addEventHandler( "onMarkerHit", theMarker, allowedVehicle ) 
  
end  
  
function allowedVehicle( hitElement, matchingDimension )  
    if matchingDimension and isElement(hitElement) and getElementType(hitElement) == "player" then 
      if isPedInVehicle ( hitElement ) then  
        local vehicle = getPedOccupiedVehicle ( hitElement ) 
          if vehicle then  
          local model = getElementModel(vehicle) 
          if tonumber(model) == 411 then  
           
          -- Your code here 
           
            end  
        end  
    end  
end  
end  

Link to comment
really? :D are you kidding me? even wiki has better information than you :P i asked for another thing i need to create many markers i want to create list like this

markers = {ls marker,

sf marker,

lv marker}

and also for that markers i want that only by infernus can be hitted and on hit write account data

Excuse me? i only told you what functions you should use.

Link to comment

Thank you walid much and the last thing i want can i get that if player will stay for 3 sec in the marker he gets for example money and write account data that he have hitted and if he leaves in this 3 sec nothing happens. and also can i add the second function to NRG? how to analyse if player hitted nrg markers with nrg and infernus markers with infernus?

Link to comment

You need to use setTimer .

Example:

  
local TimeTable = {} 
local waitTime = 3000 -- 3 secods 
  
-- inside the function 
TimeTable[hitElement] = setTimer(GM, waitTime, 1, hitElement) 
  
function GM (player) 
if isElement (player) then  
  if not isElementWithinMarker ( player, theMarker) then return end 
      givePlayerMoney(player, amount here) 
   end  
end  

Edited by Guest
Link to comment
the last question :D can i add the second function to NRG? how to analyse if player hitted nrg markers with nrg and infernus markers with

in this case you need to use table

example :

local alloWedVehicel = { 
[411] = true, -- infernus 
[522]= true, -- NRG} 
  
-- then put this inside the function  
local model = getElementModel(vehicle) 
if alloWedVehicel[model] then  
-- Your code 
end 
  

Link to comment

Walid i'm not earning money while standing in Marker and i got this error in debugscript 3

WARNING: Script\script-c.lua:18: Bad argument @ 'addEventHandler' [Expected element at argument 2, got boolean]

and this EventHandler - local infernusMarker = createMarker ( v[1], v[2], v[3], "cylinder", 4, 255, 255, 0, 170 )

addEventHandler( "onMarkerHit", infernusMarker, infernusHit )

Link to comment
Walid i'm not earning money while standing in Marker and i got this error in debugscript 3

WARNING: Script\script-c.lua:18: Bad argument @ 'addEventHandler' [Expected element at argument 2, got boolean]

and this EventHandler - local infernusMarker = createMarker ( v[1], v[2], v[3], "cylinder", 4, 255, 255, 0, 170 )

addEventHandler( "onMarkerHit", infernusMarker, :~ )

post your code here

Link to comment
  
local infMarkers = { 
{2011.6, 1543.4, 10.5}, -- Marker 1 
{x,y,z} -- Marker 2 
} 
  
for i , v in pairs (infMarkers) do 
local infernusMarker = createMarker ( v[1], v[2], v[3], "cylinder", 4, 255, 255, 0, 170 ) 
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 
          local model = getElementModel(vehicle) 
          if tonumber(model) == 411 then 
          robTbl[hitElement] = setTimer(GMinfernus, waitTime, 1, hitElement) 
          
            end 
end 
end 
end 
addEventHandler( "onMarkerHit", infernusMarker, allowedVehicles ) 
  
local TimeTable = {} 
local waitTime = 3000 -- 3 seconds 
  
function GMinfernus (player) 
if isElement (player) then 
  if isElementWithinMarker ( player, infernusMarker) then return end 
      givePlayerMoney(player, 5000) 
   end 
end 
end 
  

and there is one problem about v[3] too in createElement

Edited by Guest
Link to comment
now i don't get anymore Error about this EventHandler i fixed it but i don't get money :(

lol many things wrong i think you need to learn LUA language.

Ayways try this

local TimeTable = {} 
local waitTime = 3000 -- 3 seconds 
local infMarkers = { 
{2011.6, 1543.4, 10.5}, -- Marker 1 
} 
  
  
  
for i , v in pairs (infMarkers) do 
infernusMarker = createMarker ( v[1], v[2], v[3], "cylinder", 4, 255, 255, 0, 170 ) 
addEventHandler( "onMarkerHit", infernusMarker, allowedVehicles ) 
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 
          local model = getElementModel(vehicle) 
          if tonumber(model) == 411 then 
          TimeTable[hitElement] = setTimer(GMinfernus, waitTime, 1, hitElement) 
            end 
        end 
    end 
end 
end  
  
  
function GMinfernus (player) 
if isElement (player) then 
  if not isElementWithinMarker ( player, infernusMarker) then return end 
      givePlayerMoney(player, 5000) 
   end 
end 

Link to comment
local TimeTable = {} 
local waitTime = 3000 -- 3 seconds 
local infMarkers = { 
{2011.6, 1543.4, 10.5}, -- Marker 1 
} 
  
  
  
for i , v in pairs (infMarkers) do 
    createMarker ( v[1], v[2], v[3], "cylinder", 4, 255, 255, 0, 170 ) 
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 
                local model = getElementModel(vehicle) 
                if tonumber(model) == 411 then 
                    setElementData ( hitElement, "entered.marker", true ) 
                    TimeTable[hitElement] = setTimer(GMinfernus, waitTime, 1, hitElement) 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onMarkerHit", resourceRoot, allowedVehicles ) 
  
addEventHandler ( "onMarkerLeave", resourceRoot, 
    function ( leaveElement ) 
        if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then 
            setElementData ( leaveElement, "entered.marker", false ) 
        end 
    end 
) 
  
function GMinfernus (player) 
    if isElement (player) then 
        if getElementData ( player, "entered.marker" ) then 
            givePlayerMoney(player, 5000) 
        end 
    end 
end 

Link to comment

What do you mean? Do you mean sth like that?

local TimeTable = {} 
local waitTime = 3000 -- 3 seconds 
local infMarkers = { 
{2011.6, 1543.4, 10.5}, -- Marker 1 
} 
  
  
  
for i , v in pairs (infMarkers) do 
    createMarker ( v[1], v[2], v[3], "cylinder", 4, 255, 255, 0, 170 ) 
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 
                local model = getElementModel(vehicle) 
                if tonumber(model) == 411 then 
                    if ( not isTimer ( TimeTable[hitElement] ) ) then 
                        setElementData ( hitElement, "entered.marker", true ) 
                        TimeTable[hitElement] = setTimer(GMinfernus, waitTime, 1, hitElement) 
                    end 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onMarkerHit", resourceRoot, allowedVehicles ) 
  
addEventHandler ( "onMarkerLeave", resourceRoot, 
    function ( leaveElement ) 
        if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then 
            setElementData ( leaveElement, "entered.marker", false ) 
        end 
    end 
) 
  
function GMinfernus (player) 
    if isElement (player) then 
        if getElementData ( player, "entered.marker" ) then 
            givePlayerMoney(player, 5000) 
        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...