Bierbuikje Posted May 9, 2011 Share Posted May 9, 2011 Hello all, I have a server and the errors keep coming with my new script. Right now I try a script where it should fire a heat seeking rocket at you in a 50.0 sphere from 354.43, 2028.49, 25.4141 if you are 30.0 in z-coords. When that is true it should fire a heat-seeking rocket on you (like happens in single player if you are flying above area 69). Right now I have a script. I made a colSphere with a radius of 50.0, I check if the player is in the colSpher. If it is true it should throw a heat seeking rocket at the player. Sad enough it doesn't work. The isn't created a projectile (at least I didn't regocnize it), and if it did wasn't fired on the player's vehicle (an airplane or helicopter in most cases). Does anyone know what the problem is in this script? The whole script is client-sided. function join() local Rzone1 = createColSphere(354.43, 2028.49, 22.4141, 50.0) end addEventHandler( "onClientResourceStart", getRootElement( ), join) function boem() local target = getPedOccupiedVehicle(player) local bom = createProjectile(getLocalPlayer(), 20, 354.43, 2028.49, 25.4141, 1.0, target) end function boemRadius(player, a) local x,y,z = getElementPosition(player) if (z >= 30) then if (boem_first) then setTimer(boem, 3000, 1) else local target = getPedOccupiedVehicle(player) local bom = createProjectile(player, 20, 354.43, 2028.49, 25.4141, 1.0, target, 0, 0, 0, 0, 0, 0) local boem_first = 1 end end end addEventHandler("onColShapeHit", Rzone1, boemRadius) Link to comment
Moderators Citizen Posted May 12, 2011 Moderators Share Posted May 12, 2011 local Rzone1 = createColSphere(354.43, 2028.49, 22.4141, 100.0) function boemRadius(player, a) local x,y,z = getElementPosition(player) if (z >= 30) then local target = getPedOccupiedVehicle(player) local bom = createProjectile(player, 20, 354.43, 2028.49, 25.4141, 1.0, target ) setTimer( boemRadius, 4000, 1, player ) end end addEventHandler("onClientColShapeHit", Rzone1, boemRadius) Works ( tested ) Link to comment
karlis Posted May 12, 2011 Share Posted May 12, 2011 slight improvement in citizen's code would be to not store x and y, as you dont need them, use this line local _,_,z = getelementPosition(player) Link to comment
Moderators Citizen Posted May 12, 2011 Moderators Share Posted May 12, 2011 We don't care abaout it because it's a local variables so when the function is ended, those variables are deleted. Link to comment
karlis Posted May 12, 2011 Share Posted May 12, 2011 i agree the performance improvement is minor, but then script doesn't even bother to make that variable, even local. we all should try to make our scripts as efficient as possible Link to comment
Castillo Posted August 31, 2011 Share Posted August 31, 2011 If you are going to copy something, at least learn how to make the meta.xml. https://wiki.multitheftauto.com/wiki/Meta.xml Link to comment
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