Jump to content

[Detectar numero de Colpshare en un Area]


Narutimmy

Recommended Posts

Posted

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

mtasa://66.85.14.178:22003

350x20_FFFFFF_FFFFFF_000000_000000.png

Ts3: thezombiworld.com:7777

350x20_FFFFFF_FFFFFF_000000_000000.png

Posted
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 

mtasa://66.85.14.178:22003

350x20_FFFFFF_FFFFFF_000000_000000.png

Ts3: thezombiworld.com:7777

350x20_FFFFFF_FFFFFF_000000_000000.png

Posted
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

Currently developing for International Gaming Community - Join us!

Posted
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 xD

mtasa://66.85.14.178:22003

350x20_FFFFFF_FFFFFF_000000_000000.png

Ts3: thezombiworld.com:7777

350x20_FFFFFF_FFFFFF_000000_000000.png

Posted

eso use y no funciona solo que aqui no lo puse porque se me olvido xD

Comprueba que el evento esté siendo llamado como debería

Currently developing for International Gaming Community - Join us!

Posted
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.

Inactivo.

Posted
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

mtasa://66.85.14.178:22003

350x20_FFFFFF_FFFFFF_000000_000000.png

Ts3: thezombiworld.com:7777

350x20_FFFFFF_FFFFFF_000000_000000.png

Posted
Borralo.

amm si el problema es que solo quiero que se borren las que estan dentro de 1 area.

mtasa://66.85.14.178:22003

350x20_FFFFFF_FFFFFF_000000_000000.png

Ts3: thezombiworld.com:7777

350x20_FFFFFF_FFFFFF_000000_000000.png

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...