[Ajuda] Nгo ta descendo a gasolina
#5

Quote:
Originally Posted by AdrianoStk
Посмотреть сообщение
Ele esta armazenado em uma variбvel relacionado a cada player!

MODO QUE FICA ARMAZENADO NOS VEICULOS
PHP код:
#include a_samp
#include zcmd
#include sscanf2
new fuel[MAX_VEHICLES];
new 
VehicleNames[][] = {
    
"Landstalker""Bravura""Buffalo""Linerunner""Perrenial""Sentinel",
    
"Dumper""Firetruck""Trashmaster""Stretch""Manana""Infernus",
    
"Voodoo""Pony""Mule""Cheetah""Ambulance""Leviathan""Moonbeam",
    
"Esperanto""Taxi""Washington""Bobcat""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""Police Maverick""Boxville""Benson""Mesa""RC Goblin",
    
"Hotring Racer A""Hotring Racer B""Bloodring Banger""Rancher""Super GT",
    
"Elegant""Journey""Bike""Mountain Bike""Beagle""Cropduster""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""Monster""Uranus""Jester""Sultan""Stratium",
    
"Elegy""Raindance""RC Tiger""Flash""Tahoma""Savanna""Bandito",
    
"Freight Flat""Streak Carriage""Kart""Mower""Dune""Sweeper",
    
"Broadway""Tornado""AT-400""DFT-30""Huntley""Stafford""BF-400",
    
"News Van""Tug""Trailer""Emperor""Wayfarer""Euros""Hotdog""Club",
    
"Freight Box""Trailer""Andromada""Dodo""RC Cam""Launch""Police Car",
    
"Police Car""Police Car""Police Ranger""Picador""S.W.A.T""Alpha",
    
"Phoenix""Glendale""Sadler""Luggage""Luggage""Stairs""Boxville",
    
"Tiller""Utility Trailer"
};
//Player Textdraws:
new PlayerText:v_velocidade [MAX_PLAYERS];
new 
PlayerText:v_gasolina[MAX_PLAYERS];
new 
PlayerText:v_nome[MAX_PLAYERS];
new 
PlayerText:v_progress_branco_gas[MAX_PLAYERS];
new 
PlayerText:v_progress_branco_velo[MAX_PLAYERS];
new 
PlayerText:v_progress_azul_velo[MAX_PLAYERS];
new 
PlayerText:v_progress_ver_velo[MAX_PLAYERS];
new 
PlayerText:v_progress_cinza_velo[MAX_PLAYERS];
new 
PlayerText:v_progress_cinza_gas[MAX_PLAYERS];
public 
OnFilterScriptInit()
{
    
SetTimer("a_velocimetro"100true);
    
SetTimer("GasolinaVeiculo"10000true); //10 Segundos
    
for(new 0MAX_VEHICLESi++)
    {
        
fuel[i] == 100// Seta a gasolina inicial de todos os veiculos para 100
    
}
    return 
true;
}
public 
OnPlayerConnect(playerid) {
    
v_velocidade[playerid] = CreatePlayerTextDraw(playerid603.581237332.749847"100");
    
PlayerTextDrawLetterSize(playeridv_velocidade[playerid], 0.4392221.424997);
    
PlayerTextDrawAlignment(playeridv_velocidade[playerid], 1);
    
PlayerTextDrawColor(playeridv_velocidade[playerid], -1138808065);
    
PlayerTextDrawSetShadow(playeridv_velocidade[playerid], 1);
    
PlayerTextDrawSetOutline(playeridv_velocidade[playerid], 0);
    
PlayerTextDrawBackgroundColor(playeridv_velocidade[playerid], -1);
    
PlayerTextDrawFont(playeridv_velocidade[playerid], 3);
    
PlayerTextDrawSetProportional(playeridv_velocidade[playerid], 1);
    
v_gasolina[playerid] = CreatePlayerTextDraw(playerid603.644226347.750000"100");
    
PlayerTextDrawLetterSize(playeridv_gasolina[playerid], 0.4392221.424997);
    
PlayerTextDrawAlignment(playeridv_gasolina[playerid], 1);
    
PlayerTextDrawColor(playeridv_gasolina[playerid], 121335295);
    
PlayerTextDrawSetShadow(playeridv_gasolina[playerid], 1);
    
PlayerTextDrawSetOutline(playeridv_gasolina[playerid], 0);
    
PlayerTextDrawBackgroundColor(playeridv_gasolina[playerid], -1);
    
PlayerTextDrawFont(playeridv_gasolina[playerid], 3);
    
PlayerTextDrawSetProportional(playeridv_gasolina[playerid], 1);
    
v_nome[playerid] = CreatePlayerTextDraw(playerid507.939697305.499786"Sultan");
    
PlayerTextDrawLetterSize(playeridv_nome[playerid], 0.3984612.090001);
    
PlayerTextDrawAlignment(playeridv_nome[playerid], 1);
    
PlayerTextDrawColor(playeridv_nome[playerid], -1);
    
PlayerTextDrawSetShadow(playeridv_nome[playerid], 0);
    
PlayerTextDrawSetOutline(playeridv_nome[playerid], 256);
    
PlayerTextDrawBackgroundColor(playeridv_nome[playerid], 51);
    
PlayerTextDrawFont(playeridv_nome[playerid], 3);
    
PlayerTextDrawSetProportional(playeridv_nome[playerid], 1);
    
PlayerTextDrawSetSelectable(playeridv_nome[playerid], true);
    
v_progress_branco_gas[playerid] = CreatePlayerTextDraw(playerid603.176086350.749877"usebox");//progres fundo gas
    
PlayerTextDrawLetterSize(playeridv_progress_branco_gas[playerid], 0.0000000.967953);
    
PlayerTextDrawTextSize(playeridv_progress_branco_gas[playerid], 506.3454580.000000);
    
PlayerTextDrawUseBox(playeridv_progress_branco_gas[playerid], true);
    
PlayerTextDrawBoxColor(playeridv_progress_branco_gas[playerid], -1);
    
v_progress_branco_velo[playerid] = CreatePlayerTextDraw(playerid603.113037327.583374"usebox");//progress fundo velo
    
PlayerTextDrawLetterSize(playeridv_progress_branco_velo[playerid], 0.0000001.858143);
    
PlayerTextDrawTextSize(playeridv_progress_branco_velo[playerid], 506.3455200.000000);
    
PlayerTextDrawUseBox(playeridv_progress_branco_velo[playerid], true);
    
PlayerTextDrawBoxColor(playeridv_progress_branco_velo[playerid], -1);
    
v_progress_azul_velo[playerid] = CreatePlayerTextDraw(playerid602.770507351.749847"usebox"); //progress azul
    
PlayerTextDrawLetterSize(playeridv_progress_azul_velo[playerid], 0.0000000.827396);
    
PlayerTextDrawTextSize(playeridv_progress_azul_velo[playerid], 506.8139950.000000);
    
PlayerTextDrawUseBox(playeridv_progress_azul_velo[playerid], true);
    
PlayerTextDrawBoxColor(playeridv_progress_azul_velo[playerid], 121335295);
    
v_progress_ver_velo[playerid] = CreatePlayerTextDraw(playerid602.833435328.249816"usebox"); //progress vermelho
    
PlayerTextDrawLetterSize(playeridv_progress_ver_velo[playerid], 0.0000001.717586);
    
PlayerTextDrawTextSize(playeridv_progress_ver_velo[playerid], 506.8334350.000000);
    
PlayerTextDrawUseBox(playeridv_progress_ver_velo[playerid], true);
    
PlayerTextDrawBoxColor(playeridv_progress_ver_velo[playerid], -1138808065);
    
v_progress_cinza_velo[playerid] = CreatePlayerTextDraw(playerid602.833435328.249816"usebox"); //progress velocidade
    
PlayerTextDrawLetterSize(playeridv_progress_cinza_velo[playerid], 0.0000001.717586);
    
PlayerTextDrawTextSize(playeridv_progress_cinza_velo[playerid], 506.8334350.000000);
    
PlayerTextDrawUseBox(playeridv_progress_cinza_velo[playerid], true);
    
PlayerTextDrawBoxColor(playeridv_progress_cinza_velo[playerid], 0x707170FF);
    
v_progress_cinza_gas[playerid] = CreatePlayerTextDraw(playerid602.770507351.749847"usebox"); //progress gasolina
    
PlayerTextDrawLetterSize(playeridv_progress_cinza_gas[playerid], 0.0000000.827396);
    
PlayerTextDrawTextSize(playeridv_progress_cinza_gas[playerid], 506.8139950.000000);
    
PlayerTextDrawUseBox(playeridv_progress_cinza_gas[playerid], true);
    
PlayerTextDrawBoxColor(playeridv_progress_cinza_gas[playerid], 0x707170FF);
    return 
true;
}
forward a_velocimetro();
public 
a_velocimetro() {
    for(new 
iMAX_PLAYERSi++) {
        if(
GetPlayerState(i) == PLAYER_STATE_DRIVER) {
            new 
fVelocidade floatround(GetVehicleSpeed(GetPlayerVehicleID(i), 1)), v_index GetPlayerVehicleID(i);
            new 
string_velocidade[32], string_gasolina[32];
            
PlayerTextDrawShow(iv_velocidade[i]);
            
PlayerTextDrawShow(iv_gasolina[i]);
            
PlayerTextDrawShow(iv_nome[i]);
            
PlayerTextDrawShow(iv_progress_branco_gas[i]);
            
PlayerTextDrawShow(iv_progress_branco_velo[i]);
            
PlayerTextDrawShow(iv_progress_azul_velo[i]);
            
PlayerTextDrawShow(iv_progress_ver_velo[i]);
            
PlayerTextDrawShow(iv_progress_cinza_velo[i]);
            
PlayerTextDrawShow(iv_progress_cinza_gas[i]);
            
format(string_gasolinasizeof(string_gasolina), "%d"fuel[GetPlayerVehicleID(i)], PlayerTextDrawSetString(iv_gasolina[i], string_gasolina);
            
format(string_velocidadesizeof(string_velocidade), "%i"fVelocidade), PlayerTextDrawSetString(iv_velocidade[i], string_velocidade);
            
PlayerTextDrawSetString(iv_nome[i], GetVehicleName(v_index));
            
PlayerTextDrawTextSize(iv_progress_cinza_velo[i], (507.00 + ((97.0 fVelocidade) / 160)), 0.0);
            switch(
fuel[GetPlayerVehicleID(i)]) {
                case 
94 .. 100PlayerTextDrawTextSize(iv_progress_cinza_gas[i], (507.00 + ((97.0 100) / 100 -5.5)), 0.0);
                default: 
PlayerTextDrawTextSize(iv_progress_cinza_gas[i], (507.00 + ((97.0 fuel[GetPlayerVehicleID(i)]) / 100 )), 0.0);
            }
        }
        else {
            
PlayerTextDrawHide(iv_velocidade[i]);
            
PlayerTextDrawHide(iv_gasolina[i]);
            
PlayerTextDrawHide(iv_nome[i]);
            
PlayerTextDrawHide(iv_progress_branco_gas[i]);
            
PlayerTextDrawHide(iv_progress_branco_velo[i]);
            
PlayerTextDrawHide(iv_progress_azul_velo[i]);
            
PlayerTextDrawHide(iv_progress_ver_velo[i]);
            
PlayerTextDrawHide(iv_progress_cinza_velo[i]);
            
PlayerTextDrawHide(iv_progress_cinza_gas[i]);
        }
    }
    return 
1;
}
forward Float:GetVehicleSpeed(vehicleidUseMPH 0);
stock Float:GetVehicleSpeed(vehicleidUseMPH 0) {
    new 
Float:speed_xFloat:speed_yFloat:speed_zFloat:temp_speed;
    
GetVehicleVelocity(vehicleidspeed_xspeed_yspeed_z);
    if(
UseMPH == 0temp_speed floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667;
    else 
temp_speed floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*85.4166672;
    
floatround(temp_speed,floatround_round);
    return 
temp_speed;
}
stock GetVehicleName(vehicleid) {
    new 
String[128];
    
format(String,sizeof(String),"%s",VehicleNames[GetVehicleModel(vehicleid) - 400]);
    return 
String;
}
command(criarcarroplayeridparams []) {
    new 
indexFloat:pl_xFloat:pl_yFloat:pl_z;
    
GetPlayerPos(playeridpl_xpl_ypl_z);
    if(
sscanf(params"d"index)) return CreateVehicle(411pl_xpl_ypl_z0.06699999999);
    return 
CreateVehicle(indexpl_xpl_ypl_z0.06699999999);
}
command(setfuelplayeridparams []) {
    new 
index;
    if(
sscanf(params"d"index)) return false;
    if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1"Erro! Vocк nгo estб em um veiculo!");
    
fuel[GetPlayerVehicleID(playerid)] = index;
    return 
true;
}
//FUNDAMENTAL!
forward GasolinaVeiculo();
public 
GasolinaVeiculo()
{
    for(new 
iMAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
        {
            
fuel[GetPlayerVehicleID(i)] --;
        }
    }

Muito Obrigado, deu tudo certo!
Reply


Messages In This Thread
Nгo ta descendo a gasolina - by TheCrazyy - 03.07.2017, 18:44
Re: Nгo ta descendo a gasolina - by AdrianoStk - 03.07.2017, 19:10
Respuesta: Nгo ta descendo a gasolina - by TheCrazyy - 03.07.2017, 19:40
Re: Respuesta: Nгo ta descendo a gasolina - by AdrianoStk - 03.07.2017, 20:48
Respuesta: Re: Respuesta: Nгo ta descendo a gasolina - by TheCrazyy - 04.07.2017, 22:56

Forum Jump:


Users browsing this thread: 2 Guest(s)