2kristof2 Posted September 11, 2014 Share Posted September 11, 2014 Hi made a script to kill player when he touch an object. I used col shape because Something like OnClientPedCollision doesn't exist. I'm not a good scripter but i hope you find the errors or tell me a better way to make it marker1 = createMarker(3486.606445, -1653.6806, 36.18, 'corona', 3, 0, 0, 0, 0)function MarkerHit (element) if (element == getLocalPlayer()) then if (getElementType(element) == "player") then if (source==marker1) then local ped = getLocalPlayer (player) local tube = createColTube ( 1, 1, 1, 10.0, 10.0 ) attachElements (tube , ped, 0, 0, 0 ) end end end end addEventHandler ( "onClientMarkerHit", getRootElement() ,MarkerHit) function killPlayer ( hitElement ) if ( source == getLocalPlayer ( player ) ) then if ( isElement ( hitElement ) and getElementModel ( hitElement ) == 8656) then setElementHealth ( source, 0 ) end end end addEventHandler ( "onClientColShapeHit", getRootElement(), killPlayer ) Regards, Krzysztof Link to comment
Castillo Posted September 11, 2014 Share Posted September 11, 2014 This doesn't really make much sense... Why do you attach a colshape to the player? I thought you wanted to do when he touched a object, he died? just place the colshape where the object is. Link to comment
2kristof2 Posted September 11, 2014 Author Share Posted September 11, 2014 The problem is that the object which he touch is moving.. Any other ideas? Link to comment
Castillo Posted September 11, 2014 Share Posted September 11, 2014 Attach the colshape to the object? Link to comment
2kristof2 Posted September 11, 2014 Author Share Posted September 11, 2014 ahh you are right, I'll try to do that. I'll write later if i find a new problem Link to comment
2kristof2 Posted September 11, 2014 Author Share Posted September 11, 2014 When i attached col shape with moving object the shape is not moving with the object when i hit col area everything works but it doesn't change a position. function movement() block = createObject(8656, 3475.7880859375, -1600.0648193359, 35.055699920654, 0, 0, 0) col = createColCuboid ( 3475.1223, -1615.3714, 33.8, 1.338, 30.8451, 2.485 ) attachElements (col, block, 0, 0, 0) MoveObject(1) end function MoveObject(point) moveObject(block, 6600, 3475.7880859375, -1600.0648193359, 35.055699920654, 0, 0, 360) setTimer(moveObject, 6600, 0, block, 6600, 3475.7880859375, -1600.0648193359, 35.055699920654, 0, 0, 360) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), movement) function onClientColShapeHit( theElement, matchingDimension ) if ( theElement == getLocalPlayer() ) then setElementHealth ( theElement, 0 ) end end addEventHandler("onClientColShapeHit",getRootElement(),onClientColShapeHit) Link to comment
Anubhav Posted September 11, 2014 Share Posted September 11, 2014 function movement() block = createObject(8656, 3475.7880859375, -1600.0648193359, 35.055699920654, 0, 0, 0) col = createColCuboid ( 3475.1223, -1615.3714, 33.8, 1.338, 30.8451, 2.485 ) attachElements (col, block, 0, 0, 0) MoveObject(1) end function MoveObject(point) moveObject(block, 6600, 3475.7880859375, -1600.0648193359, 35.055699920654, 0, 0, 360) setTimer(setElementRotation, 6600, 0, block, 0, 0, 360) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), movement) function onClientColShapeHit( theElement, matchingDimension ) if ( theElement == getLocalPlayer() ) then setElementHealth ( theElement, 0 ) end end addEventHandler("onClientColShapeHit",getRootElement(),onClientColShapeHit) Link to comment
darhal Posted September 12, 2014 Share Posted September 12, 2014 By adding the event handler using getRootElement() this will work for all colshape u should use this [lua] addEventHandler("onClientColShapeHit", col, onColShapeHit) [\lua] 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