Jump to content

[help] ColShape, problem with script


2kristof2

Recommended Posts

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

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
  
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...