Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* SPEEDOMETER CREATED BY Mr.Walker (Scott_Walker) , INSPIRED BY System32
- THANK YOU System32
- version 0.4
- */
- #include <a_samp>
- #define COLOR_BLACK 0x000000FF
- #define ORANGE 0xF97804FF
- #define COLOR_RED 0xAA3333AA
- forward WalkerSpeedo();
- new FORTIMER;
- new Walkers[MAX_PLAYERS];
- new Text: Walkerspeedometer[MAX_PLAYERS];
- new Text: snagalinija[MAX_PLAYERS];
- new Text: healhtline;
- new Text: speedo[MAX_PLAYERS];
- new Text: kmh[MAX_PLAYERS];
- new Text: hp[MAX_PLAYERS];
- new Text: hpcol[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("{{{{{{{{{{{{{}}}}}}}}}}}}}");
- print("{{Mr.Walker SpeedoMeter}}");
- print("{{{{{{{{{{{{{}}}}}}}}}}}}}");
- FORTIMER = SetTimer("WalkerSpeedo",300,1);
- healhtline = TextDrawCreate(556.000000,420.000000,"_");
- TextDrawUseBox(healhtline,1);
- TextDrawBoxColor(healhtline,0xffffffff);
- TextDrawTextSize(healhtline,551.000000,0.000000);
- TextDrawAlignment(healhtline,0);
- TextDrawBackgroundColor(healhtline,0x000000ff);
- TextDrawFont(healhtline,3);
- TextDrawLetterSize(healhtline,0.199999,-0.000000);
- TextDrawColor(healhtline,0xffffffff);
- TextDrawSetOutline(healhtline,1);
- TextDrawSetProportional(healhtline,1);
- TextDrawSetShadow(healhtline,1);
- for(new i=0; i<GetMaxPlayers(); i++)
- {
- Walkers[i] = 1;
- Walkerspeedometer[i] = TextDrawCreate(535.000000,376.000000, " ");
- TextDrawAlignment(Walkerspeedometer[i],0);
- TextDrawBackgroundColor(Walkerspeedometer[i],0x000000ff);
- TextDrawFont(Walkerspeedometer[i],1);
- TextDrawLetterSize(Walkerspeedometer[i],0.199999,0.899999);
- TextDrawSetProportional(Walkerspeedometer[i],1);
- TextDrawSetShadow(Walkerspeedometer[i],1);
- TextDrawColor(Walkerspeedometer[i],0xffff00ff);
- snagalinija[i] = TextDrawCreate(538.000000,443.500000,"_");
- TextDrawUseBox(snagalinija[i],1);
- TextDrawBoxColor(snagalinija[i],COLOR_BLACK);
- TextDrawAlignment(snagalinija[i],0);
- TextDrawBackgroundColor(snagalinija[i],0x000000ff);
- TextDrawFont(snagalinija[i],3);
- TextDrawLetterSize(snagalinija[i],1.000000,-0.000000);
- TextDrawColor(snagalinija[i],0xffffffff);
- TextDrawSetOutline(snagalinija[i],1);
- TextDrawSetProportional(snagalinija[i],1);
- TextDrawSetShadow(snagalinija[i],1);
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- KillTimer(FORTIMER);
- TextDrawDestroy(Text:healhtline);
- for(new i=0; i<GetMaxPlayers(); i++)
- {
- TextDrawDestroy(snagalinija[i]);
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- speedo[playerid] = TextDrawCreate(535.000000, 415.000000, "Brzina:");
- TextDrawBackgroundColor(speedo[playerid], 255);
- TextDrawFont(speedo[playerid], 3);
- TextDrawLetterSize(speedo[playerid], 0.350000, 1.100000);
- TextDrawColor(speedo[playerid], ORANGE);
- TextDrawSetOutline(speedo[playerid], 1);
- TextDrawSetProportional(speedo[playerid], 1);
- TextDrawSetShadow(speedo[playerid], 1);
- kmh[playerid] = TextDrawCreate(581.000000, 415.000000, "_");
- TextDrawBackgroundColor(kmh[playerid], 255);
- TextDrawFont(kmh[playerid], 3);
- TextDrawLetterSize(kmh[playerid], 0.350000, 1.100000);
- TextDrawColor(kmh[playerid], -1);
- TextDrawSetOutline(kmh[playerid], 1);
- TextDrawSetProportional(kmh[playerid], 1);
- TextDrawSetShadow(kmh[playerid], 1);
- hp[playerid] = TextDrawCreate(535.000000, 430.000000, "Snaga:");
- TextDrawBackgroundColor(hp[playerid], 255);
- TextDrawFont(hp[playerid], 3);
- TextDrawLetterSize(hp[playerid], 0.350000, 1.100000);
- TextDrawColor(hp[playerid], ORANGE);
- TextDrawSetOutline(hp[playerid], 1);
- TextDrawSetProportional(hp[playerid], 1);
- TextDrawSetShadow(hp[playerid], 1);
- hpcol[playerid] = TextDrawCreate(581.000000, 430.000000, "_");
- TextDrawBackgroundColor(hpcol[playerid], 255);
- TextDrawFont(hpcol[playerid], 3);
- TextDrawLetterSize(hpcol[playerid], 0.350000, 1.100000);
- TextDrawColor(hpcol[playerid], -1);
- TextDrawSetOutline(hpcol[playerid], 1);
- TextDrawSetProportional(hpcol[playerid], 1);
- TextDrawSetShadow(hpcol[playerid], 1);
- }
- public OnPlayerUpdate(playerid)
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- new estr[64],speed = GetSpeed(playerid);
- format(estr,64,"%d km/h", speed);
- TextDrawSetString(kmh[playerid], estr);
- new estr1[16], Float: health;
- for(new i = 0; i<MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(playerid))
- {
- GetVehicleHealth(GetPlayerVehicleID(i), health);
- }
- }
- format(estr1,16,"%.2f", health);
- TextDrawSetString(hpcol[playerid], estr1);
- }
- else if(!IsPlayerInAnyVehicle(playerid))
- {
- TextDrawHideForPlayer(playerid, speedo[playerid]);
- TextDrawHideForPlayer(playerid, kmh[playerid]);
- TextDrawHideForPlayer(playerid, hp[playerid]);
- TextDrawHideForPlayer(playerid, hpcol[playerid]);
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/speedo", cmdtext, true, 10) == 0)
- {
- if(Walkers[playerid] == 1)
- {
- Walkers[playerid] = 0;
- SendClientMessage(playerid,COLOR_RED,"<< Speedometer has been disabled.");
- }
- else if(Walkers[playerid] == 0)
- {
- Walkers[playerid] = 1;
- SendClientMessage(playerid,COLOR_RED,">> Speedometer has been enabled.");
- }
- return 1;
- }
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(oldstate-1 && newstate) TextDrawHideForPlayer(playerid, speedo[playerid]); else if(newstate-1) TextDrawShowForPlayer(playerid, speedo[playerid]);
- if(oldstate-1 && newstate) TextDrawHideForPlayer(playerid, kmh[playerid]); else if(newstate-1) TextDrawShowForPlayer(playerid, kmh[playerid]);
- if(oldstate-1 && newstate) TextDrawHideForPlayer(playerid, hp[playerid]); else if(newstate-1) TextDrawShowForPlayer(playerid, hp[playerid]);
- if(oldstate-1 && newstate) TextDrawHideForPlayer(playerid, hpcol[playerid]); else if(newstate-1) TextDrawShowForPlayer(playerid, hpcol[playerid]);
- return 1;
- }
- public WalkerSpeedo()
- {
- for(new i=0; i<GetMaxPlayers(); i++)
- {
- if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && Walkers[i] == 1)
- {
- new Float:snagavozila;
- GetVehicleHealth(GetPlayerVehicleID(i), snagavozila);
- if(snagavozila < 250)
- {
- TextDrawTextSize(snagalinija[i],538.000000,0.000000);
- }
- else if(snagavozila >= 1000)
- {
- TextDrawTextSize(snagalinija[i],625.000000,0.000000);
- }
- else
- {
- TextDrawTextSize(snagalinija[i],floatadd(534.0, floatdiv(snagavozila, 14.6000000)),0.000000);
- }
- TextDrawShowForPlayer(i, snagalinija[i]);
- TextDrawShowForPlayer(i, healhtline);
- }
- else
- {
- TextDrawHideForPlayer(i, Text:Walkerspeedometer[i]);
- TextDrawHideForPlayer(i, Text:snagalinija[i]);
- TextDrawHideForPlayer(i, Text:healhtline);
- }
- }
- }
- stock GetSpeed(playerid)
- {
- new Float:ST[3];
- GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
- return floatround(1.61*floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 100.3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement