Angle Calculations

Started by D4rkR420R, Mar 10, 2018, 03:24 AM

Previous topic - Next topic

D4rkR420R

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?

Shadow

          local newAngle = floor(player.Angle);
          if( lastPlayerAngle != newAngle )
          {
                    ++angleChanges;
                    lastPlayerAngle = newAngle;
          }

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

D4rkR420R

Quote from: Shadow on Mar 10, 2018, 04:44 PM          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?

Shadow

floor(x);

returns a float value representing the largest integer that is less than or equal to x
QuotePS:is trash is ur home language??

D4rkR420R

Quote from: Shadow on Mar 10, 2018, 08:40 PMfloor(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. ¯\_(ツ)_/¯

D4rkR420R

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

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.

class PlayerStats
{
lastangle = null;
}

else if ( cmd == "checkangle" )
{
if ( stats[player.ID].lastangle == null ) stats[player.ID].lastangle = player.Angle;

{
NewTimer( "CheckAngle" , 1000, 0 , player.ID)
}
}

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.

D4rkR420R

Quote from: [KM]Helathien on Jun 21, 2018, 05:26 PMThe 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.

class PlayerStats
{
lastangle = null;
}

else if ( cmd == "checkangle" )
{
if ( stats[player.ID].lastangle == null ) stats[player.ID].lastangle = player.Angle;

{
NewTimer( "CheckAngle" , 1000, 0 , player.ID)
}
}

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.