10.06.2010, 09:05
Okei, so i managed to script a nice little Speedometer.. the only problem is that the speedometer can only be used with one person ..
means like if one person is driving the speedometer will be enabled with the speed of the person driving for all other players driving..
Heres my code:
Top of script:
Make the Text varible:
On Gm init:
OnPlayerStateChange:
The speedo function:
Help is really apprectiated!! thx
means like if one person is driving the speedometer will be enabled with the speed of the person driving for all other players driving..
Heres my code:
Top of script:
Код:
forward Speedometer(playerid);
Код:
new Text:SpeedoText;
Код:
SpeedoText = TextDrawCreate(250.0, 405.0, "SpeedoText"); TextDrawSetShadow(SpeedoText, 1); TextDrawSetOutline(SpeedoText, 2); TextDrawLetterSize(SpeedoText,0.60,2.0); TextDrawFont(SpeedoText, 3); TextDrawBoxColor(SpeedoText,0x000000AA);
Код:
public OnPlayerStateChange(playerid,newstate,oldstate) { if(newstate==PLAYER_STATE_DRIVER) { TextDrawShowForPlayer(playerid,SpeedoText); }else{ TextDrawHideForPlayer(playerid,SpeedoText); } return 1; }
Код:
//// GetPlayer Speed forward GetPlayerSpeed(playerid); 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)) * 200; return floatround(ST[3]); } //// Speedoupdate forward Speedometer(playerid); public Speedometer(playerid) { new string[256]; new speed = GetPlayerSpeed(playerid); format(string,sizeof(string),"~g~ Speed: ~w~ %d KP/h",speed); TextDrawSetString(SpeedoText, string); }
