maffius97 Posted August 28, 2016 Share Posted August 28, 2016 I have few "addEventHandler" inside function which I can trigger by command. Is it safe or will it cause server overload or something? Link to comment
KariiiM Posted August 28, 2016 Share Posted August 28, 2016 If you put addEventHandler inside a function it will be triggered untill the function is running Link to comment
idarrr Posted August 28, 2016 Share Posted August 28, 2016 It's safe, it will triggered once you entered the command. You can remove it with removeEventHandler. Link to comment
maffius97 Posted August 28, 2016 Author Share Posted August 28, 2016 Can you help me to move this 2 functions to clientside? addCommandHandler("sting", function(player) if (player) then local x,y,z = getElementPosition(player) local xr,yr,zr = getElementRotation(player) px, py, pz = getElementPosition(player) prot = getPedRotation(player) local offsetRot = math.rad(prot+90) local vx = px + 5 * math.cos(offsetRot) local vy = py + 5 * math.sin(offsetRot) local vx2 = px + 2 * math.cos(offsetRot) local vy2 = py + 2 * math.sin(offsetRot) local vx3 = px + 3 * math.cos(offsetRot) local vy3 = py + 3 * math.sin(offsetRot) local vx4 = px + 4 * math.cos(offsetRot) local vy4 = py + 4 * math.sin(offsetRot) local vz = pz + 2 local vrot = prot+180 spike = createObject(2892,vx,vy,z-0.95,0,0,vrot) setObjectScale(spike,0.7) local x2, y2, z2 = getElementPosition(spike) local blow = createColTube (x2, y2, z2-0.25, 0.9,2) local blow2 = createColTube (vx2, vy2, z2-0.25, 0.9,2) local blow3 = createColTube (vx3, vy3, z2-0.25, 0.9,2) local blow4 = createColTube (vx4, vy4, z2-0.25, 0.9,2) addEventHandler("onColShapeHit",blow, wylaczKola) addEventHandler("onColShapeHit",blow2,wylaczKola) addEventHandler("onColShapeHit",blow3,wylaczKola) addEventHandler("onColShapeHit",blow4,wylaczKola) end end) function wylaczKola (player) if player and getElementType(player) == "player" then if isPedInVehicle(player) then local pveh = getPedOccupiedVehicle(player) setVehicleWheelStates(pveh,1,1,1,1) end end end Link to comment
aka Blue Posted August 28, 2016 Share Posted August 28, 2016 For this you must use onClientColShapeHit. By the way, i think you can use this for server-side(not tested): local spike = { } local blows = { } addCommandHandler("sting", function(player) if (player) then local x,y,z = getElementPosition(player) local xr,yr,zr = getElementRotation(player) px, py, pz = getElementPosition(player) prot = getPedRotation(player) local offsetRot = math.rad(prot+90) local vx = px + 5 * math.cos(offsetRot) local vy = py + 5 * math.sin(offsetRot) local vx2 = px + 2 * math.cos(offsetRot) local vy2 = py + 2 * math.sin(offsetRot) local vx3 = px + 3 * math.cos(offsetRot) local vy3 = py + 3 * math.sin(offsetRot) local vx4 = px + 4 * math.cos(offsetRot) local vy4 = py + 4 * math.sin(offsetRot) local vz = pz + 2 local vrot = prot+180 spike[player] = createObject(2892,vx,vy,z-0.95,0,0,vrot) setObjectScale(spike,0.7) local x2, y2, z2 = getElementPosition(spike) local blows[player] = {createColTube (x2, y2, z2-0.25, 0.9,2), createColTube (vx2, vy2, z2-0.25, 0.9,2), createColTube (vx3, vy3, z2-0.25, 0.9,2), createColTube (vx4, vy4, z2-0.25, 0.9,2) } addEventHandler("onColShapeHit",blows[player], wylaczKola) end end) function wylaczKola (player) if player and getElementType(player) == "player" then if isPedInVehicle(player) then local pveh = getPedOccupiedVehicle(player) setVehicleWheelStates(pveh,1,1,1,1) end end end 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