zuzu Posted August 2, 2014 Share Posted August 2, 2014 (edited) There are many kill/dead message scripts, but i couldnt find any that will output distance which from player was killed. Ive seen it on few servers, so i decided to make my own but somehow it doesent work.. Could someone take a look on it, and help me please addEventHandler ( "onPlayerWasted" , root, function ( _, killer ) x,y,z = getElementPosition ( source ) x1,y1,z1 = getElementPosition ( killer ) distance = getDistanceBetweenPoints3D ( x, y, z, x1, y1, z1 ) outputChatBox ( getPlayerName(source).." was killed by "..getPlayerName ( killer ), root, 255, 255, 255 ) outputChatBox ( "Distance: "..distance, root, 255, 255, 255 ) end) Edited August 3, 2014 by Guest Link to comment
Addlibs Posted August 2, 2014 Share Posted August 2, 2014 Any /debugscript 3 messages? Link to comment
Bonsai Posted August 3, 2014 Share Posted August 3, 2014 C'mon, this can't be so hard. Did you even include the script in the meta? Did you try some output of the coordinates? Link to comment
Tete omar Posted August 3, 2014 Share Posted August 3, 2014 Make sure it's on server-side. Link to comment
zuzu Posted August 3, 2014 Author Share Posted August 3, 2014 So this should work, right? Yes I'm total newb, but I know that onPlayerWasted is server side, and ofc how I should create meta's Link to comment
Addlibs Posted August 3, 2014 Share Posted August 3, 2014 https://wiki.multitheftauto.com/wiki/Meta.xml Link to comment
zuzu Posted August 3, 2014 Author Share Posted August 3, 2014 I heve used this code for meta and my script called kd_s.lua <meta> <info author="kev" type="script" name="KillDistance" version="1.0"/> <script src="kd_s.lua" type="server" /> </meta> So everything should be fine I think. Link to comment
Addlibs Posted August 3, 2014 Share Posted August 3, 2014 Are you sure you have started the resource? (Admin Panel >Resources or /start command) Link to comment
cheez3d Posted August 3, 2014 Share Posted August 3, 2014 addEventHandler("onPlayerWasted",root,function(_,killer) if killer and getElementType(killer) == "player" then local VictimX,VictimY,VictimZ = getElementPosition(source); local KillerX,KillerY,KillerZ = getElementPosition(killer); local Distance = getDistanceBetweenPoints3D(VictimX,VictimY,VictimZ,KillerX,KillerY,KillerZ); outputChatBox(getPlayerName(source).." was killed by "..getPlayerName(killer).." from a distance of "..tostring(Distance).."!",root,255,255,255); end; end); Link to comment
zuzu Posted August 3, 2014 Author Share Posted August 3, 2014 @ MrTasty Not that newbie:p @ Cheez3D Thanks for your exmaple! Anyway its still wont work but I found where the problem is. My server is running DayZ gamemode, and when I terminate it then distance appeared and your script as same as mine works perfect. So my next problem is how to adapt it for DayZ... I wonder why all killmessages and other stuff works there, while distance dont. Link to comment
zuzu Posted August 3, 2014 Author Share Posted August 3, 2014 addEventHandler("onPlayerWasted",root,function(_,killer) if killer and getElementType(killer) == "player" then local VictimX,VictimY,VictimZ = getElementPosition(source); local KillerX,KillerY,KillerZ = getElementPosition(killer); local Distance = getDistanceBetweenPoints3D(VictimX,VictimY,VictimZ,KillerX,KillerY,KillerZ); outputChatBox(getPlayerName(source).." was killed by "..getPlayerName(killer).." from a distance of "..tostring(Distance).."!",root,255,255,255); end; end); Ok I manage how make it work, thanks for help everyone. One more little question, how can I output short distance value like "was killed from 200m" except of "was killed from 200.23472423108m" ? Link to comment
Et-win Posted August 3, 2014 Share Posted August 3, 2014 http://www.lua.org/manual/5.1/manual.ht ... math.floor Or: http://www.lua.org/manual/5.1/manual.html#pdf-math.ceil Link to comment
Max+ Posted August 3, 2014 Share Posted August 3, 2014 Distance = string.format ( "%.f" , Distance ) ---------------------------------- distance=pos2-pos1 --use getDistanceBetweenPoints if 2/3D needed currentDistance=pos2-yourPos --use getDistanceBetweenPoints if 2/3D needed precents=math.min(math.max(math.abs(currentDistance/distance*100),0),100) ---------------------------------------- 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