This topic was marked solved by its starter, on June 21st, 2018, 07:58 PM

#### DarkRaZoR^

• Full Member
• Posts: 196
##### Angle Calculations
«  »
Based from the topic's title, I want to calculate the amount of times the player's angle changed each second. I can't find a way to call the function frequently without causing lag issues to the server. I kinda want a function that calls whenever the player's angle is modified. Any ideas you could spill out?

• LU Beta Tester
• Posts: 176
##### Re: Angle Calculations
« Reply #1,  »
Code: [Select]
`          local newAngle = floor(player.Angle);          if( lastPlayerAngle != newAngle )          {                    ++angleChanges;                    lastPlayerAngle = newAngle;          }`

isn't this what you want?
Quote
PS:is trash is ur home language??

#### DarkRaZoR^

• Full Member
• Posts: 196
##### Re: Angle Calculations
« Reply #2,  »
Quote from Shadow on March 10th, 2018, 04:44 PM
Code: [Select]
`          local newAngle = floor(player.Angle);          if( lastPlayerAngle != newAngle )          {                    ++angleChanges;                    lastPlayerAngle = newAngle;          }`

isn't this what you want?
Could you summarize what you did in your words?

• LU Beta Tester
• Posts: 176
##### Re: Angle Calculations
« Reply #3,  »
Code: [Select]
`floor(x);returns a float value representing the largest integer that is less than or equal to x`
Quote
PS:is trash is ur home language??

#### DarkRaZoR^

• Full Member
• Posts: 196
##### Re: Angle Calculations
« Reply #4,  »
Quote from Shadow on March 10th, 2018, 08:40 PM
Code: [Select]
`floor(x);returns a float value representing the largest integer that is less than or equal to x`
I understand what floor does. Where should I add this piece of code? I tried it on OnPlayerMove. The more players in the server, the greater the lag. ¯\_(ツ)_/¯
##### Re: Angle Calculations
« Reply #5,  »
Well based from what I attempted, there is one main issue. So, we've a timer set to 1 second, calling a function in which is Shadow's code, right? However, onPlayerMove calls the timer too much times that the output isn't timed. What if I could implement this code on client-side with a different method?

#### [KM]Helathien

• Newbie
• Posts: 21
##### Re: Angle Calculations
« Reply #6,  »
The only thing I can think of is using timers right now. This way it will announce in ID 1, rather then Messaging.
Hope it helps a litte.

Code: [Select]
`class PlayerStats{lastangle = null;}`

Code: [Select]
`else if ( cmd == "checkangle" ){if ( stats[player.ID].lastangle == null ) stats[player.ID].lastangle = player.Angle;{NewTimer( "CheckAngle" , 1000, 0 , player.ID)}} `

Code: [Select]
`function CheckAngle( player ){local player = FindPlayer( player )local lastangle = stats[player.ID].lastangle;local newangle = player.Angle;Announce( "Your Last Angle: " + lastangle + " New Angle " + newangle , player, 1 )stats[player.ID].lastangle = newangle;}`
Feel free to PM me for any help.
If I am not available on the forum come to VKs Official Server I am usually there.

#### DarkRaZoR^

• Full Member
• Posts: 196
##### Re: Angle Calculations
« Reply #7,  »
Quote from [KM]Helathien on June 21st, 2018, 06:26 PM
The only thing I can think of is using timers right now. This way it will announce in ID 1, rather then Messaging.
Hope it helps a litte.

Code: [Select]
`class PlayerStats{lastangle = null;}`

Code: [Select]
`else if ( cmd == "checkangle" ){if ( stats[player.ID].lastangle == null ) stats[player.ID].lastangle = player.Angle;{NewTimer( "CheckAngle" , 1000, 0 , player.ID)}} `

Code: [Select]
`function CheckAngle( player ){local player = FindPlayer( player )local lastangle = stats[player.ID].lastangle;local newangle = player.Angle;Announce( "Your Last Angle: " + lastangle + " New Angle " + newangle , player, 1 )stats[player.ID].lastangle = newangle;}`
But I can't rely on timers as it'll display the angle from a moment ago. BTW, I let this topic loose for a while so I just want to say thank you everyone for your feedback.