z24d Posted September 16, 2015 Share Posted September 16, 2015 Hi guys i had a little problem on my code but i don't know what is it ? Code : aw1 = createMarker(-1694.87244, 950.35175, 24.89063,"cylinder",2,255,255,0,80) spawns = {} setElementData(resourceRoot,"map","no") setElementData(resourceRoot,"winMoney","0") addEventHandler("onMarkerHit", getRootElement(), function() if source == aw1 and checkDuel(source) == "prestart" and ( not checkExistPlrOnDuel(source) ) then online = countPlayersOnDerby() if tonumber(online)+1 < 32 then setData(source,"onCrossMap","yes") exports.killmessages:outputMessage("* - ( Derby ) : Please wait ..",source,255,255,0,true) setD(source) spawnOnMap(source) else exports.killmessages:outputMessage("* ≈- ( Derby ) : No place to you , come later,",source,0,255,0,true) end end end) function checkDuel(p) if tostring(getElementData(resourceRoot,"map")) == "yes" then exports.killmessages:outputMessage("* ≈ [ DerbySystem ] ≈",p,255,255,0,true) elseif tostring(getElementData(resourceRoot,"map")) == "no" then exports.killmessages:outputMessage("* ≈ - ( Derby ) : Please wait to start derby",p,255,255,0,true) end return tostring(getElementData(resourceRoot,"map")) end function checkExistPlrOnDuel(p) per = getElementData(p,"onCrossMap") if tostring(per) == "yes" then return true else return false end end function setData(element,key,vlr) setElementData(element,key,vlr) end function setD(element) setElementDimension(element,30) end function spawnOnMap(p) count = countPlayersOnDerby() spawned = "no" for i,data in pairs(spawns)do if tonumber(data.id) == tonumber(count) then spawned = "yes" v = createVehicle(411,data.x,data.y,data.z,data.rx,data.ry,data.rz) setElementDimension(v,30) setElementFrozen(v,true) setElementData(v,"creatorDerby","yes") break end end if spawned == "no" then randomS = math.random("1","32") for i,data in pairs(spawns)do if tonumber(data.id) == tonumber(randomS) then v = createVehicle(411,data.x,data.y,data.z,data.rx,data.ry,data.rz) setElementDimension(v,30) setElementFrozen(v,true) setElementData(v,"creatorDerby","yes") break end end end toggleControl(p,"enter_exit", false ) warpPedIntoVehicle(p,v) setCameraTarget(p,p) end debugscript: problem on line 63 and 64 Link to comment
DNL291 Posted September 17, 2015 Share Posted September 17, 2015 It's because a marker element is being passed to the function spawnOnMap. Link to comment
z24d Posted September 17, 2015 Author Share Posted September 17, 2015 ok fix it man i din't now how Link to comment
DNL291 Posted September 17, 2015 Share Posted September 17, 2015 ok fix it man i din't now how Have you at least tried to fix the problem I mentioned? Try this: aw1 = createMarker(-1694.87244, 950.35175, 24.89063,"cylinder",2,255,255,0,80) spawns = {} setElementData(resourceRoot,"map","no") setElementData(resourceRoot,"winMoney","0") addEventHandler("onMarkerHit", aw1, function(player, dim) if (getElementType(player) ~= "player") or not (dim) then return end if checkDuel(player) == "prestart" and ( not checkExistPlrOnDuel(player) ) then online = countPlayersOnDerby() if tonumber(online)+1 < 32 then setData(player,"onCrossMap","yes") exports.killmessages:outputMessage("* - ( Derby ) : Please wait ..",player,255,255,0,true) setD(player) spawnOnMap(player) else exports.killmessages:outputMessage("* ≈- ( Derby ) : No place to you , come later,",player,0,255,0,true) end end end) function checkDuel(p) if tostring(getElementData(resourceRoot,"map")) == "yes" then exports.killmessages:outputMessage("* ≈ [ DerbySystem ] ≈",p,255,255,0,true) elseif tostring(getElementData(resourceRoot,"map")) == "no" then exports.killmessages:outputMessage("* ≈ - ( Derby ) : Please wait to start derby",p,255,255,0,true) end return tostring(getElementData(resourceRoot,"map")) end function checkExistPlrOnDuel(p) per = getElementData(p,"onCrossMap") if tostring(per) == "yes" then return true else return false end end function setData(element,key,vlr) setElementData(element,key,vlr) end function setD(element) setElementDimension(element,30) end function spawnOnMap(p) count = countPlayersOnDerby() spawned = "no" for i,data in pairs(spawns)do if tonumber(data.id) == tonumber(count) then spawned = "yes" v = createVehicle(411,data.x,data.y,data.z,data.rx,data.ry,data.rz) setElementDimension(v,30) setElementFrozen(v,true) setElementData(v,"creatorDerby","yes") break end end if spawned == "no" then randomS = math.random("1","32") for i,data in pairs(spawns)do if tonumber(data.id) == tonumber(randomS) then v = createVehicle(411,data.x,data.y,data.z,data.rx,data.ry,data.rz) setElementDimension(v,30) setElementFrozen(v,true) setElementData(v,"creatorDerby","yes") break end end end toggleControl(p,"enter_exit", false ) warpPedIntoVehicle(p,v) setCameraTarget(p,p) end 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