Jump to content

Time?


Recommended Posts

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 by Shaman123
Link to post
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?

Link to post

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 by Shaman123
Link to post

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 by Tekken
  • Like 1
Link to post
  • Moderators
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 by IIYAMA
  • Like 2
Link to post
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!

  • Like 2
Link to post
  • Moderators
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.

  • Like 1
Link to post
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 by Shaman123
  • Like 1
Link to post
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.

Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...