JuanM27 Posted July 3, 2012 Posted July 3, 2012 hola que tal, estoy haciendo un script que al morir se cree un pickup pero cuando lo agarro, a los "30 segundos Aprox" (no lo conte), el pickup vuelve a aparecer. como puedo hacer para que una ves que lo usen no vuelva a aparecer. dejo el code aver si me pueden ayudar. function createArma(player) local x, y, z = getElementPosition(player); local x1, y1, x2, y2; x1 = (x-2)+(math.random()*4); y1 = (y-2)+(math.random()*4); x2 = (x-2)+(math.random()*4); y2 = (y-2)+(math.random()*4); local weapon = getPedWeapon ( player ) local ammo = getPedTotalAmmo ( player ) ammo = math.floor(ammo/10); takeWeapon ( player, weapon, ammo ) setElementData("Munision", ammo) setElementData("Armas", weapon) local Pick = createPickup(x2, y2, z, 2, weapon) end function ArmaPickupHit(player) local Municion = getElementData(source, "Munision"); local Arma = getElementData(source, "Armas"); if Arma then giveWeapon ( player, Arma, Municion ) destroyElement(Pick); end end function playerDied(ammo, attacker, weapon, bodypart) createArma(source); end addEventHandler("onPickupUse", getRootElement(), ArmaPickupHit); addEventHandler("onPlayerWasted", getRootElement(), playerDied);
Castillo Posted July 3, 2012 Posted July 3, 2012 Estas usando: math.random sin un numero. Ese no es el problema, en destroyElement pone 'source'.
JuanM27 Posted July 3, 2012 Author Posted July 3, 2012 listo lo solucione leyendo la wiki function ArmaPickupHit(player) --local Municion = getElementData(source, "Munision"); --local Arma = getElementData(source, "Armas"); -- if Arma then if getPickupType ( source ) ~= 2 then return end -- if the pickup is no weapon, stop local ammo = getPickupAmmo ( source ) -- get the amount of ammo local weapon = getPickupWeapon ( source ) -- get the weapon of the pickup giveWeapon ( player, weapon, ammo ) destroyElement(source); -- end end
Recommended Posts