maarten123 Posted April 29, 2010 Share Posted April 29, 2010 Hello everyone, I have a server with the TDMA gamemode and to my surprise do not you die if you jump into the water. So now I want a script that when you go swimming then you die I thought of as the swimming animation is played then you die but I can not really scripting in LUA, so would anyone here would like to help me. Regards Maarten123 Sorry for my bad english, I'm dutch Link to comment
Callum Posted April 29, 2010 Share Posted April 29, 2010 (As far as I know:) there is no event for as a player gets in/out water, so the only option would be a timer to check every player, and see if they're in water or not. Such as below; function makeTimer() setTimer(checkPlayers,5000,0) end addEventHandler("onResourceStart",getResourceRootElement(),makeTimer) function checkPlayers() for k, v in ipairs(getElementsByType("player")) do if (isElementInWater(v)) then killPed(v) end end end Link to comment
maarten123 Posted April 29, 2010 Author Share Posted April 29, 2010 Ok, thanks i will test it now , is this client side? Link to comment
maarten123 Posted April 29, 2010 Author Share Posted April 29, 2010 sorry everybody the problem is resolved but there is still a problem when I go dead in the water and then I get again gespawnt about 10x death and then does it suddenly Link to comment
Maccer. Posted April 29, 2010 Share Posted April 29, 2010 Why server-side? Try client-side. When you die, it gets sync, so there should be no problem. addEventHandler("onClientRender", getRootElement(), function () if(isElementInWater(getLocalPlayer())) then setElementHealth(getLocalPlayer(), 0) end end ) This is a snippet, but all you have to copy and paste this code somewhere in your code. 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