Narutimmy Posted January 6, 2016 Posted January 6, 2016 Hola buenas estoy haciendo un script sencillo para limitar el numero de tents en una area pero no me funciona hasta donde las cuenta en general funciona pero cuando uso para comprobar si esta dentro del area me da 0 addEventHandler('onColShapeHit', Area, function (pHitElement) Tents = 0 LimitCOL = 20 for _,col in ipairs(getElementsByType("colshape")) do tnt = getElementData(col, "tent") if tnt then if isElement(col) then Tents = Tents+1 end end end if ( getElementData ( pHitElement , "gang" ) == GangLider ) then outputChatBox("Numero de Tents: "..Tents.."/"..LimitCOL, pHitElement, 255, 0, 0) end if Tents >= LimitCOL then ----destroyElement (getElementData(col, "parent")) end end) PD: estoy seguro que el area si existe
UserToDelete Posted January 6, 2016 Posted January 6, 2016 La tent es una col? Como estas haciendo ese area? Y el orden en el script de hecha de menos
Narutimmy Posted January 6, 2016 Author Posted January 6, 2016 La tent es una col?Como estas haciendo ese area? Y el orden en el script de hecha de menos amm si osea las colpshare tienen una data que es "tent" y quiero que todas las colpshare con esa data dentro de un area sean afectadas, el area la creo asi : local Area = createColCuboid(2040.0518798828,2354.2321777344,0, 155, 90, 200) ----x,y,z,ancho,largo,altura
Tomas Posted January 6, 2016 Posted January 6, 2016 La tent es una col?Como estas haciendo ese area? Y el orden en el script de hecha de menos amm si osea las colpshare tienen una data que es "tent" y quiero que todas las colpshare con esa data dentro de un area sean afectadas, el area la creo asi : local Area = createColCuboid(2040.0518798828,2354.2321777344,0, 155, 90, 200) ----x,y,z,ancho,largo,altura Si mal no recuerdo había un problema con los eventos cuando la colshape estaba dentro de otra, desconozco si el problema persiste... Puedes usar esta useful isElementWithinAColShape
Narutimmy Posted January 6, 2016 Author Posted January 6, 2016 La tent es una col?Como estas haciendo ese area? Y el orden en el script de hecha de menos amm si osea las colpshare tienen una data que es "tent" y quiero que todas las colpshare con esa data dentro de un area sean afectadas, el area la creo asi : local Area = createColCuboid(2040.0518798828,2354.2321777344,0, 155, 90, 200) ----x,y,z,ancho,largo,altura Si mal no recuerdo había un problema con los eventos cuando la colshape estaba dentro de otra, desconozco si el problema persiste... Puedes usar esta useful isElementWithinAColShape eso use y no funciona solo que aqui no lo puse porque se me olvido
Tomas Posted January 6, 2016 Posted January 6, 2016 eso use y no funciona solo que aqui no lo puse porque se me olvido Comprueba que el evento esté siendo llamado como debería
aka Blue Posted January 6, 2016 Posted January 6, 2016 ¿Y si los insertas en una tabla y después compruebas desde la misma si están dentro?
Enargy, Posted January 6, 2016 Posted January 6, 2016 function onPlayerPitchATent (itemName) setElementData(source,itemName,getElementData(source,itemName)-1) setPedAnimation (source,"BOMBER","BOM_Plant",nil,false,false,nil,false) local source = source setTimer( function () local x,y,z = getElementPosition(source) local xr,yr,zr = getElementRotation(source) px, py, pz = getElementPosition(source) prot = getPedRotation(source) local offsetRot = math.rad(prot+90) local vx = px + 5 * math.cos(offsetRot) local vy = py + 5 * math.sin(offsetRot) local vz = pz + 2 local vrot = prot+180 tent = createObject(3243,vx,vy,z-1,0,0,vrot) setObjectScale(tent,1.3) tentCol = createColSphere(x,y,z,4) attachElements ( tentCol, tent, 0, 0, 0 ) setElementData(tentCol,"parent",tent) setElementData(tent,"parent",tentCol) setElementData(tentCol,"tent",true) setElementData(tentCol,"vehicle",true) setElementData(tentCol,"MAX_Slots",100) triggerClientEvent(source,"refreshInventoryManual",source) end,1500,1) end addEvent("onPlayerPitchATent",true) addEventHandler("onPlayerPitchATent",getRootElement(),onPlayerPitchATent) El dato es un elemento.
Narutimmy Posted January 7, 2016 Author Posted January 7, 2016 function onPlayerPitchATent (itemName) setElementData(source,itemName,getElementData(source,itemName)-1) setPedAnimation (source,"BOMBER","BOM_Plant",nil,false,false,nil,false) local source = source setTimer( function () local x,y,z = getElementPosition(source) local xr,yr,zr = getElementRotation(source) px, py, pz = getElementPosition(source) prot = getPedRotation(source) local offsetRot = math.rad(prot+90) local vx = px + 5 * math.cos(offsetRot) local vy = py + 5 * math.sin(offsetRot) local vz = pz + 2 local vrot = prot+180 tent = createObject(3243,vx,vy,z-1,0,0,vrot) setObjectScale(tent,1.3) tentCol = createColSphere(x,y,z,4) attachElements ( tentCol, tent, 0, 0, 0 ) setElementData(tentCol,"parent",tent) setElementData(tent,"parent",tentCol) setElementData(tentCol,"tent",true) setElementData(tentCol,"vehicle",true) setElementData(tentCol,"MAX_Slots",100) triggerClientEvent(source,"refreshInventoryManual",source) end,1500,1) end addEvent("onPlayerPitchATent",true) addEventHandler("onPlayerPitchATent",getRootElement(),onPlayerPitchATent) El dato es un elemento. si pero lo que quiero eliminar es la colshere que se le pega al objeto
Narutimmy Posted January 7, 2016 Author Posted January 7, 2016 Borralo. amm si el problema es que solo quiero que se borren las que estan dentro de 1 area.
Recommended Posts