THASMOG Posted March 31, 2014 Share Posted March 31, 2014 (edited) WORKS !! Edited April 5, 2014 by Guest Link to comment
Mr_Moose Posted April 1, 2014 Share Posted April 1, 2014 Line 14, 16, 17, 18, 19: getLocalPlayer is a function, use one of these instead: getLocalPlayer() -- Function to get local player localPlayer -- Predefined variable of local player The source element of onClientVehicleDamage is the vehicle that has been damaged so you don't need line 13 unless if you want to compare it with the source element. Use /debugscript 3 and check the server console for more information about these issues. Link to comment
THASMOG Posted April 1, 2014 Author Share Posted April 1, 2014 Thanks it works kinda. But it's not perfect. Now both players get text."Your car received damage! Do not log out in 10 seconds or you will die!" I'd like to only have ped in car. EDIT: Actually it's better that way. I just changed text to "You are in combat! Don't log out or you will die! if i change player's damage from source to local player does it work same way then ?. Sorry i can't test right now only 2 plaeyers in my server. Link to comment
THASMOG Posted April 2, 2014 Author Share Posted April 2, 2014 If i try to edit it i brake it more. Link to comment
THASMOG Posted April 2, 2014 Author Share Posted April 2, 2014 (edited) Miss post... Edited April 2, 2014 by Guest Link to comment
THASMOG Posted April 2, 2014 Author Share Posted April 2, 2014 (edited) WORKS !! Edited April 5, 2014 by Guest Link to comment
Castillo Posted April 2, 2014 Share Posted April 2, 2014 What do you mean by "still nothing"? what is the problem? Link to comment
THASMOG Posted April 2, 2014 Author Share Posted April 2, 2014 (edited) WORKS !! Edited April 5, 2014 by Guest Link to comment
Moderators IIYAMA Posted April 3, 2014 Moderators Share Posted April 3, 2014 Only the client version can get this information. Also this event can be cancelled. "onClientVehicleDamage" local lastDamageTime = 0 function VehicleGetDamageDayZ ( attacker, weapon, loss, x, y, z, tyre ) local vehicle = getPedOccupiedVehicle( localPlayer ) local timeNow = getTickCount() if timeNow > lastDamageTime and source == vehicle and not getElementData ( localPlayer, "tempodosexo" ) then if weapon and weapon > 1 and attacker and getElementType(attacker) == "player" then lastDamageTime = timeNow+300 -- can only be executed every 300 ms. setTimer (deslogger, 10000, 1, localPlayer) setTimer ( setElementData, 10000, 1, localPlayer, "tempodosexo", false ) setElementData ( localPlayer, "tempodosexo", true ) outputChatBox ( "Your car received damage! Do not log out in 10 seconds or you will die!", localPlayer, 255, 5, 0 ) end end end You used getLocalPlayer instead of getLocalPlayer() or localPlayer. Link to comment
THASMOG Posted April 3, 2014 Author Share Posted April 3, 2014 Thanks very much, i test it. I didn't know that there is difference with getLocalPlayer or getLocalPlayer() Link to comment
Moderators IIYAMA Posted April 3, 2014 Moderators Share Posted April 3, 2014 getLocalPlayer -- this is a function getLocalPlayer() -- this is calling the function(using the function) localPlayer -- this is the result of the function, but predefined. Link to comment
Moderators IIYAMA Posted April 3, 2014 Moderators Share Posted April 3, 2014 outputChatBox ( "Your car received damage! Do not log out in 10 seconds or you will die!", [color=#FF0000]localPlayer[/color], 255, 5, 0 ) outputChatBox ( "Your car received damage! Do not log out in 10 seconds or you will die!", 255, 5, 0 ) You don't have to send it to anybody at clientside, since you are the client. Link to comment
THASMOG Posted April 3, 2014 Author Share Posted April 3, 2014 Still nothing, I tryed to remove if weapon and weapon stuff still wont work. Link to comment
.:HyPeX:. Posted April 3, 2014 Share Posted April 3, 2014 "onClientVehicleDamage" has those parameters, and i'm not sure that if supports 3 and , It does support multiple ORs, but idk if ands, also in my experience, redefine localPlayer = getLocalPlayer() just in case. Post the script. Link to comment
Moderators IIYAMA Posted April 4, 2014 Moderators Share Posted April 4, 2014 Still nothing, I tryed to remove if weapon and weapon stuff still wont work. Debug your code with outputDebugString, if nobody can see why it doesn't work, you should make it visible. @.:HyPeX:.also in my experience, redefine localPlayer = getLocalPlayer() just in case. You will make more trouble then fixing it, by redefine predefined variables. and if you aren't sure they do work well, you can compare them with the function that returns that value. if localPlayer == getLocalPlayer() then and you will be fine. @THASMOG I hope you can do that next time by yourself, instead of saying that you can't find your problem. local lastDamageTime = 0 function VehicleGetDamageDayZ ( attacker, weapon, loss, x, y, z, tyre ) outputDebugString("addEventHandler works") local vehicle = getPedOccupiedVehicle( localPlayer ) local timeNow = getTickCount() if timeNow > lastDamageTime and source == vehicle and not getElementData ( localPlayer, "tempodosexo" ) then outputDebugString("tickCount system works, vehicle check works, elementdata check works") outputDebugString("weapon: " .. tostring(weapon) .. ", attacker: " .. tostring(attacker).. ", element type " .. tostring(attacker and getElementType(attacker))) if weapon and weapon > 1 and attacker and getElementType(attacker) == "player" then outputDebugString("weapon check works,attacker exist, element type is a player.") lastDamageTime = timeNow+300 -- can only be executed every 300 ms. setTimer (deslogger, 10000, 1, localPlayer) setTimer ( setElementData, 10000, 1, localPlayer, "tempodosexo", false ) setElementData ( localPlayer, "tempodosexo", true ) outputChatBox ( "Your car received damage! Do not log out in 10 seconds or you will die!", localPlayer, 255, 5, 0 ) end end end addEventHandler ( "onClientVehicleDamage", root, VehicleGetDamageDayZ ) outputDebugString("code loaded!") Link to comment
THASMOG Posted April 5, 2014 Author Share Posted April 5, 2014 Can i buy u a beer ? It won't work but u helped me to learn something. I try to fix something now myself EDIT: IT WORKS !! I WANNA BUY U TWO BEERS ! 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