Главный редактор форума: Doc-John | Текущая дата: 30.11.2024, 06:37
  • Страница 1 из 1
  • 1
[Мануал] Спидометр
Оффлайн
Пятница, 18.07.2014, 20:27 | Сообщение # 1
Сообщений:
12
2
"Здравствуйте, уважаемые форумчане!
В этой теме я научу Вас, как... " - создать Спидометр
Специально для игрового портала isamp.3dn.ru.
Автор: ARTEM_SKOROBAGACH


в new

Код
new bool:RefuelVehicle[MAX_VEHICLES];
new Text:Box[MAX_PLAYERS];
new Text:speed[MAX_PLAYERS],Text:health[MAX_PLAYERS],Text:fuel[MAX_PLAYERS],Text:OGRAN[MAX_PLAYERS],Text:FAR[MAX_PLAYERS],Text:lock[MAX_PLAYERS],Text:ESC[MAX_PLAYERS],Text:Fue[MAX_PLAYERS];
new VehicleFuel[MAX_VEHICLES];
new zavodis[MAX_VEHICLES];
new bag1[MAX_VEHICLES];
new kap1[MAX_VEHICLES];

В public OnGameModeInit

Код
SetTimer("SpeedoUpdate",400,1), SetTimer("FuelUpdate",40000,1);


В конец мода

Код
forward SpeedoUpdate();
public SpeedoUpdate()
{
foreach(Player, i)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
if(!IsABMX(GetPlayerVehicleID(i)))
{
new vehe[20],esc[20],ogran[20],fue[20],far[20];
TextDrawShowForPlayer(i,speed[i]);
TextDrawShowForPlayer(i,ESC);
TextDrawShowForPlayer(i,OGRAN);
TextDrawShowForPlayer(i,FAR);
TextDrawShowForPlayer(i,Box);
TextDrawShowForPlayer(i,health);
TextDrawShowForPlayer(i,Fue);
TextDrawShowForPlayer(i,fuel);
TextDrawShowForPlayer(i,lock);
new Float:x,Float:y,Float:z,Float:hp,string[24],vehicleid = GetPlayerVehicleID(i);
GetVehicleVelocity(vehicleid,x,y,z);
GetVehicleHealth(vehicleid,hp);
format(string,sizeof(string),"%d KM/H",floatround(floatsqroot(((x*x)+(y*y))+(z*z))*156.666667));
TextDrawSetString(speed,string);
format(string,sizeof(string),"~b~%d",floatround(hp));
TextDrawSetString(health,string);
format(string,sizeof(string),"Fuel %d",VehicleFuel[vehicleid]);
TextDrawSetString(fuel,string);
if(IsLocked[GetPlayerVehicleID(i)] == 1) vehe = "~r~LOCK";
else vehe = "~g~OPEN";
format(string,sizeof(string),"%s",vehe);
TextDrawSetString(lock,string);
if(zavodis[GetPlayerVehicleID(i)] == 0) esc = "~w~E";
else esc = "~g~E";
if(akavandal[GetPlayerVehicleID(i)] == 0) far = "~w~S";
else far = "~g~S";
if(Ogran[GetPlayerVehicleID(i)] == 0) ogran = "~w~MAX";
else ogran = "~r~MAX";
format(string,sizeof(string),"%s",far);
TextDrawSetString(FAR, string);
format(string,sizeof(string),"%s",ogran);
TextDrawSetString(OGRAN, string);
format(string,sizeof(string),"%s",esc);
TextDrawSetString(ESC, string);
format(string,sizeof(string),"%s",fue);
TextDrawSetString(Fue, string);
}
}
if(!IsPlayerInAnyVehicle(i))
{
TextDrawHideForPlayer(i,speed);
TextDrawHideForPlayer(i,Box);
TextDrawHideForPlayer(i,lock);
TextDrawHideForPlayer(i,health);
TextDrawHideForPlayer(i,fuel);
TextDrawHideForPlayer(i,OGRAN);
TextDrawHideForPlayer(i,ESC);
TextDrawHideForPlayer(i,FAR);
TextDrawHideForPlayer(i,Fue);
}
if(Ogran[GetPlayerVehicleID(i)] == 1)
{
#define MAX_SPEEDO 0.4
#define SLOW_FACTOR 0.6 // ?? ??????? ????? ?????????? ????????
new Float:xx,Float:yy,Float:zz, veh = GetPlayerVehicleID(i);
GetVehicleVelocity(veh,xx,yy,zz);
if((xx > MAX_SPEEDO || xx < -MAX_SPEEDO) || (yy > MAX_SPEEDO || yy < -MAX_SPEEDO)) SetVehicleVelocity(veh,xx*SLOW_FACTOR,yy*SLOW_FACTOR,zz);
return 1;
}
}
}
forward FuelUpdate();
public FuelUpdate()
{
for(new i = 1;i<MAX_VEHICLES;i++)
{
if(GetVehicleModel(i) && !IsABMX(i))
{
GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine == 1)
{
if(VehicleFuel > 0) VehicleFuel--;
else SetVehicleParamsEx(i,0,lights,alarm,doors,bonnet,boot,objective);
}
}
}
}


public Ongamemodeinit

Код
speed [playerid]= TextDrawCreate(377.000000+41,398.500000,"_");
TextDrawColor(speed[playerid],0x22CCFFAA);
TextDrawLetterSize(speed[playerid],0.45,1.629999);
TextDrawSetOutline(speed[playerid],1);
TextDrawFont(speed[playerid], 3);
health [playerid]= TextDrawCreate(377.000000+190.2,398.500000,"_");
TextDrawLetterSize(health[playerid],0.45,1.629999);
TextDrawSetOutline(health[playerid],1);
TextDrawFont(health[playerid], 3);
fuel [playerid]= TextDrawCreate(377.000000+117.6,398.500000,"_");
TextDrawLetterSize(fuel[playerid],0.45,1.629999);
TextDrawColor(fuel[playerid],0x01FCFFC8);
TextDrawSetOutline(fuel[playerid],1);
TextDrawFont(fuel[playerid], 3);
lock [playerid]= TextDrawCreate(377.000000+41,370.000000+43.5,"_");
TextDrawLetterSize(lock[playerid],0.45,1.629999);
TextDrawSetOutline(lock[playerid],1);
TextDrawFont(lock[playerid], 3);
ESC [playerid]= TextDrawCreate(377.000000+153.2,370.000000+43.5,"_");
TextDrawLetterSize(ESC[playerid],0.45,1.629999);
TextDrawSetOutline(ESC[playerid],1);
TextDrawFont(ESC[playerid], 3);
//
OGRAN [playerid]= TextDrawCreate(377.000000+85.2,370.000000+43.5,"_");
TextDrawLetterSize(OGRAN[playerid],0.45,1.629999);
TextDrawSetOutline(OGRAN[playerid],1);
TextDrawFont(OGRAN[playerid], 3);
//
FAR [playerid]= TextDrawCreate(377.000000+133.2,370.000000+43.5,"_");
TextDrawLetterSize(FAR[playerid],0.45,1.629999);
TextDrawSetOutline(FAR[playerid],1);
TextDrawFont(FAR[playerid], 3);
Fue [playerid]= TextDrawCreate(377.000000+142.2,370.000000+43.5,"_");
TextDrawLetterSize(Fue[playerid],0.45,1.629999);
TextDrawSetOutline(Fue[playerid],1);
TextDrawFont(Fue[playerid], 3);
  • Страница 1 из 1
  • 1
Поиск: