Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new Float:distance[MAX_PLAYERS];
- new m[MAX_PLAYERS];
- new km[MAX_PLAYERS];
- new Float:xx[MAX_PLAYERS],Float:yy[MAX_PLAYERS],Float:zz[MAX_PLAYERS];
- new Text:tacho[MAX_PLAYERS];
- new tachovar[MAX_PLAYERS];
- public OnGameModeInit()
- {
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- tacho[i]= TextDrawCreate(508.000000, 383.000000, " ");
- TextDrawBackgroundColor(tacho[i],255);
- TextDrawFont(tacho[i],2);
- TextDrawLetterSize(tacho[i],0.639999,2.399999);
- TextDrawColor(tacho[i],16711935);
- TextDrawSetOutline(tacho[i],1);
- TextDrawSetProportional(tacho[i],1);
- }
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate==PLAYER_STATE_DRIVER)
- {
- tachovar[playerid]=SetTimerEx("tachotimer",200,true,"i",playerid);
- TextDrawShowForPlayer(playerid,tacho[playerid]);
- GetPlayerPos(playerid,xx[playerid],yy[playerid],zz[playerid]);
- }
- if(newstate==PLAYER_STATE_ONFOOT)
- {
- KillTimer(tachovar[playerid]);
- TextDrawHideForPlayer(playerid,tacho[playerid]);
- }
- }
- forward tachotimer(playerid);
- public tachotimer(playerid)
- {
- new string[50];
- new Float:distanz;
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid,x,y,z);
- distanz=GetDistanceFromPointToPoint(xx[playerid],yy[playerid],zz[playerid],x,y,z);
- if(distanz>100) return 1;
- distance[playerid]=distance[playerid]+distanz;
- GetPlayerPos(playerid,xx[playerid],yy[playerid],zz[playerid]);
- if(distance[playerid]>100)
- {
- m[playerid]++;
- distance[playerid]=distance[playerid]-100;
- if(m[playerid]==10)
- {
- km[playerid]++;
- m[playerid]=0;
- }
- }
- format(string,sizeof(string),"%i,%i KM",km[playerid],m[playerid]);
- TextDrawSetString(tacho[playerid],string);
- return 1;
- }
- forward Float:GetDistanceFromPointToPoint(Float:X,Float:Y,Float:Z,Float:tX,Float:tY,Float:tZ);
- public Float:GetDistanceFromPointToPoint(Float:X,Float:Y,Float:Z,Float:tX,Float:tY,Float:tZ)
- {
- return Float:floatsqroot((tX-X)*(tX-X)+(tY-Y)*(tY-Y)+(tZ-Z)*(tZ-Z));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement