BenceDev Posted March 15, 2022 Share Posted March 15, 2022 (edited) Hi, i created small shop system with marker, when i hit the marker i got error. ERROR: [SafeZoneSystems]\an_safezoneVehShop\server.lua:90: attempt to compare nubmer with nil Code: function spawnItemsWhenStart ( name ) createPed(287, 1544.75390625, -1675.2421875, 13.55902671814, 90) end addEventHandler ( "onResourceStart", getResourceRootElement(), spawnItemsWhenStart ) function spawnMarkerFunction() --local deleteMarker = createMarker(1529.248046875, -1685.935546875, 4.5, "cylinder", 3, 135, 15, 15, 0) setElementInterior(spawnMarker, 0) setElementDimension(spawnMarker, 0) addEventHandler("onMarkerHit",spawnMarker,onSpawnMarkerHit) end spawnHeliMarker = createMarker (1930.0791015625, -2626.673828125, 12.5, "cylinder", 3, 122, 193, 67, 70) function onSpawnHeliMarkerHit (thePlayer, hitElement, heliSpawnPos) if (money > 10000) or (isElement(hitElement) and getElementType(hitElement) == 'player') and tonumber(getElementData(hitElement, money)) then -- if money is more than 1000 local money = getPlayerMoney(hitElement) outputChatBox("You purchased a blackhawk!", hitElement, 0, 255, 0) takePlayerMoney(hitElement, 10000) local heliSpawnPos={ {1967.8515625, -2636.1103515625, 13.546875}, {1998.966796875, -2636.849609375, 13.546875}, } local theVeh = getPedOccupiedVehicle(hitElement) if ( theVeh ) then if ( VehiclesTable[hitElement] ) then VehiclesTable[hitElement] = nil end return end local x, y, z = getElementPosition (hitElement) local rotX, rotY, rotZ = getElementRotation (hitElement) local random = math.random(1,#heliSpawnPos) VehiclesTable[hitElement] = createVehicle (563, heliSpawnPos[random][1], heliSpawnPos[random][2], heliSpawnPos[random][3]+2) setElementRotation (VehiclesTable[hitElement], rotX, rotY, 0) warpPedIntoVehicle (hitElement, VehiclesTable[hitElement]) elseif(money < 0) then outputChatBox("You don't have enough money!", thePlayer, 255, 0, 0) end end addEventHandler("onMarkerHit", spawnHeliMarker, onSpawnHeliMarkerHit) i dont figure what is this error means. Edited March 15, 2022 by SphinxDev Link to comment
βurak Posted March 15, 2022 Share Posted March 15, 2022 (edited) there is an error here money must be a string tonumber(getElementData(hitElement, money)) change it like this tonumber(getElementData(hitElement, "money")) Edited March 15, 2022 by Burak5312 Link to comment
BenceDev Posted March 15, 2022 Author Share Posted March 15, 2022 it doesn't work, same error Link to comment
βurak Posted March 15, 2022 Share Posted March 15, 2022 (edited) What data do you want to get with getElementData?, can you show line 90? by the way this line should be above the if code local money = getPlayerMoney(hitElement) Edited March 15, 2022 by Burak5312 Link to comment
BenceDev Posted March 15, 2022 Author Share Posted March 15, 2022 if (money > 10000) or (isElement(hitElement) and getElementType(hitElement) == 'player') then -- Line 90 local money = getPlayerMoney(hitElement) -- Line 91 Link to comment
βurak Posted March 15, 2022 Share Posted March 15, 2022 function spawnItemsWhenStart ( name ) createPed(287, 1544.75390625, -1675.2421875, 13.55902671814, 90) end addEventHandler ( "onResourceStart", getResourceRootElement(), spawnItemsWhenStart ) function spawnMarkerFunction() --local deleteMarker = createMarker(1529.248046875, -1685.935546875, 4.5, "cylinder", 3, 135, 15, 15, 0) setElementInterior(spawnMarker, 0) setElementDimension(spawnMarker, 0) addEventHandler("onMarkerHit",spawnMarker,onSpawnMarkerHit) end spawnHeliMarker = createMarker (1930.0791015625, -2626.673828125, 12.5, "cylinder", 3, 122, 193, 67, 70) function onSpawnHeliMarkerHit (thePlayer, hitElement, heliSpawnPos) if(getElementType(hitElement) ~= "player") then --If hitElement is not a player, go no further return end local money = getPlayerMoney(hitElement) if (money < 10000) then --if the player's money is less than 10000 go no further outputChatBox("You don't have enough money!", hitElement, 255, 0, 0) return end outputChatBox("You purchased a blackhawk!", hitElement, 0, 255, 0) takePlayerMoney(hitElement, 10000) local heliSpawnPos={ {1967.8515625, -2636.1103515625, 13.546875}, {1998.966796875, -2636.849609375, 13.546875}, } local theVeh = getPedOccupiedVehicle(hitElement) if ( theVeh ) then if ( VehiclesTable[hitElement] ) then VehiclesTable[hitElement] = nil end return end local x, y, z = getElementPosition (hitElement) local rotX, rotY, rotZ = getElementRotation (hitElement) local random = math.random(1,#heliSpawnPos) VehiclesTable[hitElement] = createVehicle (563, heliSpawnPos[random][1], heliSpawnPos[random][2], heliSpawnPos[random][3]+2) setElementRotation (VehiclesTable[hitElement], rotX, rotY, 0) warpPedIntoVehicle (hitElement, VehiclesTable[hitElement]) end addEventHandler("onMarkerHit", spawnHeliMarker, onSpawnHeliMarkerHit) can you try this? You didn't say what getElementData means so I deleted that Link to comment
BenceDev Posted March 15, 2022 Author Share Posted March 15, 2022 5 minutes ago, Burak5312 said: function spawnItemsWhenStart ( name ) createPed(287, 1544.75390625, -1675.2421875, 13.55902671814, 90) end addEventHandler ( "onResourceStart", getResourceRootElement(), spawnItemsWhenStart ) function spawnMarkerFunction() --local deleteMarker = createMarker(1529.248046875, -1685.935546875, 4.5, "cylinder", 3, 135, 15, 15, 0) setElementInterior(spawnMarker, 0) setElementDimension(spawnMarker, 0) addEventHandler("onMarkerHit",spawnMarker,onSpawnMarkerHit) end spawnHeliMarker = createMarker (1930.0791015625, -2626.673828125, 12.5, "cylinder", 3, 122, 193, 67, 70) function onSpawnHeliMarkerHit (thePlayer, hitElement, heliSpawnPos) if(getElementType(hitElement) ~= "player") then --If hitElement is not a player, go no further return end local money = getPlayerMoney(hitElement) if (money < 10000) then --if the player's money is less than 10000 go no further outputChatBox("You don't have enough money!", hitElement, 255, 0, 0) return end outputChatBox("You purchased a blackhawk!", hitElement, 0, 255, 0) takePlayerMoney(hitElement, 10000) local heliSpawnPos={ {1967.8515625, -2636.1103515625, 13.546875}, {1998.966796875, -2636.849609375, 13.546875}, } local theVeh = getPedOccupiedVehicle(hitElement) if ( theVeh ) then if ( VehiclesTable[hitElement] ) then VehiclesTable[hitElement] = nil end return end local x, y, z = getElementPosition (hitElement) local rotX, rotY, rotZ = getElementRotation (hitElement) local random = math.random(1,#heliSpawnPos) VehiclesTable[hitElement] = createVehicle (563, heliSpawnPos[random][1], heliSpawnPos[random][2], heliSpawnPos[random][3]+2) setElementRotation (VehiclesTable[hitElement], rotX, rotY, 0) warpPedIntoVehicle (hitElement, VehiclesTable[hitElement]) end addEventHandler("onMarkerHit", spawnHeliMarker, onSpawnHeliMarkerHit) can you try this? You didn't say what getElementData means so I deleted that i try it, but i got WARNING: WARNING: [SafeZoneSystems]\an_safezoneVehShop\server.lua: Bad argument @ 'getElementType' [Expected element at argument 1, got boolean] Link to comment
βurak Posted March 15, 2022 Share Posted March 15, 2022 (edited) function onSpawnHeliMarkerHit(hitElement, matchingDimension) change function parameters like this Edited March 15, 2022 by Burak5312 Link to comment
BenceDev Posted March 15, 2022 Author Share Posted March 15, 2022 It worked THX @Burak5312 Link to comment
βurak Posted March 15, 2022 Share Posted March 15, 2022 (edited) You're welcome Edited March 15, 2022 by Burak5312 1 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