Hallo,
ich habe mir gerade eine Silvesterpistole gebastelt, im Prinzip funktioniert das auch ganz gut, außer dass die Objekte nicht gelöscht und auch nicht unsichtbar gemacht werden.
Code:
clientside:
Code
function startsilvester ( weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement )
if ( weapon == 24 ) then
local px, py, pz = getElementPosition(getLocalPlayer())
triggerServerEvent("onStartSilvester", getLocalPlayer(), px, py, pz+2, hitX, hitY, hitZ )
end
end
addEventHandler("onClientPlayerWeaponFire", getRootElement(), startsilvester )
serverside:
Code
addEvent("onStartSilvester", true )
local object = nil
local time = 5000
local light1 = nil
local light2 = nil
local light3 = nil
local mo1 = nil
local mo2 = nil
local mo3 = nil
function continueSilvester ( px, py, pz, hitX, hitY, hitZ )
object = createObject (2780, px, py, pz )
setElementAlpha(object, 0)
moveObject(object, time, hitX, hitY, hitZ)
setTimer( function()
destroyElement(object)
light1 = createMarker(hitX,hitY,hitZ, "corona", 2, math.random(0,255), math.random(0,255), math.random(0,255), math.random(180,255) )
light2 = createMarker(hitX,hitY,hitZ, "corona", 2, math.random(0,255), math.random(0,255), math.random(0,255), math.random(180,255) )
light3 = createMarker(hitX,hitY,hitZ, "corona", 2, math.random(0,255), math.random(0,255), math.random(0,255), math.random(180,255) )
mo1 = createObject(1672, hitX, hitY, hitZ)
mo2 = createObject(1672, hitX, hitY, hitZ)
mo3 = createObject(1672, hitX, hitY, hitZ)
setElementAlpha(mo1, 0)
setElementAlpha(mo2, 0)
setElementAlpha(mo3, 0)
attachElements(light1, mo1)
attachElements(light2, mo2)
attachElements(light3, mo3)
moveObject(mo1, math.random(4000,6000), hitX+math.random(-10, 10), hitY+math.random(-10, 10), hitZ+math.random(0, 20) )
moveObject(mo2, math.random(4000,6000), hitX+math.random(-10, 10), hitY+math.random(-10, 10), hitZ+math.random(0, 20) )
moveObject(mo3, math.random(4000,6000), hitX+math.random(-10, 10), hitY+math.random(-10, 10), hitZ+math.random(0, 20) )
setTimer(function()
destroyElement(light1)
destroyElement(light2)
destroyElement(light3)
destroyElement(mo1)
destroyElement(mo2)
destroyElement(mo3)
end, 6000, 1 )
end, time, 1 )
end
addEventHandler("onStartSilvester", getRootElement(), continueSilvester )
Alles anzeigen
Warnings: Bad element pointer @ 'destroyElement'(1)
Gruß Justus