Bean666 Posted February 8, 2021 Posted February 8, 2021 Hello in my server when I tested with other player, time is different for each of us, how to have the time synced with each other?
Tekken Posted February 8, 2021 Posted February 8, 2021 You set time server side? getRealTime() — get real time of the server; setTime() — set in game time comparing with real time of the server!
Bean666 Posted February 8, 2021 Author Posted February 8, 2021 (edited) 7 minutes ago, Tekken said: You set time server side? just did it, thanks, though it's not super synced, when player reconnects, his time is either 3-6 seconds late or ahead of mine, though not a big deal. Edited February 8, 2021 by Shaman123
Hydra Posted February 8, 2021 Posted February 8, 2021 16 minutes ago, Tekken said: You set time server side? getRealTime() — get real time of the server; setTime() — set in game time comparing with real time of the server! isn't getRealTime() used for getting the current time from player computer?
Tekken Posted February 8, 2021 Posted February 8, 2021 3 minutes ago, Hydra said: isn't getRealTime() used for getting the current time from player computer? If used client side
Bean666 Posted February 8, 2021 Author Posted February 8, 2021 (edited) okay okay chill out guys, it's fine, its just a few seconds away anyway, i have one last question, this is out of topic but how do i cancel this event if the user has armor? addEvent "onPlayerHeadshot" addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 then local result = triggerEvent("onPlayerHeadshot", source, attacker, weapon, loss) if result == true then setElementHealth(source, getElementHealth(source)-20) if weapon == 34 then setElementHealth(source, getElementHealth(source)-100) end end end end ) I tried with getPedArmor but it didn't work, guess I used it wrong. If so please tell me Edited February 8, 2021 by Shaman123
Tekken Posted February 8, 2021 Posted February 8, 2021 (edited) If getPedArmor(source) > 0 then When in doubt always check wiki GetPedArmor returns a float that can be from 0 to 100 of i recall correctly Edited February 8, 2021 by Tekken 1
Moderators IIYAMA Posted February 8, 2021 Moderators Posted February 8, 2021 (edited) 9 minutes ago, Shaman123 said: I tried with getPedArmor but it didn't work You probably did it correctly, the only problem is that this event cannot be cancelled. Since the damage has already happened on clientside a while(few milliseconds) ago. This event represents a reflection of the past, not the moment the player got damaged. The now moment: onClientPlayerDamage Edited February 8, 2021 by IIYAMA 2
Bean666 Posted February 8, 2021 Author Posted February 8, 2021 (edited) okay thankss Edited February 8, 2021 by Shaman123
Tekken Posted February 8, 2021 Posted February 8, 2021 2 minutes ago, IIYAMA said: You probably did it correctly, the only problem is that this event cannot be cancelled. Since the damage has already happened on clientside a while(few milliseconds) ago. This event represents a reflection of the past, not the moment the player got damaged. Oh yes forgot server side onDamage can’t be canceled! 2
Moderators IIYAMA Posted February 8, 2021 Moderators Posted February 8, 2021 Just now, Shaman123 said: damn, is there any way or functions that would make this event detect if player has armor? Yes, @Tekken just gave you that one a few seconds ago. 1
Bean666 Posted February 8, 2021 Author Posted February 8, 2021 (edited) 15 minutes ago, IIYAMA said: Yes, @Tekken just gave you that one a few seconds ago. yes, i didn't see his comment before I replied, thanks y'all 15 minutes ago, IIYAMA said: Yes, @Tekken just gave you that one a few seconds ago. @IIYAMA error is : line 6: = expected near getPedArmor() it gives an error even though I put the = , and <= 0 means if less than 0 right? addEvent "onPlayerHeadshot" addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 then If getPedArmor(source) <= 0 then local result = triggerEvent("onPlayerHeadshot", source, attacker, weapon, loss) if result == true then setElementHealth(source, getElementHealth(source)-20) if weapon == 34 then setElementHealth(source, getElementHealth(source)-100) end end end end ) 12 minutes ago, Shaman123 said: yes, i didn't see his comment before I replied, thanks y'all @IIYAMA error is : line 6: = expected near getPedArmor() it gives an error even though I put the = , and <= 0 means if less than 0 right? addEvent "onPlayerHeadshot" addEventHandler("onPlayerDamage", getRootElement(), function (attacker, weapon, bodypart, loss) if bodypart == 9 then If getPedArmor(source) <= 0 then local result = triggerEvent("onPlayerHeadshot", source, attacker, weapon, loss) if result == true then setElementHealth(source, getElementHealth(source)-20) if weapon == 34 then setElementHealth(source, getElementHealth(source)-100) end end end end ) check my edit: @IIYAMA @Tekken Edited February 8, 2021 by Shaman123 1
Tekken Posted February 8, 2021 Posted February 8, 2021 You should put > 0 as it can’t be less than 0 can’t be armor -10 can it?
Bean666 Posted February 8, 2021 Author Posted February 8, 2021 1 minute ago, Tekken said: You should put > 0 as it can’t be less than 0 can’t be armor -10 can it? thats what happened as well, when i put > 0 it gave me that = expected error.
Tekken Posted February 8, 2021 Posted February 8, 2021 (edited) < less <= less or equal > greater >= greater or equal You put an capital I in script replace If with if Edited February 8, 2021 by Tekken
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