Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Criado Por: [JFS]: Jonathan Feitosa
- Publicado: 02/08/2016
- Contato: http://forum.sa-mp.com/member.php?u=116320
- */
- #include <a_samp>
- #include <progressbar>
- #define ATUALIZACAOVELO 1 // EM SEGUNDOS E NAO EM MILISEGUNDOS.
- new
- PlayerText:TDjVelocimetro[MAX_PLAYERS][6],
- bool:EntrouVeiculo[MAX_PLAYERS],
- StringJFS[128],
- tdstring[50],
- TimerVelocimetro[MAX_PLAYERS],
- PlayerBar:BarjVelocimetro[MAX_PLAYERS] = {INVALID_PLAYER_BAR_ID, ...}
- ;
- 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]);
- }
- new CarModelNameFromID[][] =
- {"Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster",
- "Stretch","Manana","Infernus","Voodoo","Pony","Mule","Cheetah","Ambulancia","Leviathan","Moonbeam","Esperanto",
- "Taxi","Washington","Bobcat","Mr Whoopee","BF Injection","Hunter","Premier","Enforcer","Securicar","Banshee",
- "Predator","Bus","Rhino","Barracks","Hotknife","Trailer","Previon","Coach","Cabbie","Stallion","Rumpo",
- "RC Bandit","Romero","Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer",
- "Turismo","Speeder","Reefer","Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van","Skimmer",
- "PCJ-600","Faggio","Freeway","RC Baron","RC Raider","Glendale","Oceanic","Sanchez","Sparrow","Patriot",
- "Quad","Coastguard","Dinghy","Hermes","Sabre","Rustler","ZR-350","Walton","Regina","Comet","BMX",
- "Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo",
- "Greenwood","Jetmax","Hotring","Sandking","Blista Compact","Maverick Policial","Boxville","Benson","Mesa",
- "RC Goblin","Hotring Racer A","Hotring Racer B","Bloodring Banger","Rancher","Super GT","Elegant",
- "Journey","Bike","Mountain Bike","Beagle","Cropdust","Stunt","Tanker","RoadTrain","Nebula","Majestic",
- "Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV1000","Cement Truck","Tow Truck","Fortune","Cadrona",
- "FBI Truck","Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan","Blade","Freight",
- "Streak","Vortex","Vincent","Bullet","Clover","Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob",
- "Tampa","Sunrise","Merit","Utility","Nevada","Yosemite","Windsor","Monster A","Monster B","Uranus",
- "Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight",
- "Trailer","Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford",
- "BF-400","Newsvan","Tug","Trailer A","Emperor","Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C",
- "Andromada","Dodo","RC Cam","Launch","Viatura (LSPD)","Viatura (SFPD)","Viatura (LVPD)","Police Ranger",
- "Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B",
- "Stair Trailer","Boxville","Farm Plow","Utility Trailer"
- };
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER && !EntrouVeiculo[playerid]) {
- PlayerTextDrawSetPreviewModel(playerid, TDjVelocimetro[playerid][3], GetVehicleModel(GetPlayerVehicleID(playerid)));
- format(StringJFS, sizeof(StringJFS), "]_%s_]", CarModelNameFromID[GetVehicleModel(GetPlayerVehicleID(playerid)) - 400]);
- PlayerTextDrawSetString(playerid, TDjVelocimetro[playerid][1], StringJFS);
- AbrirjVelocimetro(playerid);
- }
- return 1;
- }
- public OnPlayerConnect(playerid){
- CarregarjVelocimetro(playerid);
- return true;
- }
- public OnPlayerDisconnect(playerid, reason){
- // Caso necessário, botar também no OnGameModeExit com um Loop trocando os playerid por i.
- if(EntrouVeiculo[playerid]){
- KillTimer(TimerVelocimetro[playerid]);
- DestroyPlayerProgressBar(playerid, BarjVelocimetro[playerid]);
- EntrouVeiculo[playerid] = false;
- for(new i; i<6; i++)
- PlayerTextDrawDestroy(playerid, TDjVelocimetro[playerid][i]);
- }
- return true;
- }
- stock CarregarjVelocimetro(playerid){
- //Player TextDraws:
- TDjVelocimetro[playerid][0] = CreatePlayerTextDraw(playerid, 502.000000, 387.120117, "box");
- PlayerTextDrawLetterSize(playerid, TDjVelocimetro[playerid][0], 0.000000, 5.120001);
- PlayerTextDrawTextSize(playerid, TDjVelocimetro[playerid][0], 633.000000, 0.000000);
- PlayerTextDrawAlignment(playerid, TDjVelocimetro[playerid][0], 1);
- PlayerTextDrawColor(playerid, TDjVelocimetro[playerid][0], -1);
- PlayerTextDrawUseBox(playerid, TDjVelocimetro[playerid][0], 1);
- PlayerTextDrawBoxColor(playerid, TDjVelocimetro[playerid][0], 102);
- PlayerTextDrawSetShadow(playerid, TDjVelocimetro[playerid][0], 0);
- PlayerTextDrawSetOutline(playerid, TDjVelocimetro[playerid][0], 0);
- PlayerTextDrawBackgroundColor(playerid, TDjVelocimetro[playerid][0], 1090519142);
- PlayerTextDrawFont(playerid, TDjVelocimetro[playerid][0], 3);
- PlayerTextDrawSetProportional(playerid, TDjVelocimetro[playerid][0], 1);
- PlayerTextDrawSetShadow(playerid, TDjVelocimetro[playerid][0], 0);
- TDjVelocimetro[playerid][1] = CreatePlayerTextDraw(playerid, 499.599670, 395.900512, "]_INFERNUS_]");
- PlayerTextDrawLetterSize(playerid, TDjVelocimetro[playerid][1], 0.243999, 0.815994);
- PlayerTextDrawAlignment(playerid, TDjVelocimetro[playerid][1], 1);
- PlayerTextDrawColor(playerid, TDjVelocimetro[playerid][1], -1);
- PlayerTextDrawSetShadow(playerid, TDjVelocimetro[playerid][1], 0);
- PlayerTextDrawSetOutline(playerid, TDjVelocimetro[playerid][1], 0);
- PlayerTextDrawBackgroundColor(playerid, TDjVelocimetro[playerid][1], 409855);
- PlayerTextDrawFont(playerid, TDjVelocimetro[playerid][1], 2);
- PlayerTextDrawSetProportional(playerid, TDjVelocimetro[playerid][1], 1);
- PlayerTextDrawSetShadow(playerid, TDjVelocimetro[playerid][1], 0);
- TDjVelocimetro[playerid][2] = CreatePlayerTextDraw(playerid, 502.299865, 398.607482, "box");
- PlayerTextDrawLetterSize(playerid, TDjVelocimetro[playerid][2], 0.000000, 0.385003);
- PlayerTextDrawTextSize(playerid, TDjVelocimetro[playerid][2], 633.000000, 0.000000);
- PlayerTextDrawAlignment(playerid, TDjVelocimetro[playerid][2], 1);
- PlayerTextDrawColor(playerid, TDjVelocimetro[playerid][2], -1);
- PlayerTextDrawUseBox(playerid, TDjVelocimetro[playerid][2], 1);
- PlayerTextDrawBoxColor(playerid, TDjVelocimetro[playerid][2], 102);
- PlayerTextDrawSetShadow(playerid, TDjVelocimetro[playerid][2], 0);
- PlayerTextDrawSetOutline(playerid, TDjVelocimetro[playerid][2], 0);
- PlayerTextDrawBackgroundColor(playerid, TDjVelocimetro[playerid][2], 1090519142);
- PlayerTextDrawFont(playerid, TDjVelocimetro[playerid][2], 1);
- PlayerTextDrawSetProportional(playerid, TDjVelocimetro[playerid][2], 1);
- PlayerTextDrawSetShadow(playerid, TDjVelocimetro[playerid][2], 0);
- TDjVelocimetro[playerid][3] = CreatePlayerTextDraw(playerid, 549.799743, 335.693756, "_");
- PlayerTextDrawLetterSize(playerid, TDjVelocimetro[playerid][3], 0.000000, 0.000000);
- PlayerTextDrawTextSize(playerid, TDjVelocimetro[playerid][3], 90.000000, 90.000000);
- PlayerTextDrawAlignment(playerid, TDjVelocimetro[playerid][3], 1);
- PlayerTextDrawColor(playerid, TDjVelocimetro[playerid][3], -1);
- PlayerTextDrawSetShadow(playerid, TDjVelocimetro[playerid][3], 0);
- PlayerTextDrawSetOutline(playerid, TDjVelocimetro[playerid][3], 0);
- PlayerTextDrawBackgroundColor(playerid, TDjVelocimetro[playerid][3], 0);
- PlayerTextDrawFont(playerid, TDjVelocimetro[playerid][3], 5);
- PlayerTextDrawSetProportional(playerid, TDjVelocimetro[playerid][3], 0);
- PlayerTextDrawSetShadow(playerid, TDjVelocimetro[playerid][3], 0);
- PlayerTextDrawSetPreviewModel(playerid, TDjVelocimetro[playerid][3], 411);
- PlayerTextDrawSetPreviewRot(playerid, TDjVelocimetro[playerid][3], 0.000000, 0.000000, 40.000000, 1.000000);
- PlayerTextDrawSetPreviewVehCol(playerid, TDjVelocimetro[playerid][3], 1, 1);
- TDjVelocimetro[playerid][4] = CreatePlayerTextDraw(playerid, 501.900238, 415.880126, "box");
- PlayerTextDrawLetterSize(playerid, TDjVelocimetro[playerid][4], 0.000000, 0.400002);
- PlayerTextDrawTextSize(playerid, TDjVelocimetro[playerid][4], 633.000000, 0.000000);
- PlayerTextDrawAlignment(playerid, TDjVelocimetro[playerid][4], 1);
- PlayerTextDrawColor(playerid, TDjVelocimetro[playerid][4], -1);
- PlayerTextDrawUseBox(playerid, TDjVelocimetro[playerid][4], 1);
- PlayerTextDrawBoxColor(playerid, TDjVelocimetro[playerid][4], 102);
- PlayerTextDrawSetShadow(playerid, TDjVelocimetro[playerid][4], 0);
- PlayerTextDrawSetOutline(playerid, TDjVelocimetro[playerid][4], 0);
- PlayerTextDrawBackgroundColor(playerid, TDjVelocimetro[playerid][4], 1090519142);
- PlayerTextDrawFont(playerid, TDjVelocimetro[playerid][4], 1);
- PlayerTextDrawSetProportional(playerid, TDjVelocimetro[playerid][4], 1);
- PlayerTextDrawSetShadow(playerid, TDjVelocimetro[playerid][4], 0);
- TDjVelocimetro[playerid][5] = CreatePlayerTextDraw(playerid, 501.299896, 414.533569, "]_VELOCIDADE:_200KM_]");
- PlayerTextDrawLetterSize(playerid, TDjVelocimetro[playerid][5], 0.203997, 0.718931);
- PlayerTextDrawAlignment(playerid, TDjVelocimetro[playerid][5], 1);
- PlayerTextDrawColor(playerid, TDjVelocimetro[playerid][5], -1);
- PlayerTextDrawSetShadow(playerid, TDjVelocimetro[playerid][5], 0);
- PlayerTextDrawSetOutline(playerid, TDjVelocimetro[playerid][5], 0);
- PlayerTextDrawBackgroundColor(playerid, TDjVelocimetro[playerid][5], 255);
- PlayerTextDrawFont(playerid, TDjVelocimetro[playerid][5], 2);
- PlayerTextDrawSetProportional(playerid, TDjVelocimetro[playerid][5], 1);
- PlayerTextDrawSetShadow(playerid, TDjVelocimetro[playerid][5], 0);
- }
- stock AbrirjVelocimetro(playerid){
- BarjVelocimetro[playerid] = CreatePlayerProgressBar(playerid, 504.00, 426.00, 127.50, 7.19, -1, 100.0);
- SetPlayerProgressBarMaxValue(playerid, BarjVelocimetro[playerid], 250.0);
- SetPlayerProgressBarValue(playerid, BarjVelocimetro[playerid], 0.0);
- ShowPlayerProgressBar(playerid, BarjVelocimetro[playerid]);
- TimerVelocimetro[playerid] = SetTimerEx("TimerjVelocimetro", ATUALIZACAOVELO*1000, true, "i", playerid);
- EntrouVeiculo[playerid] = true;
- for(new i; i<6; i++)
- PlayerTextDrawShow(playerid, TDjVelocimetro[playerid][i]);
- }
- stock FecharjVelocimetro(playerid){
- KillTimer(TimerVelocimetro[playerid]);
- DestroyPlayerProgressBar(playerid, BarjVelocimetro[playerid]);
- EntrouVeiculo[playerid] = false;
- for(new i; i<6; i++)
- PlayerTextDrawHide(playerid, TDjVelocimetro[playerid][i]);
- }
- forward TimerjVelocimetro(playerid);
- public TimerjVelocimetro(playerid){
- if(EntrouVeiculo[playerid] && !IsPlayerInAnyVehicle(playerid)){
- FecharjVelocimetro(playerid);
- return true;
- }
- format(tdstring, sizeof(tdstring), "]_VELOCIDADE:_%dKM_]", GetPlayerSpeed(playerid));
- PlayerTextDrawSetString(playerid, TDjVelocimetro[playerid][5], tdstring);
- SetPlayerProgressBarValue(playerid, BarjVelocimetro[playerid], GetPlayerSpeed(playerid));
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement