Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public OnGameModeInit()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- Textdraw[i] = TextDrawCreate(512.500000,316.088989,"");
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- TextDrawShowForPlayer(playerid,Textdraw[playerid]);
- return 1;
- }
- public OnPlayerStateChange(playerid,newstate,oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER)
- {
- new string[124];
- format(string,sizeof(string),"%d KM/H",GetPlayerSpeed(playerid));
- TextDrawSetString(Textdraw[playerid],string);
- }
- else if(newstate == PLAYER_STATE_ONFOOT)
- {
- new string[124];
- format(string,sizeof(string),"");
- TextDrawSetString(Textdraw[playerid],string);
- }
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
- {
- new string[124];
- format(string,sizeof(string),"%d KM/H",GetPlayerSpeed(playerid));
- TextDrawSetString(Textdraw[playerid],string);
- }
- return 1;
- }
- stock GetPlayerSpeed(playerid)
- {
- new Float:ST[4];
- if(IsPlayerInAnyVehicle(playerid))
- GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
- else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
- ST[3] = floatsqroot(floatpower(floatabs(ST[0]),2.0) + floatpower(floatabs(ST[1]),2.0) + floatpower(floatabs(ST[2]),2.0)) * 179.28625;
- return floatround(ST[3]);
- }
Advertisement
Add Comment
Please, Sign In to add comment