Elmatus Posted April 1, 2015 Posted April 1, 2015 (edited) The event is triggered if I only send one argument, "theShooter". I added the argument "object", ensuring is not nil. But the server event is not triggered after that Any help is aprecciated Client (Relevant: line 34-40) function ObjectShot ( theShooter, weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) 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 object exist destroy if it did if shells.object.obj[shells.object.shotCount] ~= nil then if isElement(shells.object.obj[shells.object.shotCount]) then destroyElement(shells.object.obj[shells.object.shotCount]) end shells.object.obj[shells.object.shotCount] = nil end shells.object.obj[shells.object.shotCount] = createObject(321, startX, startY, startZ) setObjectScale ( shells.object.obj[shells.object.shotCount], 5) moveObject ( shells.object.obj[shells.object.shotCount], targetDistance*10, hitX, hitY, hitZ, rx, ry, rz ) outputChatBox ("Count: shells.object.obj" .. tostring(shells.object.shotCount) .. " objects") if (shells.object.obj[shells.object.shotCount]) then triggerServerEvent( "onSpecialEvent", resourceRoot, theShooter, shells.object.obj[shells.object.shotCount] ) outputChatBox ("Sending to server-side") else outputChatBox ("Object does not exist") end end end Server: addEvent ( "onSpecialEvent",true) function objectExplosion (theShooter, object) outputChatBox ( "Player " .. getPlayerName(theShooter) .. " triggered object shoot " ) if ( (targetDistance*10) < 50) then createExplosion ( hitX, hitY, hitZ, 2, theShooter) destroyElement (object) else setTimer ( function() createExplosion ( hitX, hitY, hitZ, 2, theShooter ) destroyElement(object) end, targetDistance*10, 1 ) end end addEventHandler ( "onSpecialEvent", getRootElement(), objectExplosion ) Edited April 2, 2015 by Guest
xXMADEXx Posted April 1, 2015 Posted April 1, 2015 You need to use addEvent for your own events. function objectExplosion (theShooter, object) outputChatBox ( "Player " .. getPlayerName(theShooter) .. " triggered object shoot " ) if ( (targetDistance*10) < 50) then createExplosion ( hitX, hitY, hitZ, 2, theShooter) destroyElement (object) else setTimer ( function() createExplosion ( hitX, hitY, hitZ, 2, theShooter ) destroyElement(object) end, targetDistance*10, 1 ) end end addEvent ( "onSpecialEvent", true ); addEventHandler ( "onSpecialEvent", getRootElement(), objectExplosion )
Elmatus Posted April 2, 2015 Author Posted April 2, 2015 You need to use addEvent for your own events. Oh sorry! I didn't paste it here, I already have it!
xXMADEXx Posted April 3, 2015 Posted April 3, 2015 Does "Sending server-side" output? Are there any debug errors (/debugscript 3)
Elmatus Posted April 6, 2015 Author Posted April 6, 2015 Yes it outputs. And no I already tried debugscript and no error is displayed. Like I said is only when I add other argument
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