adamb Posted May 22, 2013 Posted May 22, 2013 for k,v in ipairs(getElementsByType("player")) do bindKey(v, "o", "down", "pullover") end local circlearea = createColCircle ( 0, 0, 10 ) function ColShapeHit ( su, matchingDimension ) local detection = isElementWithinColShape ( su, circlearea ) if detection then if ( getElementType ( su ) == "vehicle" ) then setVehicleEngineState ( su, false ) end end end addCommandHandler("pullover", ColShapeHit) Basically supposed to stop the NPC ped in the colsphere, doesn't work for some reason, can anyone look thru it and correct it?
Moderators IIYAMA Posted May 23, 2013 Moderators Posted May 23, 2013 Because "su" is a player and not a vehicle.
Moderators IIYAMA Posted May 23, 2013 Moderators Posted May 23, 2013 try this: for k,v in pairs(getElementsByType("player")) do bindKey(v, "o", "down", "pullover") end local circlearea = createColCircle ( 0, 0, 10 ) function ColShapeHit ( su, command) local vehicle =getPedOccupiedVehicle ( su ) if isElementWithinColShape ( vehicle, circlearea ) and getElementType ( vehicle ) == "vehicle" then setVehicleEngineState ( vehicle, false ) end end addCommandHandler("pullover", ColShapeHit)
Moderators IIYAMA Posted May 23, 2013 Moderators Posted May 23, 2013 btw you can remove this one: and getElementType ( vehicle ) == "vehicle" not required in the script, (sorry)
adamb Posted May 23, 2013 Author Posted May 23, 2013 Got an error @ Line 9, expected element, got boolean.
Schlammy Posted May 23, 2013 Posted May 23, 2013 local circlearea = createColCircle ( 0, 0, 10 ) function ColShapeHit ( hitElement, matchingDimension ) local detection = isElementWithinColShape ( hitElement, circlearea ) if (detection and (getElementType(hitElement) == "vehicle")) then setVehicleEngineState (hitElement, false) end end addEventHandler("onColShapeHit", circlearea, ColShapeHit) It will not work with Command handler becouse the parameters are hitElement and the dimension. CommandHandler givs player, commandname and rest. And a Player is not a vehicle. Use onColShapeHit or make 2 functions: local circlearea = createColCircle ( 0, 0, 10 ) function ColShapeHit ( hitElement, matchingDimension ) local detection = isElementWithinColShape ( hitElement, circlearea ) if (detection and (getElementType(hitElement) == "vehicle")) then setVehicleEngineState (hitElement, false) end end addEventHandler("onColShapeHit", circlearea, ColShapeHit) function triggerEventColShapeHit(player) local pVeh = getPedOccupiedVehicle ( player ) local curDimen = getElementDimension(player) if (pVeh and curDimen) then triggerEvent("onColShapeHit", player, pVeh, curDimen) else outputChatBox("Vehicle not found! Enter a vehicle", player, 255, 0, 0) end end addCommandHandler("tColshape", triggerEventColShapeHit) Not tested at all but after debugging it should work like this
Moderators IIYAMA Posted May 23, 2013 Moderators Posted May 23, 2013 for k,v in pairs(getElementsByType("player")) do bindKey(v, "o", "down", "pullover") end local circlearea = createColCircle ( 0, 0, 10 ) addCommandHandler("pullover", function ( su, command) local vehicle =getPedOccupiedVehicle ( su ) if vehicle and isElementWithinColShape ( vehicle, circlearea ) then setVehicleEngineState ( vehicle, false ) end end)
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