LasHa Posted May 4, 2015 Share Posted May 4, 2015 Hello guys! Today i've decided to create very nice script 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 Link to comment
Mr.unpredictable. Posted May 4, 2015 Share Posted May 4, 2015 createMarker onMarkerHit Link to comment
LasHa Posted May 4, 2015 Author Share Posted May 4, 2015 really? are you kidding me? even wiki has better information than you 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
Walid Posted May 4, 2015 Share Posted May 4, 2015 really? are you kidding me? even wiki has better information than you 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
Mr.unpredictable. Posted May 4, 2015 Share Posted May 4, 2015 really? are you kidding me? even wiki has better information than you 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
LasHa Posted May 4, 2015 Author Share Posted May 4, 2015 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
Walid Posted May 4, 2015 Share Posted May 4, 2015 (edited) 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 May 4, 2015 by Guest Link to comment
LasHa Posted May 4, 2015 Author Share Posted May 4, 2015 the last question can i add the second function to NRG? how to analyse if player hitted nrg markers with nrg and infernus markers with Link to comment
Walid Posted May 4, 2015 Share Posted May 4, 2015 the last question 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
LasHa Posted May 4, 2015 Author Share Posted May 4, 2015 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 Posted May 4, 2015 Share Posted May 4, 2015 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
LasHa Posted May 4, 2015 Author Share Posted May 4, 2015 (edited) 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 May 4, 2015 by Guest Link to comment
LasHa Posted May 4, 2015 Author Share Posted May 4, 2015 now i don't get anymore Error about this EventHandler i fixed it but i don't get money Link to comment
Walid Posted May 4, 2015 Share Posted May 4, 2015 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
LasHa Posted May 4, 2015 Author Share Posted May 4, 2015 dude it didn't give me money http://i.imgur.com/We8PD3e.jpg Link to comment
LasHa Posted May 4, 2015 Author Share Posted May 4, 2015 The same thing problem with Event handler argument 3 http://i.imgur.com/cj6I5Gt.jpg addEventHandler("onMarkerHit", infernusMarker, AllowedVehicles) Link to comment
WhoAmI Posted May 4, 2015 Share Posted May 4, 2015 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
Walid Posted May 4, 2015 Share Posted May 4, 2015 The same thing problem with Event handler argument 3 http://i.imgur.com/cj6I5Gt.jpg addEventHandler("onMarkerHit", infernusMarker, AllowedVehicles) its allowedVehicles not AllowedVehicles Link to comment
LasHa Posted May 4, 2015 Author Share Posted May 4, 2015 Thank you guys very much. guys can i prevent people from entering in the marker the second time? to prevent them getting money. Link to comment
WhoAmI Posted May 4, 2015 Share Posted May 4, 2015 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
LasHa Posted May 4, 2015 Author Share Posted May 4, 2015 can i add you in skype? i can explain much better. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now