Elmatus Posted March 26, 2015 Posted March 26, 2015 Hi, I'll appreciate any help, and thanks I have a funny scrit that throws objects and when they impact, they make an explosion. The problem is that with the explosion, I writed destroyElement(shells.dildos.obj[shells.dildos.shotCount]) But this gives me an error in console: Bad argumenet @'destroyElement' [Expexted element at argument 1, got nil] I noticed that if I change the object before moving it, I can change the alpha and all, but after it, i can't And in both cases I can't destroy the object. Here is my code: function DildoShot ( theShooter, weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) -- Calculate distance for object speed shooterX, shooterY, shooterZ = getElementPosition (theShooter) targetDistance = getDistanceBetweenPoints3D ( shooterX, shooterY, shooterZ, hitX, hitY, hitZ ) local startX, startY, startZ = getPointInFrontOfPlayer(theShooter, 1.5 ) local rx,ry,rz = math.random(360), math.random(360), math.random(360) startZ = startZ - 0.5 if isPedInVehicle(theShooter) == true or isBadWeapon(weapon) == true then else -- does paint marker exist destroy if it did if shells.dildos.obj[shells.dildos.shotCount] ~= nil then if isElement(shells.dildos.obj[shells.dildos.shotCount]) then destroyElement(shells.dildos.obj[shells.dildos.shotCount]) end shells.dildos.obj[shells.dildos.shotCount] = nil end shells.dildos.obj[shells.dildos.shotCount] = createObject(321, startX, startY, startZ) setObjectScale ( shells.dildos.obj[shells.dildos.shotCount], 5) moveObject ( shells.dildos.obj[shells.dildos.shotCount], targetDistance*10, hitX, hitY, hitZ, rx, ry, rz ) if ( (targetDistance*10) < 50) then createExplosion ( hitX, hitY, hitZ, 2) else setTimer ( function() createExplosion ( hitX, hitY, hitZ, 2 ) end, targetDistance*10, 1 ) end -- check for limit if shells.dildos.shotCount > 20 then shells.dildos.shotCount = 1 else shells.dildos.shotCount = shells.dildos.shotCount + 1 end end -- local outString = string.format(“DildoShot Count: %d Element: %s", shells.dildos.shotCount, tostring(shells.dildos.obj[shells.dildos.shotCount])) -- outputDebugString( outString ) end
xXMADEXx Posted March 26, 2015 Posted March 26, 2015 Are you sure the error is being produced in this function? You checked if the object exists with isElement, so I don't see why there would be an error there.
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