Gas[vehicleID] -= 0.01;
_Pos[3] = GetPlayerDistanceFromPoint(playerid, x, y, z); // pega distancia anterior e checa com a distancia do jogador
GetPlayerPos(playerid, _Pos[0], _Pos[1], _Pos[2]); // pega posiзгo atual do jogador
if(_Pos[3]) { // caso a distancia for maior que 0.0 ele diminui a gasolina
Gas[vehicleID] -= 0.01;
}
SetTimerEx("VelocimeterUpdate", 200, false, "ifff", playerid, _Pos[0], _Pos[1], _Pos[2]); // envia a posicao do jogador
#include a_samp
/*
*
* "Velocimetro"
* by [S]trong
*
*/
#define COL_VEH_NAME 0xFF8C00FF
#define COL_VEH_INFO 0xE3E3E3FF
stock const
vehicleNames[ 212 ][ 18 ] = {
{ !#Landstalker }, { !#Bravura }, { !#Buffalo }, { !#Linerunner }, // 400, 401, 402, 403
{ !#Perrenial }, { !#Sentinel }, { !#Dumper }, { !#Firetruck }, // 404, 405, 406, 407
{ !#Trashmaster }, { !#Stretch }, { !#Manana }, { !#Infernus }, // 408, 409, 410, 411
{ !#Voodoo }, { !#Pony }, { !#Mule }, { !#Cheetah }, // 412, 413, 414, 415
{ !#Ambulance }, { !#Leviathan }, { !#Moonbeam }, { !#Esperanto }, // 416, 417, 418, 419
{ !#Taxi }, { !#Washington }, { !#Bobcat }, { !#Mr Whoopee }, // 420, 421, 422, 423
{ !#BF Injection }, { !#Hunter }, { !#Premier }, { !#Enforcer }, // 424, 425, 426, 427
{ !#Securicar }, { !#Banshee }, { !#Predator }, { !#Bus }, // 428, 429, 430, 431
{ !#Rhino }, { !#Barracks }, { !#Hotknife }, { !#Trailer 1 }, // 432, 433, 434, 435
{ !#Previon }, { !#Coach }, { !#Cabbie }, { !#Stallion }, // 436, 437, 438, 439
{ !#Rumpo }, { !#RC Bandit }, { !#Romero }, { !#Packer }, // 440, 441, 442, 443
{ !#Monster }, { !#Admiral }, { !#Squalo }, { !#Seasparrow }, // 444, 445, 446, 447
{ !#Pizzaboy }, { !#Tram }, { !#Trailer 2 }, { !#Turismo }, // 448, 449, 450, 451
{ !#Speeder }, { !#Reefer }, { !#Tropic }, { !#Flatbed }, // 452, 453, 454, 455
{ !#Yankee }, { !#Caddy }, { !#Solair }, { !#RC Van }, // 456, 457, 458, 459
{ !#Skimmer }, { !#PCJ-600 }, { !#Faggio }, { !#Freeway }, // 460, 461, 462, 463
{ !#RC Baron }, { !#RC Raider }, { !#Glendale }, { !#Oceanic }, // 464, 465, 466, 467
{ !#Sanchez }, { !#Sparrow }, { !#Patriot }, { !#Quad }, // 468, 469, 470, 471
{ !#Coastguard }, { !#Dinghy }, { !#Hermes }, { !#Sabre }, // 472, 473, 474, 475
{ !#Rustler }, { !#ZR-350 }, { !#Walton }, { !#Regina }, // 476, 477, 478, 479
{ !#Comet }, { !#BMX }, { !#Burrito }, { !#Camper }, // 480, 481, 482, 483
{ !#Marquis }, { !#Baggage }, { !#Dozer }, { !#Maverick }, // 484, 485, 486, 487
{ !#News Chopper }, { !#Rancher }, { !#FBI Rancher }, { !#Virgo }, // 488, 489, 490, 491
{ !#Greenwood }, { !#Jetmax }, { !#Hotring }, { !#Sandking }, // 492, 493, 494, 495
{ !#Blista }, { !#Police Maverick }, { !#Boxville }, { !#Benson }, // 496, 497, 498, 499
{ !#Mesa }, { !#RC Goblin }, { !#Hotring A }, { !#Hotring B }, // 500, 501, 502, 503
{ !#Bloodring Banger }, { !#Rancher }, { !#Super GT }, { !#Elegant }, // 504, 505, 506, 507
{ !#Journey }, { !#Bike }, { !#Mountain Bike }, { !#Beagle }, // 508, 509, 510, 511
{ !#Cropdust }, { !#Stuntplane }, { !#Tanker }, { !#Roadtrain }, // 512, 513, 514, 515
{ !#Nebula }, { !#Majestic }, { !#Buccaneer }, { !#Shamal }, // 516, 517, 518, 519
{ !#Hydra }, { !#FCR-900 }, { !#NRG-500 }, { !#HPV1000 }, // 520, 521, 522, 523
{ !#Cement Truck }, { !#Tow Truck }, { !#Fortune }, { !#Cadrona }, // 524, 525, 526, 527
{ !#FBI Truck }, { !#Willard }, { !#Forklift }, { !#Tractor }, // 528, 529, 530, 531
{ !#Combine }, { !#Feltzer }, { !#Remington }, { !#Slamvan }, // 532, 533, 534, 535
{ !#Blade }, { !#Freight }, { !#Streak }, { !#Vortex }, // 536, 537, 538, 539
{ !#Vincent }, { !#Bullet }, { !#Clover }, { !#Sadler }, // 540, 541, 542, 543
{ !#Firetruck LA }, { !#Hustler }, { !#Intruder }, { !#Primo }, // 544, 545, 546, 547
{ !#Cargobob }, { !#Tampa }, { !#Sunrise }, { !#Merit }, // 548, 549, 550, 551
{ !#Utility }, { !#Nevada }, { !#Yosemite }, { !#Windsor }, // 552, 553, 554, 555
{ !#Monster }, { !#Monster }, { !#Uranus }, { !#Jester }, // 556, 557, 558, 559
{ !#Sultan }, { !#Stratum }, { !#Elegy }, { !#Raindance }, // 560, 561, 562, 563
{ !#RC Tiger }, { !#Flash }, { !#Tahoma }, { !#Savanna }, // 564, 565, 566, 567
{ !#Bandito }, { !#Freight Flat }, { !#Streak Carriage }, { !#Kart }, // 568, 569, 570, 571
{ !#Mower }, { !#Duneride }, { !#Sweeper }, { !#Broadway }, // 572, 573, 574, 575
{ !#Tornado }, { !#AT-400 }, { !#DFT-30 }, { !#Huntley }, // 576, 577, 578, 579
{ !#Stafford }, { !#BF-400 }, { !#Newsvan }, { !#Tug }, // 580, 581, 582, 583
{ !#Trailer 3 }, { !#Emperor }, { !#Wayfarer }, { !#Euros }, // 584, 585, 586, 587
{ !#Hotdog }, { !#Club }, { !#Freight Carriage }, { !#Trailer 3 }, // 588, 589, 590, 591
{ !#Andromada }, { !#Dodo }, { !#RC Cam }, { !#Launch }, // 592, 593, 594, 595
{ !#Police LS }, { !#Police SF }, { !#Police LV }, { !#Police Ranger }, // 596, 597, 598, 599
{ !#Picador }, { !#S.W.A.T. Van }, { !#Alpha }, { !#Phoenix }, // 600, 601, 602, 603
{ !#Glendale }, { !#Sadler }, { !#Luggage Trailer A }, { !#Luggage Trailer B }, // 604, 605, 606, 607
{ !#Stair Trailer }, { !#Boxville }, { !#Farm Plow }, { !#Utility Trailer } // 608, 609, 610, 611
}
;
enum E_TEXTDRAW
{
Text:vehicleBox,
Text:vehicleName[ MAX_PLAYERS ],
Text:vehicleRight[ MAX_PLAYERS ],
Text:vehicleLeft[ MAX_PLAYERS ],
};
stock
textDraw[ E_TEXTDRAW ],
Float:Gas[ MAX_VEHICLES ] = { 100.0, ... }
;
VelocimeterUpdate(playerid, Float:x, Float:y, Float:z);
public OnFilterScriptInit( ) {
textsLoad( );
}
public OnFilterScriptExit( ) {
TextDrawHideForAll(textDraw[vehicleBox]);
for( new i = 0, s = GetMaxPlayers( ); i != s; ++ i) {
TextDrawHideForAll(textDraw[vehicleName][i]);
TextDrawHideForAll(textDraw[vehicleLeft][i]);
TextDrawHideForAll(textDraw[vehicleRight][i]);
}
}
public OnPlayerConnect(playerid) {
for( new i = 0, s = GetMaxPlayers( ); i != s; ++ i) {
TextDrawHideForPlayer(playerid, textDraw[vehicleName][i]);
TextDrawHideForPlayer(playerid, textDraw[vehicleLeft][i]);
TextDrawHideForPlayer(playerid, textDraw[vehicleRight][i]);
}
}
stock textsLoad( ) {
textDraw[ vehicleBox ] = TextDrawCreate( 555.0, 360.0, "LD_POKE:cd9d" );
TextDrawLetterSize ( textDraw[ vehicleBox ], -0.09, -8.3 ),
TextDrawTextSize ( textDraw[ vehicleBox ], -130.0, 40.0 ),
TextDrawBoxColor ( textDraw[ vehicleBox ], 0x0000000F ),
TextDrawBackgroundColor ( textDraw[ vehicleBox ], 0x0000000F ),
TextDrawColor ( textDraw[ vehicleBox ], 0x0000000F ),
TextDrawAlignment ( textDraw[ vehicleBox ], 0x2 ),
TextDrawFont ( textDraw[ vehicleBox ], 0x4 ),
TextDrawSetOutline ( textDraw[ vehicleBox ], 0x1 ),
TextDrawSetShadow ( textDraw[ vehicleBox ], 0x0 ),
TextDrawUseBox ( textDraw[ vehicleBox ], 0x1 );
for( new i = 0; i != MAX_PLAYERS; ++ i ) {
textDraw[ vehicleName ][ i ] = TextDrawCreate( 490.0, 362.0, "~n~ ~n~" );
TextDrawLetterSize ( textDraw[ vehicleName ][ i ], 0.25, 1.1 ),
TextDrawBackgroundColor ( textDraw[ vehicleName ][ i ], 0x0000000F ),
TextDrawColor ( textDraw[ vehicleName ][ i ], COL_VEH_NAME ),
TextDrawAlignment ( textDraw[ vehicleName ][ i ], 0x2 ),
TextDrawFont ( textDraw[ vehicleName ][ i ], 0x2 ),
TextDrawSetOutline ( textDraw[ vehicleName ][ i ], 0x1 ),
TextDrawSetShadow ( textDraw[ vehicleName ][ i ], 0x0 );
textDraw[ vehicleLeft ][ i ] = TextDrawCreate( 433.0, 375.0, "~n~ ~n~" );
TextDrawLetterSize ( textDraw[ vehicleLeft ][ i ], 0.2, 0.8 ),
TextDrawBackgroundColor ( textDraw[ vehicleLeft ][ i ], 0x0000001F ),
TextDrawColor ( textDraw[ vehicleLeft ][ i ], COL_VEH_INFO ),
TextDrawAlignment ( textDraw[ vehicleLeft ][ i ], 0x1 ),
TextDrawFont ( textDraw[ vehicleLeft ][ i ], 0x1 ),
TextDrawSetOutline ( textDraw[ vehicleLeft ][ i ], 0x1 ),
TextDrawSetShadow ( textDraw[ vehicleLeft ][ i ], 0x0 );
textDraw[ vehicleRight ][ i ] = TextDrawCreate( 547.0, 375.0, "~n~ ~n~" );
TextDrawLetterSize ( textDraw[ vehicleRight ][ i ], 0.2, 0.8 ),
TextDrawBackgroundColor ( textDraw[ vehicleRight ][ i ], 0x0000001F ),
TextDrawColor ( textDraw[ vehicleRight ][ i ], COL_VEH_INFO ),
TextDrawAlignment ( textDraw[ vehicleRight ][ i ], 0x3 ),
TextDrawFont ( textDraw[ vehicleRight ][ i ], 0x1 ),
TextDrawSetOutline ( textDraw[ vehicleRight ][ i ], 0x1 ),
TextDrawSetShadow ( textDraw[ vehicleRight ][ i ], 0x0 );
}
}
public OnPlayerStateChange(playerid, newstate, oldstate) {
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) {
new
Float:_Pos[3]
;
GetPlayerPos(playerid, _Pos[0], _Pos[1], _Pos[2]);
VelocimeterUpdate(playerid, _Pos[0], _Pos[1], _Pos[2]);
new
_Name[18]
;
strunpack(_Name, vehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid)) - 400]);
TextDrawSetString(textDraw[vehicleName][playerid], _Name);
TextDrawShowForPlayer(playerid, textDraw[vehicleBox]);
TextDrawShowForPlayer(playerid, textDraw[vehicleName][playerid]);
TextDrawShowForPlayer(playerid, textDraw[vehicleLeft][playerid]);
TextDrawShowForPlayer(playerid, textDraw[vehicleRight][playerid]);
}
if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) {
TextDrawHideForPlayer(playerid, textDraw[vehicleBox]);
TextDrawHideForPlayer(playerid, textDraw[vehicleName][playerid]);
TextDrawHideForPlayer(playerid, textDraw[vehicleLeft][playerid]);
TextDrawHideForPlayer(playerid, textDraw[vehicleRight][playerid]);
}
}
public VelocimeterUpdate(playerid, Float:x, Float:y, Float:z) {
if(IsPlayerInAnyVehicle(playerid)) {
new
Float:_Pos[5],
_String[45]
;
_Pos[3] = GetPlayerDistanceFromPoint(playerid, x, y, z);
GetPlayerPos(playerid, _Pos[0], _Pos[1], _Pos[2]);
new
vehicleID = GetPlayerVehicleID(playerid)
;
if(_Pos[3]) {
Gas[vehicleID] -= 0.50;
}
format(_String, sizeof(_String), "gasolina %d%%~n~altitude %0.2f m", floatround(Gas[vehicleID]), floatmul(_Pos[2], 0.3408));
TextDrawSetString(textDraw[vehicleRight][playerid], _String);
GetVehicleHealth(vehicleID, _Pos[4]);
format(_String, sizeof(_String), "%d km/h~n~lataria %d%%", floatround(floatmul(_Pos[3], 10.0)), floatround(floatdiv(_Pos[4], 10.0)));
TextDrawSetString(textDraw[vehicleLeft][playerid], _String);
SetTimerEx("VelocimeterUpdate", 920, false, "ifff", playerid, _Pos[0], _Pos[1], _Pos[2]);
}
}
x--; //Operaзгo de decremento.
--x; //Operaзгo de decremento.
x -= y; //Operaзгo de atribuiзгo com subtraзгo.
Na verdade й um erro que hб no cуdigo rjj!
pawn Код:
Entгo, basta aumentar o tempo de diferenзa para checagem de gasolina e aumentar o decrйscimo de gasolina ao longo do tempo. Para fixar isto, deixe mais ou menos assim: pawn Код:
![]() |