Thivenin Posted August 3, 2013 Share Posted August 3, 2013 hai all, this is the third time I ask help in 3 day x) but as I always say I started lua only since thursday platformKillerofNoobObject = createObject ( 8661, -15, 95, 100 ) setElementInterior ( platformKillerofNoobObject, 901 ) function platformKillerofNoob ( hitElement, matchingDimension ) if ( getElementType ( hitElement ) == "Object" ) then targetPlayer = getPlayerFromName setElementHealth ( targetPlayer, - 100 ) end end addEventHandler ( "onPlayerHit", getRootElement(), platformKillerofNoob ) here is the script I want that the platform kill the player when he hit the object (platform) there is not any error, idk what is wrong ^^ and it's not killing the player Link to comment
denny199 Posted August 3, 2013 Share Posted August 3, 2013 Use https://wiki.multitheftauto.com/wiki/OnPlayerContact Link to comment
Thivenin Posted August 3, 2013 Author Share Posted August 3, 2013 platformKillerofNoobObject = createObject ( 8661, -15, 95, 100 ) setElementInterior ( platformKillerofNoobObject, 901 ) function platformKillerofNoob ( targetElem, matchingDimension ) if getElementType ( targetElem ) == "object" and getElementModel ( targetElem ) == 8661 then targetPlayer = getPlayerFromName setElementHealth ( targetPlayer, - 100 ) end end addEventHandler ( "onPlayerContact", getRootElement(), platformKillerofNoob ) I tried it, it saying on console when I hit the element Bad argument at 'getElementType' [Expected element at argument 1, got nil ] Link to comment
denny199 Posted August 3, 2013 Share Posted August 3, 2013 Thats because targetElem isn't a element. Parameterselement previousElement, element currentElement previousElement: The element player was standing on before. nil if none. currentElement: The new element that the player is standing on now. nil if none. also: SourceThe source of this event is the player who hit an element. So: platformKillerofNoobObject = createObject ( 8661, -15, 95, 100 ) setElementInterior ( platformKillerofNoobObject, 901 ) function platformKillerofNoob (prev, current) if current == platformKillerofNoobObject then killPed (source) end end addEventHandler ( "onPlayerContact", getRootElement(), platformKillerofNoob ) 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