pawn Код:
#include <a_samp>
forward time();
forward SpeedoUpdate();
forward FuelUpdate();
new Text:Textdraw0;
new Text:Textdraw1;
new Text:box[MAX_PLAYERS],Text:speed[MAX_PLAYERS],Text:health[MAX_PLAYERS],Text:fuel[MAX_PLAYERS];
new VehicleFuel[MAX_VEHICLES];
public OnFilterScriptInit()
{
SetTimer("SpeedoUpdate",500,false);
SetTimer("FuelUpdate",500,false);
ManualVehicleEngineAndLights();
for(new i = 1;i<MAX_VEHICLES;i++)
{
VehicleFuel[i] = 100 + random(50);
}
Textdraw0 = TextDrawCreate(87.000000, 326.000000, "Roleplay");
TextDrawAlignment(Textdraw0, 2);
TextDrawBackgroundColor(Textdraw0, 255);
TextDrawFont(Textdraw0, 1);
TextDrawLetterSize(Textdraw0, 0.500000, 1.000000);
TextDrawColor(Textdraw0, -45931777);
TextDrawSetOutline(Textdraw0, 0);
TextDrawSetProportional(Textdraw0, 1);
TextDrawSetShadow(Textdraw0, 1);
Textdraw1 = TextDrawCreate(62.000000, 316.000000, "Brasil");
TextDrawBackgroundColor(Textdraw1, 255);
TextDrawFont(Textdraw1, 2);
TextDrawLetterSize(Textdraw1, 0.360000, 1.200000);
TextDrawColor(Textdraw1, 1650615039);
TextDrawSetOutline(Textdraw1, 0);
TextDrawSetProportional(Textdraw1, 1);
TextDrawSetShadow(Textdraw1, 1);
}
public OnPlayerConnect(playerid)
{
box[playerid] = TextDrawCreate(623,389,"_"); //618
TextDrawLetterSize(box[playerid],0.5,3.999996);
TextDrawUseBox(box[playerid],1);
TextDrawBoxColor(box[playerid],0x00000060);
TextDrawTextSize(box[playerid],473,0);
speed[playerid] = TextDrawCreate(478,389,"_");
TextDrawLetterSize(speed[playerid],0.37,1.099999);
TextDrawSetOutline(speed[playerid],1);
health[playerid] = TextDrawCreate(478,401,"_");
TextDrawLetterSize(health[playerid],0.37,1.099999);
TextDrawSetOutline(health[playerid],1);
fuel[playerid] = TextDrawCreate(478,413,"_");
TextDrawLetterSize(fuel[playerid],0.37,1.099999);
TextDrawSetOutline(fuel[playerid],1);
TextDrawShowForPlayer(playerid, Textdraw0);
TextDrawShowForPlayer(playerid, Textdraw1);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
TextDrawDestroy(box[playerid]);
TextDrawDestroy(speed[playerid]);
TextDrawDestroy(health[playerid]);
TextDrawDestroy(fuel[playerid]);
return 1;
}
public OnVehicleSpawn(vehicleid)
{
VehicleFuel[vehicleid] = 100 + random(50);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext,"/abastecer",true))
{
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, 0xFF4E00FF, "RPBR Fuel:{A6A6A6} Voce nao esta em um veiculo.");
if(!Locais(playerid))
return SendClientMessage(playerid, 0xFF4E00FF, "RPBR Fuel:{A6A6A6} Voce nao esta em um posto de gasolina.");
VehicleFuel[GetPlayerVehicleID(playerid)] = 100 + random(50);
GivePlayerMoney(playerid,-500);
GameTextForPlayer(playerid, "~>~~w~Abastecido~<~", 3000, 4);
SendClientMessage(playerid,0xFF4E00FF,"RPBR Fuel:{A6A6A6} Foi cobrado 500$ pelo abastecimento.");
return 1;
}
return 0;
}
Locais(playerid) { //ADICIONAR LOCALIZACOES DOS POSTOS
if(IsPlayerInRangeOfPoint(playerid, 5.0,1938.4000244141,-1771.6999511719,13) || IsPlayerInRangeOfPoint(playerid, 0.5,1999.4090244146,-1771.6999911719,23)
|| IsPlayerInRangeOfPoint(playerid, 0.5,1999.4000244146,-1771.6999811719,12) || IsPlayerInRangeOfPoint(playerid, 0.5,1999.4000744146,-1771.6999881719,25))
return true;
return false;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(newkeys & KEY_ACTION)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine == 1) SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
else
{
if(VehicleFuel[vehicleid] > 0) SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
}
}
if(newkeys & KEY_CROUCH)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(lights == 1) SetVehicleParamsEx(vehicleid,engine,0,alarm,doors,bonnet,boot,objective);
else SetVehicleParamsEx(vehicleid,engine,1,alarm,doors,bonnet,boot,objective);
}
}
return 1;
}
public SpeedoUpdate()
{
for(new i = 0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
new Float:x,Float:y,Float:z,Float:hp,string[24],vehicleid = GetPlayerVehicleID(i);
TextDrawShowForPlayer(i,box[i]);
TextDrawShowForPlayer(i,speed[i]);
TextDrawShowForPlayer(i,health[i]);
TextDrawShowForPlayer(i,fuel[i]);
GetVehicleVelocity(vehicleid,x,y,z);
GetVehicleHealth(vehicleid,hp);
format(string,sizeof(string),"Velocidade: %dKm/h",floatround(floatsqroot(((x*x)+(y*y))+(z*z))*250.666667));
TextDrawSetString(speed[i],string);
format(string,sizeof(string),"Motor: %d%",floatround(hp));
TextDrawSetString(health[i],string);
format(string,sizeof(string),"Gasolina: %dL",VehicleFuel[vehicleid]);
TextDrawSetString(fuel[i],string);
}
if(!IsPlayerInAnyVehicle(i))
{
TextDrawHideForPlayer(i,box[i]);
TextDrawHideForPlayer(i,speed[i]);
TextDrawHideForPlayer(i,health[i]);
TextDrawHideForPlayer(i,fuel[i]);
}
}
}
public FuelUpdate()
{
for(new i = 1;i<MAX_VEHICLES;i++)
{
if(GetVehicleModel(i))
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine == 1)
{
if(VehicleFuel[i] > 0) VehicleFuel[i]--;
else SetVehicleParamsEx(i,0,lights,alarm,doors,bonnet,boot,objective);
}
}
}
}
//HORA
public OnPlayerSpawn(playerid)
{
time();
}
public time()
{
new Text:Clock;
new hour,minute,second;
gettime(hour,minute,second);
new string[256];
new string2[256];
if (minute <= 9){format(string,25,"%d:0%d",hour,minute);}
else {format(string,25,"%d:%d",hour,minute);}
TextDrawHideForAll(Clock);
Clock=TextDrawCreate(549,24,string);
TextDrawLetterSize(Clock,0.55,2);
TextDrawFont(Clock,3);
TextDrawBackgroundColor(Clock,0x000000AA);
TextDrawSetOutline(Clock,2);
TextDrawShowForAll(Clock);
SetTimer("time",30000,0);
if (hour == 0){SetWorldTime(0);}
if (hour == 1){SetWorldTime(1);}
if (hour == 2){SetWorldTime(2);}
if (hour == 3){SetWorldTime(3);}
if (hour == 4){SetWorldTime(4);}
if (hour == 5){SetWorldTime(5);}
if (hour == 6){SetWorldTime(6);}
if (hour == 7){SetWorldTime(7);}
if (hour == 8){SetWorldTime(8);}
if (hour == 9){SetWorldTime(9);}
if (hour == 10){SetWorldTime(10);}
if (hour == 11){SetWorldTime(11);}
if (hour == 12){SetWorldTime(12);}
if (hour == 13){SetWorldTime(13);}
if (hour == 14){SetWorldTime(14);}
if (hour == 15){SetWorldTime(15);}
if (hour == 16){SetWorldTime(16);}
if (hour == 17){SetWorldTime(17);}
if (hour == 18){SetWorldTime(18);}
if (hour == 19){SetWorldTime(19);}
if (hour == 20){SetWorldTime(20);}
if (hour == 21){SetWorldTime(21);}
if (hour == 22){SetWorldTime(22);}
if (hour == 23){SetWorldTime(23);}
if (hour == 24){SetWorldTime(24);}
//DATA
new Text:Datum;
new year,month,day;
getdate(year,month,day);
if (day <= 9){format(string2,25,"0%d.%d.%d",day,month,year);}
else if (month <= 9 && day >= 9) {format(string2,25,"%d/0%d/%d",day,month,year);}
else {format(string2,25,"%d.%d.%d",day,month,year);}
TextDrawHideForAll(Datum);
Datum=TextDrawCreate(29.000000, 429.000000,string2);
TextDrawFont(Datum, 2);
TextDrawLetterSize(Datum, 0.500000, 1.000000);
TextDrawColor(Datum, 0x878787FF);
TextDrawSetOutline(Datum, 0);
TextDrawSetProportional(Datum, 1);
TextDrawShowForAll(Datum);
return 1;
}
public OnFilterScriptExit()
{
TextDrawDestroy(Textdraw0);
TextDrawDestroy(Textdraw1);
}