LasHa Posted May 10, 2015 Share Posted May 10, 2015 Hello guys! i asked in forums for many things and i got many answers. one of questions was about markers and in the markers there was setElementData i used the same way to setElementData but mine one wasn't working why? i will show you whole code and after that whole code + my ElementData here is the working code local TimeTable = {} local waitTime = 3000 -- 3 seconds local Blips = {} local Markers = { {522, 1986, -1478.1, 21.5, 17.500}, -- Marker 1 {522, 1114, -1822, 33.5, 17.500}, -- Marker 2 {522, 776.8, -1036, 39.5, 9000}, -- Marker 3 {522, 1313, -1163, 41, 7500}, -- Marker 4 {522, 1404, -806, 85, 7500}, -- Marker 5 {522, 775.7, -1060.5, 33.2, 5000}, -- Marker 6 } 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] ) setElementData ( HitMarker, "markerName", v[6] ) 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 and earned "..tonumber(getElementData (marker, "cash")).."$", player, 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 addEventHandler ( "onMarkerLeave", resourceRoot, function ( leaveElement ) if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then setElementData ( leaveElement, "entered.marker", false ) outputChatBox("You failed the Stunt!", leaveElement, 255, 0, 0) end end ) i tried to add this in the code at the function StuntComplete local totalStunts = getElementData( player, "totalStunts" ) setElementData( HitMarker, "totalStunts" +1) and this function stuntsFinished ( player ) outputChatBox( "You have finished "..tonumber(getElementData( player, "totalStunts" )).."/512 Stunts", player, 0, 255, 0) end addCommandHandler("fstunts", stuntsFinished) and the full code after it looks like that local TimeTable = {} local waitTime = 3000 -- 3 seconds local Blips = {} local Markers = { {522, 1986, -1478.1, 21.5, 17.500}, -- Marker 1 {522, 1114, -1822, 33.5, 17.500}, -- Marker 2 {522, 776.8, -1036, 39.5, 9000}, -- Marker 3 {522, 1313, -1163, 41, 7500}, -- Marker 4 {522, 1404, -806, 85, 7500}, -- Marker 5 {522, 775.7, -1060.5, 33.2, 5000}, -- Marker 6 } 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] ) setElementData ( HitMarker, "markerName", v[6] ) 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 and earned "..tonumber(getElementData (marker, "cash")).."$", player, 0, 255, 0 ) if isElement( Blips[marker] ) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) setMarkerColor (marker,0, 255, 0, 255 ) local totalStunts = getElementData( player, "totalStunts" ) setElementData( HitMarker, "totalStunts" +1) end end end end addEventHandler ( "onMarkerLeave", resourceRoot, function ( leaveElement ) if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then setElementData ( leaveElement, "entered.marker", false ) outputChatBox("You failed the Stunt!", leaveElement, 255, 0, 0) end end ) function stuntsFinished ( player ) outputChatBox( "You have finished "..tonumber(getElementData( player, "totalStunts" )).."/512 Stunts", player, 0, 255, 0) end addCommandHandler("fstunts", stuntsFinished) an error says: #1 Attempt to perform arithmetic on a string value #2 Attempt to concetante a nil value also help in this i want to add v[6] {v[1]VehicleModel, v[2]X, v[3]Y, v[4]Z, v[5]Cash, v[6]StuntName} help me to add it and after player complete the stunt he get texts like that: "You completed v[6] - v[5] " example: You completed Vinewoods One - 7,500$ Link to comment
Walid Posted May 10, 2015 Share Posted May 10, 2015 Try this local TimeTable = {} local waitTime = 3000 -- 3 seconds local Blips = {} local Markers = { {522, 1986, -1478.1, 21.5, 17.500}, -- Marker 1 {522, 1114, -1822, 33.5, 17.500}, -- Marker 2 {522, 776.8, -1036, 39.5, 9000}, -- Marker 3 {522, 1313, -1163, 41, 7500}, -- Marker 4 {522, 1404, -806, 85, 7500}, -- Marker 5 {522, 775.7, -1060.5, 33.2, 5000}, -- Marker 6 } 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] ) setElementData ( HitMarker, "markerName", v[6] ) 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 and earned "..tonumber(getElementData (marker, "cash")).."$", player, 0, 255, 0 ) if isElement( Blips[marker] ) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) setMarkerColor (marker,0, 255, 0, 255 ) local totalStunts = getElementData( player, "totalStunts" ) setElementData( player, "totalStunts" , tonumber(totalStunts)+1) end end end end addEventHandler ( "onMarkerLeave", resourceRoot, function ( leaveElement ) if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then setElementData ( leaveElement, "entered.marker", false ) outputChatBox("You failed the Stunt!", leaveElement, 255, 0, 0) end end ) function stuntsFinished ( player ) if isElement(player) then local count = getElementData( player, "totalStunts" ) or 0 outputChatBox( "You have finished "..tonumber(count).."/512 Stunts", player, 0, 255, 0) end end addCommandHandler("fstunts", stuntsFinished) Link to comment
LasHa Posted May 10, 2015 Author Share Posted May 10, 2015 Walid tried but after stunt complete i get the same error: attempt to perform arithmetic on a nil value and after writing command /fstunts i got the same error: attempt to concatenate a nil value Link to comment
Walid Posted May 10, 2015 Share Posted May 10, 2015 Walid tried but after stunt complete i get the same error: attempt to perform arithmetic on a nil valueand after writing command /fstunts i got the same error: attempt to concatenate a nil value Try this one local TimeTable = {} local waitTime = 3000 -- 3 seconds local Blips = {} local Markers = { {522, 1986, -1478.1, 21.5, 17.500, "StantName Here"}, -- Marker 1 {522, 1114, -1822, 33.5, 17.500,""}, -- Marker 2 {522, 776.8, -1036, 39.5, 9000,""}, -- Marker 3 {522, 1313, -1163, 41, 7500,""}, -- Marker 4 {522, 1404, -806, 85, 7500,""}, -- Marker 5 {522, 775.7, -1060.5, 33.2, 5000,""}, -- Marker 6 } 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] ) setElementData ( HitMarker, "markerName", v[6] ) 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 and earned "..tonumber(getElementData (marker, "cash")).."$", player, 0, 255, 0 ) if isElement( Blips[marker] ) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) setMarkerColor (marker,0, 255, 0, 255 ) end local totalStunts = getElementData( player, "totalStunts" ) or 0 setElementData( player, "totalStunts" , tonumber(totalStunts)+1) end end end addEventHandler ( "onMarkerLeave", resourceRoot, function ( leaveElement ) if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then setElementData ( leaveElement, "entered.marker", false ) outputChatBox("You failed the Stunt!", leaveElement, 255, 0, 0) end end ) function stuntsFinished ( player ) if isElement(player) then local count = getElementData( player, "totalStunts" ) or 0 outputChatBox( "You have finished "..tonumber(count).."/512 Stunts", player, 0, 255, 0) end end addCommandHandler("fstunts", stuntsFinished) Link to comment
LasHa Posted May 10, 2015 Author Share Posted May 10, 2015 thank you works :* can you help me add v[6]? and also how to permit players enter marker second time? i mean can we setAccountData after complete stunt and it will check if player hasn't this stunt yet? please please Link to comment
Walid Posted May 10, 2015 Share Posted May 10, 2015 thank you works :* can you help me add v[6]? and also how to permit players enter marker second time? i mean can we setAccountData after complete stunt and it will check if player hasn't this stunt yet? please please Np here is your code local TimeTable = {} local waitTime = 3000 -- 3 seconds local Blips = {} local details = {} local Markers = { {522, 1986, -1478.1, 21.5, 17.500, "StantName Here"}, -- Marker 1 {522, 1114, -1822, 33.5, 17.500,"StantName Here"}, -- Marker 2 {522, 776.8, -1036, 39.5, 9000,"StantName Here"}, -- Marker 3 {522, 1313, -1163, 41, 7500,"StantName Here"}, -- Marker 4 {522, 1404, -806, 85, 7500,"StantName Here"}, -- Marker 5 {522, 775.7, -1060.5, 33.2, 5000,"StantName Here"}, -- Marker 6 } 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 ) details[HitMarker] = {v[1],v[5],v[6]} 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 alreadyEntred = getElementData ( hitElement, "entered.marker") if alreadyEntred then outputChatBox("Sorry you can't enter the marker twice" , hitElement,255,0,0) return end 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 local theTable = details[marker] if (theTable) then local model, cash, name = details[marker][1], details[marker][2], details[marker][3] givePlayerMoney ( player, tonumber(cash)) outputChatBox ( "You have completed the Stunt and earned "..tonumber(cash).."$", player, 0, 255, 0 ) if isElement( Blips[marker] ) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) setMarkerColor (marker,0, 255, 0, 255 ) end local totalStunts = getElementData( player, "totalStunts" ) or 0 setElementData( player, "totalStunts" , tonumber(totalStunts)+1) end end end end addEventHandler ( "onMarkerLeave", resourceRoot, function ( leaveElement ) if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then setElementData ( leaveElement, "entered.marker", false ) outputChatBox("You failed the Stunt!", leaveElement, 255, 0, 0) end end ) function stuntsFinished ( player ) if isElement(player) then local count = getElementData( player, "totalStunts" ) or 0 outputChatBox( "You have finished "..tonumber(count).."/512 Stunts", player, 0, 255, 0) end end addCommandHandler("fstunts", stuntsFinished) Link to comment
LasHa Posted May 10, 2015 Author Share Posted May 10, 2015 it writes You have entered in the Stunt with wrong vehicle in any marker if i enter and also i wanted with account system because ElementData won't save all the things like marker and blip color can you do it with AccountData pleasE? please please. from this code local TimeTable = {} local waitTime = 3000 -- 3 seconds local Blips = {} local Markers = { {522, 1986, -1478.1, 21.5, 17.500, "StantName Here"}, -- Marker 1 {522, 1114, -1822, 33.5, 17.500,""}, -- Marker 2 {522, 776.8, -1036, 39.5, 9000,""}, -- Marker 3 {522, 1313, -1163, 41, 7500,""}, -- Marker 4 {522, 1404, -806, 85, 7500,""}, -- Marker 5 {522, 775.7, -1060.5, 33.2, 5000,""}, -- Marker 6 } 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] ) setElementData ( HitMarker, "markerName", v[6] ) 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 and earned "..tonumber(getElementData (marker, "cash")).."$", player, 0, 255, 0 ) if isElement( Blips[marker] ) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) setMarkerColor (marker,0, 255, 0, 255 ) end local totalStunts = getElementData( player, "totalStunts" ) or 0 setElementData( player, "totalStunts" , tonumber(totalStunts)+1) end end end addEventHandler ( "onMarkerLeave", resourceRoot, function ( leaveElement ) if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then setElementData ( leaveElement, "entered.marker", false ) outputChatBox("You failed the Stunt!", leaveElement, 255, 0, 0) end end ) function stuntsFinished ( player ) if isElement(player) then local count = getElementData( player, "totalStunts" ) or 0 outputChatBox( "You have finished "..tonumber(count).."/512 Stunts", player, 0, 255, 0) end end addCommandHandler("fstunts", stuntsFinished) and can you test it if you have your local server please? Link to comment
Walid Posted May 10, 2015 Share Posted May 10, 2015 Man check the code before you start talking because i already changed every thing in it check this: local TimeTable = {} local waitTime = 3000 -- 3 seconds local Blips = {} local details = {} local Entred = {} local Markers = { {522, 1986, -1478.1, 21.5, 17.500, "StantName Here"}, -- Marker 1 {522, 1114, -1822, 33.5, 17.500,"StantName Here"}, -- Marker 2 {522, 776.8, -1036, 39.5, 9000,"StantName Here"}, -- Marker 3 {522, 1313, -1163, 41, 7500,"StantName Here"}, -- Marker 4 {522, 1404, -806, 85, 7500,"StantName Here"}, -- Marker 5 {522, 775.7, -1060.5, 33.2, 5000,"StantName Here"}, -- Marker 6 } 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 ) details[HitMarker] = {v[1],v[5],v[6]} 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 Entred[hitElement] == source then outputChatBox("Sorry you can't enter the marker twice" , hitElement,255,0,0) return end if getElementModel ( vehicle ) == getElementData ( source, "model" ) then TimeTable[hitElement] = setTimer(StuntComplete, waitTime, 1, hitElement,source) setElementData ( hitElement, "entered.marker", true ) Entred[hitElement] = source 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 local theTable = details[marker] if (theTable) then local model, cash, name = details[marker][1], details[marker][2], details[marker][3] givePlayerMoney ( player, tonumber(cash)) outputChatBox ( "You have completed the Stunt and earned "..tonumber(cash).."$", player, 0, 255, 0 ) if isElement( Blips[marker] ) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) setMarkerColor (marker,0, 255, 0, 255 ) end local totalStunts = getElementData( player, "totalStunts" ) or 0 setElementData( player, "totalStunts" , tonumber(totalStunts)+1) end end end end addEventHandler ( "onMarkerLeave", resourceRoot, function ( leaveElement ) if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then setElementData ( leaveElement, "entered.marker", false ) outputChatBox("You failed the Stunt!", leaveElement, 255, 0, 0) end end ) function stuntsFinished ( player ) if isElement(player) then local count = getElementData( player, "totalStunts" ) or 0 outputChatBox( "You have finished "..tonumber(count).."/512 Stunts", player, 0, 255, 0) end end addCommandHandler("fstunts", stuntsFinished) Link to comment
LasHa Posted May 10, 2015 Author Share Posted May 10, 2015 this is equal that you wrote a post before mine? i have already checked it and there were many problems. as i said it writes You have entered in the Stunt with wrong vehicle and in the first enter i can't get money too. and if i reconnect or restart script will it save my details? like if i have completed stunt the marker or blip color will be saved? or the details that i have already entered will be saved? Link to comment
Walid Posted May 10, 2015 Share Posted May 10, 2015 this is equal that you wrote a post before mine? i have already checked it and there were many problems. as i said it writesYou have entered in the Stunt with wrong vehicle and in the first enter i can't get money too. and if i reconnect or restart script will it save my details? like if i have completed stunt the marker or blip color will be saved? or the details that i have already entered will be saved? try this one local TimeTable = {} local waitTime = 3000 -- 3 seconds local Blips = {} local details = {} local Entred = {} local Markers = { {522, 1986, -1478.1, 21.5, 17.500, "StantName Here"}, -- Marker 1 {522, 1114, -1822, 33.5, 17.500,"StantName Here"}, -- Marker 2 {522, 776.8, -1036, 39.5, 9000,"StantName Here"}, -- Marker 3 {522, 1313, -1163, 41, 7500,"StantName Here"}, -- Marker 4 {522, 1404, -806, 85, 7500,"StantName Here"}, -- Marker 5 {522, 775.7, -1060.5, 33.2, 5000,"StantName Here"}, -- Marker 6 } 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 ) details[HitMarker] = {v[1],v[5],v[6]} 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 Entred[hitElement] == source then outputChatBox("Sorry you can't enter the marker twice" , hitElement,255,0,0) return end theTable = details[source] if (theTable) then model, cash, name = details[source][1], details[source][2], details[source][3] if getElementModel ( vehicle ) == model then TimeTable[hitElement] = setTimer(StuntComplete, waitTime, 1, hitElement,source) setElementData ( hitElement, "entered.marker", true ) Entred[hitElement] = source else outputChatBox ( "You have entered in Stunt with wrong vehicle", hitElement, 255, 0, 0 ) end 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(cash)) outputChatBox ( "You have completed the Stunt and earned "..tonumber(cash).."$", player, 0, 255, 0 ) if isElement( Blips[marker] ) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) setMarkerColor (marker,0, 255, 0, 255 ) end local totalStunts = getElementData( player, "totalStunts" ) or 0 setElementData( player, "totalStunts" , tonumber(totalStunts)+1) end end end addEventHandler ( "onMarkerLeave", resourceRoot, function ( leaveElement ) if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then setElementData ( leaveElement, "entered.marker", false ) outputChatBox("You failed the Stunt!", leaveElement, 255, 0, 0) end end ) function stuntsFinished ( player ) if isElement(player) then local count = getElementData( player, "totalStunts" ) or 0 outputChatBox( "You have finished "..tonumber(count).."/512 Stunts", player, 0, 255, 0) end end addCommandHandler("fstunts", stuntsFinished) Edit : Try it now Link to comment
LasHa Posted May 10, 2015 Author Share Posted May 10, 2015 hey it works but as i told you after script was restarted or after i did reconnect nor blip color green neither marker color green was saved only that saved that i entered marker Link to comment
Walid Posted May 10, 2015 Share Posted May 10, 2015 hey it works but as i told you after script was restarted or after i did reconnect nor blip color green neither marker color green was saved only that saved that i entered marker you are welcome try to use setAccountData() Link to comment
LasHa Posted May 10, 2015 Author Share Posted May 10, 2015 idk where to use or ehere to get it please this is the last what i need in this account system Link to comment
Walid Posted May 10, 2015 Share Posted May 10, 2015 idk where to use or ehere to get it please this is the last what i need in this account system Do it by yourself and i will help you. Link to comment
LasHa Posted May 10, 2015 Author Share Posted May 10, 2015 okay #1 i changed ElementData of totalStunts to AccountData and it doesn't work no errors or things i did like that local playerAccount = getPlayerAccount ( player ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local totalStunts = getAccountData ( playerAccount, "totalStunts" ) or 0 getAccountData( playerAccount, "totalStunts" , tonumber(totalStunts)+1) -- added this in StuntComplete function stuntsFinished ( player ) if isElement(player) then local playerAccount = getPlayerAccount ( player ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local count = getAccountData( playerAccount, "totalStunts" ) or 0 outputChatBox( "You have finished "..tonumber(count).."/512 Stunts", player, 0, 255, 0) end end end addCommandHandler("fstunts", stuntsFinished) #2 i did blip colors in AccountData but doesn't work it looks like that local blipColor = getBlipColor ( Blips[marker] ) setAccountData ( playerAccount, "Blip.Color", blipColor ) local markerColor = getMarkerColor ( marker ) setAccountData ( playerAccount, "Marker.Color", markerColor ) --added this in StuntComplete too. function savedStunts ( marker ) local playerAccount = getPlayerAccount(source) if (playerAccount) then local BlipColor = getAccountData ( playerAccount, "Blip.Color", true ) if (BlipColor) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) local MarkerColor = getAccountData ( playerAccount, "Marker.Color", true ) if (MarkerColor) then setMarkerColor ( marker, 0, 255, 0, 255 ) end end end end addEventHandler ( "onResourceStart", resourceRoot, savedStunts ) i have done everything i wanted but nothing works now please help me #3 full code looks like that local TimeTable = {} local waitTime = 3000 -- 3 seconds local Blips = {} local details = {} local Entred = {} local Markers = { {522, 1986, -1478.1, 21.5, 17.500, "Sonix #1"}, -- Marker 1 {522, 1114, -1822, 33.5, 17.500,"Sonix #2"}, -- Marker 2 {522, 776.8, -1036, 39.5, 9000,"StantName Here"}, -- Marker 3 {522, 1313, -1163, 41, 7500,"StantName Here"}, -- Marker 4 {522, 1404, -806, 85, 7500,"StantName Here"}, -- Marker 5 {522, 775.7, -1060.5, 33.2, 5000,"StantName Here"}, -- Marker 6 } 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 ) details[HitMarker] = {v[1],v[5],v[6]} 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 Entred[hitElement] == source then outputChatBox("Sorry you can't enter the marker twice" , hitElement,255,0,0) return end theTable = details[source] if (theTable) then model, cash, name = details[source][1], details[source][2], details[source][3] if getElementModel ( vehicle ) == model then TimeTable[hitElement] = setTimer(StuntComplete, waitTime, 1, hitElement,source) setElementData ( hitElement, "entered.marker", true ) Entred[hitElement] = source else outputChatBox ( "You have entered in Stunt with wrong vehicle", hitElement, 255, 0, 0 ) end 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(cash)) outputChatBox ( "You have completed the Stunt and earned "..tonumber(cash).."$", player, 0, 255, 0 ) if isElement( Blips[marker] ) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) setMarkerColor (marker,0, 255, 0, 255 ) end local playerAccount = getPlayerAccount ( player ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local totalStunts = getAccountData ( playerAccount, "totalStunts" ) or 0 getAccountData( playerAccount, "totalStunts" , tonumber(totalStunts)+1) local blipColor = getBlipColor ( Blips[marker] ) setAccountData ( playerAccount, "Blip.Color", blipColor ) local markerColor = getMarkerColor ( marker ) setAccountData ( playerAccount, "Marker.Color", markerColor ) end end end end addEventHandler ( "onMarkerLeave", resourceRoot, function ( leaveElement ) if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then setElementData ( leaveElement, "entered.marker", false ) outputChatBox("You failed the Stunt!", leaveElement, 255, 0, 0) end end ) function stuntsFinished ( player ) if isElement(player) then local playerAccount = getPlayerAccount ( player ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local count = getAccountData( playerAccount, "totalStunts" ) or 0 outputChatBox( "You have finished "..tonumber(count).."/512 Stunts", player, 0, 255, 0) end end end addCommandHandler("fstunts", stuntsFinished) function savedStunts ( marker ) local playerAccount = getPlayerAccount(source) if (playerAccount) then local BlipColor = getAccountData ( playerAccount, "Blip.Color", true ) if (BlipColor) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) local MarkerColor = getAccountData ( playerAccount, "Marker.Color", true ) if (MarkerColor) then setMarkerColor ( marker, 0, 255, 0, 255 ) end end end end addEventHandler ( "onResourceStart", resourceRoot, savedStunts ) Link to comment
Walid Posted May 10, 2015 Share Posted May 10, 2015 replace getAccountData() with setAccountData() here Link to comment
LasHa Posted May 10, 2015 Author Share Posted May 10, 2015 okay thats totalstunts but marker and blip colors? save? Link to comment
Walid Posted May 11, 2015 Share Posted May 11, 2015 okay thats totalstunts but marker and blip colors? save? Walid sorry man i'm busy try to do it by yourself and post your code here Link to comment
LasHa Posted May 11, 2015 Author Share Posted May 11, 2015 i said in the last post i wrote code and posted it if you want i will post it again Link to comment
LasHa Posted May 11, 2015 Author Share Posted May 11, 2015 local TimeTable = {} local waitTime = 3000 -- 3 seconds local Blips = {} local details = {} local Entred = {} local Markers = { {522, 1986, -1478.1, 21.5, 17.500, "Sonix #1"}, -- Marker 1 {522, 1114, -1822, 33.5, 17.500,"Sonix #2"}, -- Marker 2 {522, 776.8, -1036, 39.5, 9000,"StantName Here"}, -- Marker 3 {522, 1313, -1163, 41, 7500,"StantName Here"}, -- Marker 4 {522, 1404, -806, 85, 7500,"StantName Here"}, -- Marker 5 {522, 775.7, -1060.5, 33.2, 5000,"StantName Here"}, -- Marker 6 } 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 ) details[HitMarker] = {v[1],v[5],v[6]} 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 Entred[hitElement] == source then outputChatBox("Sorry you can't enter the marker twice" , hitElement,255,0,0) return end theTable = details[source] if (theTable) then model, cash, name = details[source][1], details[source][2], details[source][3] if getElementModel ( vehicle ) == model then TimeTable[hitElement] = setTimer(StuntComplete, waitTime, 1, hitElement,source) setElementData ( hitElement, "entered.marker", true ) Entred[hitElement] = source else outputChatBox ( "You have entered in Stunt with wrong vehicle", hitElement, 255, 0, 0 ) end 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(cash)) outputChatBox ( "You have completed the Stunt and earned "..tonumber(cash).."$", player, 0, 255, 0 ) if isElement( Blips[marker] ) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) setMarkerColor (marker,0, 255, 0, 255 ) end local playerAccount = getPlayerAccount ( player ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local totalStunts = getAccountData ( playerAccount, "totalStunts" ) or 0 getAccountData( playerAccount, "totalStunts" , tonumber(totalStunts)+1) local blipColor = getBlipColor ( Blips[marker] ) setAccountData ( playerAccount, "Blip.Color", blipColor ) local markerColor = getMarkerColor ( marker ) setAccountData ( playerAccount, "Marker.Color", markerColor ) end end end end addEventHandler ( "onMarkerLeave", resourceRoot, function ( leaveElement ) if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then setElementData ( leaveElement, "entered.marker", false ) outputChatBox("You failed the Stunt!", leaveElement, 255, 0, 0) end end ) function stuntsFinished ( player ) if isElement(player) then local playerAccount = getPlayerAccount ( player ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local count = getAccountData( playerAccount, "totalStunts" ) or 0 outputChatBox( "You have finished "..tonumber(count).."/512 Stunts", player, 0, 255, 0) end end end addCommandHandler("fstunts", stuntsFinished) function savedStunts ( marker ) local playerAccount = getPlayerAccount(source) if (playerAccount) then local BlipColor = getAccountData ( playerAccount, "Blip.Color", true ) if (BlipColor) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) local MarkerColor = getAccountData ( playerAccount, "Marker.Color", true ) if (MarkerColor) then setMarkerColor ( marker, 0, 255, 0, 255 ) end end end end addEventHandler ( "onResourceStart", resourceRoot, savedStunts ) Link to comment
Walid Posted May 11, 2015 Share Posted May 11, 2015 Try this untested. local TimeTable = {} local waitTime = 3000 -- 3 seconds local Blips = {} local details = {} local Entred = {} local Markers = { {522, 1986, -1478.1, 21.5, 17.500, "Sonix #1"}, -- Marker 1 {522, 1114, -1822, 33.5, 17.500,"Sonix #2"}, -- Marker 2 {522, 776.8, -1036, 39.5, 9000,"StantName Here"}, -- Marker 3 {522, 1313, -1163, 41, 7500,"StantName Here"}, -- Marker 4 {522, 1404, -806, 85, 7500,"StantName Here"}, -- Marker 5 {522, 775.7, -1060.5, 33.2, 5000,"StantName Here"}, -- Marker 6 } 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 ) details[HitMarker] = {v[1],v[5],v[6]} 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 Entred[hitElement] == source then outputChatBox("Sorry you can't enter the marker twice" , hitElement,255,0,0) return end local theTable = details[source] if (theTable) then local model, cash, name = details[source][1], details[source][2], details[source][3] if getElementModel ( vehicle ) == model then TimeTable[hitElement] = setTimer(StuntComplete, waitTime, 1, hitElement,source,cash,name) setElementData ( hitElement, "entered.marker", true ) Entred[hitElement] = source else outputChatBox ( "You have entered in Stunt with wrong vehicle", hitElement, 255, 0, 0 ) end end end end end end addEventHandler( "onMarkerHit", resourceRoot, allowedVehicles ) function StuntComplete (player,marker,cash,markerName) if isElement ( player ) then if getElementData ( player, "entered.marker" ) then givePlayerMoney ( player, tonumber(cash)) outputChatBox ( "You have completed the Stunt and earned "..tonumber(cash).."$", player, 0, 255, 0 ) if isElement( Blips[marker] ) then setBlipColor ( Blips[marker], 0, 255, 0, 255 ) setMarkerColor (marker,0, 255, 0, 255 ) end local playerAccount = getPlayerAccount ( player ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local totalStunts = getAccountData ( playerAccount, "totalStunts" ) or 0 local name = markerName local rb,gb,bb,ab = getBlipColor ( Blips[marker] ) local rm,gm,bm,am = getMarkerColor ( marker ) local Det = toJSON({name,rb,gb,bb,ab,rm,gm,bm,am}) setAccountData ( playerAccount, "Details", Det ) setAccountData( playerAccount, "totalStunts" , tonumber(totalStunts)+1) end end end end addEventHandler ( "onMarkerLeave", resourceRoot, function ( leaveElement ) if ( isElement ( leaveElement ) and getElementType ( leaveElement ) == "player" ) then setElementData ( leaveElement, "entered.marker", false ) outputChatBox("You failed the Stunt!", leaveElement, 255, 0, 0) end end ) function stuntsFinished ( player ) if isElement(player) then local playerAccount = getPlayerAccount ( player ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local count = getAccountData( playerAccount, "totalStunts" ) or 0 outputChatBox( "You have finished "..tonumber(count).."/512 Stunts", player, 0, 255, 0) end end end addCommandHandler("fstunts", stuntsFinished) function Load (_,cur) local Det = getAccountData(cur,"Details") if Det then local marName,rb,gb,bb,ab,rm,gm,bm,am = unpack( fromJSON(Det)) for i , mar in pairs (getElementsByType("marker")) do local theTable = details[mar] if (theTable) then local name = details[mar][3] if name == tostring(marName) then setMarkerColor (mar,tonumber(rm),tonumber(gm),tonumber(bm),tonumber(am)) end end end end end addEventHandler("onPlayerLogin",root,Load) Link to comment
LasHa Posted May 11, 2015 Author Share Posted May 11, 2015 didn't save after restart script. nor colors neither this twice entered. 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