30.12.2013, 13:47
I'm hiding my speedometer using OnPlayerStateChange callback.
For every state, the speedo is hidden or shown when needed.
Class-selection after entering the server is State 0 (PLAYER_STATE_NONE).
Class-selection after respawning and re-entering class selection = 7 (PLAYER_STATE_WASTED).
For both cases, the speedo is hidden.
PLAYER_STATE_ONFOOT also hides the speedo (to hide it when you exit the vehicle, either from the driver-seat as well from a passenger seat).
PLAYER_STATE_DRIVER and PLAYER_STATE_PASSENGER display the speedo.
That's how I fixed it.
Previously, I used the globalspeedotimer function to hide/show the speedo based on being a vehicle.
But displaying it twice every second when it's already displayed was a waste of resources and possibly bandwidth.
That's why I re-made it to use OnPlayerStateChange.
If you state doesn't change, there is no need to hide/show your textdraws twice every second when it's already hidden/shown respectively.
Now it doesn't matter if you're inside a vehicle or not, because the script isn't using your vehicleid anymore to determine if the speedo should be displayed or hidden solely based on that.
It's only checking your state.
For every state, the speedo is hidden or shown when needed.
Class-selection after entering the server is State 0 (PLAYER_STATE_NONE).
Class-selection after respawning and re-entering class selection = 7 (PLAYER_STATE_WASTED).
For both cases, the speedo is hidden.
PLAYER_STATE_ONFOOT also hides the speedo (to hide it when you exit the vehicle, either from the driver-seat as well from a passenger seat).
PLAYER_STATE_DRIVER and PLAYER_STATE_PASSENGER display the speedo.
That's how I fixed it.
Previously, I used the globalspeedotimer function to hide/show the speedo based on being a vehicle.
But displaying it twice every second when it's already displayed was a waste of resources and possibly bandwidth.
That's why I re-made it to use OnPlayerStateChange.
If you state doesn't change, there is no need to hide/show your textdraws twice every second when it's already hidden/shown respectively.
Now it doesn't matter if you're inside a vehicle or not, because the script isn't using your vehicleid anymore to determine if the speedo should be displayed or hidden solely based on that.
It's only checking your state.