- Регистрация
- 1 Авг 2012
- Сообщения
- 322
- Лучшие ответы
- 0
- Репутация
- 160
Всем приятного времени!
Писал мод с 0. Вот выкладываю спидометр с зажиганием авто на "CTRL".
Screen Спидометра:
И так приступим к зажиганию:
Нам понадобится инклуд: a_engine. ссылка:
.. приступим:
ко всем new:
в
в
в
C заводкой двигателя мы закончили.. теперь приступим к системе бензина:
Вот и закончили с бензином.. теперь приступим к спидометру:
Вот на этом и закончили..
Автор Спидометра: Nourthmar.
Автор заводки: мод Cherbet ( я лишь редактировал кнопку )
Ошибки будут - пишите в теме - исправим!
Дополнение:
ко всем new:
ко всем массивам ( в конец мода или у кого как )
Писал мод с 0. Вот выкладываю спидометр с зажиганием авто на "CTRL".
Screen Спидометра:
Чтобы видеть скрытое содержание Зарегистрируйтесь на форуме!
И так приступим к зажиганию:
Нам понадобится инклуд: a_engine. ссылка:
Чтобы видеть скрытое содержание Зарегистрируйтесь на форуме!
.. приступим:
ко всем new:
PHP:
new bool:EngineState[MAX_PLAYERS];
PHP:
public OnPlayerCommandText(playerid, cmdtext[])
PHP:
if(strcmp(cmd, "/двигатель", true) == 0)
{
if(EngineState[playerid] == false)
{
if(GetPlayerVehicleID(playerid) != INVALID_VEHICLE_ID)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid) ,VEHICLE_PARAMS_ON,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
format(string, sizeof(string), "%s завел(а) машину", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
EngineState[playerid] = true;
}
}
}
else if(EngineState[playerid] == true)
{
if(GetPlayerVehicleID(playerid) != INVALID_VEHICLE_ID)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
format(string, sizeof(string), "%s заглушил(а) машину", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
EngineState[playerid] = false;
}
}
}
return true;
}
PHP:
OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
PHP:
if(newkeys == KEY_ACTION) // как и говорил: эта кнопка CTRL
{
if(IsPlayerInAnyVehicle(playerid))
{
OnPlayerCommandText(playerid, "/двигатель");
}
}
PHP:
public OnGameModeInit()
PHP:
ManualVehicleEngineAndLights(); // это для того, что бы заработала заводка ( загружается из a_engine.inc )
C заводкой двигателя мы закончили.. теперь приступим к системе бензина:
ко всем new:
в
в
в
PHP:
new Float:Fuell[MAX_VEHICLES];
PHP:
enum pInfo
PHP:
Float:pFuelCar,
pFuel, // на них делаем сохранения. ( не буду расписывать )
PHP:
public OnGameModeInit()
PHP:
for(new v = 0; v < MAX_VEHICLES; v++)
{
Fuell[v] = 200; // при коннекте сколько бензина всем машинам будет давать.
}
PHP:
public OnPlayerConnect(playerid)
PHP:
PlayerInfo[playerid][pFuel] = 0;
Вот и закончили с бензином.. теперь приступим к спидометру:
ко всем forward:
ко всем new:
в
в
в
ко всем пабликам либо в конец мода:
в
у кого нету в конец мода:
PHP:
forward UpdateSpeedometr();
PHP:
new SpeedoTimer;
new Text:SpeedShow[MAX_PLAYERS];
new Text:VehiclenameShow[MAX_PLAYERS];
new Text:VehicleShow[MAX_PLAYERS];
new Text:KMShow[MAX_PLAYERS];
new Text:FillShow[MAX_PLAYERS];
new Text:FuelShow[MAX_PLAYERS];
new Text:Box[MAX_PLAYERS];
new Text:EngineShow[MAX_PLAYERS];
new str1[64], str2[64], str4[64], str5[64], str6[64], str8[64], str9[64];
new Text:EnginShow[MAX_PLAYERS];
new Text:CarShow[MAX_PLAYERS];
new Text:HealthShow[MAX_PLAYERS];
PHP:
public OnPlayerConnect(playerid)
PHP:
//==========================================================================
KMShow[playerid] = TextDrawCreate(383.000000, 408.000000, "KM/H");
TextDrawBackgroundColor(KMShow[playerid], 255);
TextDrawFont(KMShow[playerid], 2);
TextDrawLetterSize(KMShow[playerid], 0.200000, 1.000000);
TextDrawColor(KMShow[playerid], -1);
TextDrawSetOutline(KMShow[playerid], 0);
TextDrawSetProportional(KMShow[playerid], 1);
TextDrawSetShadow(KMShow[playerid], 1);
//==========================================================================
SpeedShow[playerid] = TextDrawCreate(354.000000, 408.000000, "_");
TextDrawBackgroundColor(SpeedShow[playerid], 255);
TextDrawFont(SpeedShow[playerid], 2);
TextDrawLetterSize(SpeedShow[playerid], 0.500000, 1.000000);
TextDrawColor(SpeedShow[playerid], -1);
TextDrawSetOutline(SpeedShow[playerid], 1);
TextDrawSetProportional(SpeedShow[playerid], 1);
//==========================================================================
VehicleShow[playerid] = TextDrawCreate(440.000000, 423.000000, "vehicle:");
TextDrawBackgroundColor(VehicleShow[playerid], 255);
TextDrawFont(VehicleShow[playerid], 2);
TextDrawLetterSize(VehicleShow[playerid], 0.109999, 1.000000);
TextDrawColor(VehicleShow[playerid], -1);
TextDrawSetOutline(VehicleShow[playerid], 0);
TextDrawSetProportional(VehicleShow[playerid], 1);
TextDrawSetShadow(VehicleShow[playerid], 1);
//==========================================================================
VehiclenameShow[playerid] = TextDrawCreate(461.000000, 423.000000, "_");
TextDrawBackgroundColor(VehiclenameShow[playerid], 255);
TextDrawFont(VehiclenameShow[playerid], 2);
TextDrawLetterSize(VehiclenameShow[playerid], 0.130000, 1.000000);
TextDrawColor(VehiclenameShow[playerid], 866844671);
TextDrawSetOutline(VehiclenameShow[playerid], 1);
TextDrawSetProportional(VehiclenameShow[playerid], 1);
//==========================================================================
FuelShow[playerid] = TextDrawCreate(383.000000, 397.000000, "Fuel");
TextDrawBackgroundColor(FuelShow[playerid], 255);
TextDrawFont(FuelShow[playerid], 2);
TextDrawLetterSize(FuelShow[playerid], 0.200000, 1.000000);
TextDrawColor(FuelShow[playerid], -1);
TextDrawSetOutline(FuelShow[playerid], 0);
TextDrawSetProportional(FuelShow[playerid], 1);
TextDrawSetShadow(FuelShow[playerid], 1);
//======
FillShow[playerid] = TextDrawCreate(353.000000, 397.000000, "_");
TextDrawBackgroundColor(FillShow[playerid], 255);
TextDrawFont(FillShow[playerid], 2);
TextDrawLetterSize(FillShow[playerid], 0.370000, 1.000000);
TextDrawColor(FillShow[playerid], -1);
TextDrawSetOutline(FillShow[playerid], 1);
TextDrawSetProportional(FillShow[playerid], 1);
//======
EngineShow[playerid] = TextDrawCreate(382.000000, 423.000000, "__");
TextDrawBackgroundColor(EngineShow[playerid], 255);
TextDrawFont(EngineShow[playerid], 2);
TextDrawLetterSize(EngineShow[playerid], 0.110000, 1.000000);
TextDrawColor(EngineShow[playerid], -1);
TextDrawSetOutline(EngineShow[playerid], 1);
TextDrawSetProportional(EngineShow[playerid], 1);
//=====
Box[playerid] = TextDrawCreate(533.000000, 393.000000, "____");
TextDrawBackgroundColor(Box[playerid], 255);
TextDrawFont(Box[playerid], 1);
TextDrawLetterSize(Box[playerid], 1.309998, 4.499999);
TextDrawColor(Box[playerid], -1);
TextDrawSetOutline(Box[playerid], 0);
TextDrawSetProportional(Box[playerid], 1);
TextDrawSetShadow(Box[playerid], 1);
TextDrawUseBox(Box[playerid], 1);
TextDrawBoxColor(Box[playerid], COLOR_BOX);
TextDrawTextSize(Box[playerid], 348.000000, 27.000000);
//=======================
EnginShow[playerid] = TextDrawCreate(354.000000, 423.000000, "Engine:");
TextDrawBackgroundColor(EnginShow[playerid], 255);
TextDrawFont(EnginShow[playerid], 2);
TextDrawLetterSize(EnginShow[playerid], 0.160000, 1.000000);
TextDrawColor(EnginShow[playerid], -1);
TextDrawSetOutline(EnginShow[playerid], 0);
TextDrawSetProportional(EnginShow[playerid], 1);
TextDrawSetShadow(EnginShow[playerid], 1);
//=======================
CarShow[playerid] = TextDrawCreate(399.000000, 423.000000, "CAR:");
TextDrawBackgroundColor(CarShow[playerid], 255);
TextDrawFont(CarShow[playerid], 2);
TextDrawLetterSize(CarShow[playerid], 0.150000, 1.000000);
TextDrawColor(CarShow[playerid], -1);
TextDrawSetOutline(CarShow[playerid], 0);
TextDrawSetProportional(CarShow[playerid], 1);
TextDrawSetShadow(CarShow[playerid], 1);
//==========================
HealthShow[playerid] = TextDrawCreate(414.000000, 423.000000, "_");
TextDrawBackgroundColor(HealthShow[playerid], 255);
TextDrawFont(HealthShow[playerid], 2);
TextDrawLetterSize(HealthShow[playerid], 0.150000, 1.000000);
TextDrawColor(HealthShow[playerid], -1);
TextDrawSetOutline(HealthShow[playerid], 0);
TextDrawSetProportional(HealthShow[playerid], 1);
TextDrawSetShadow(HealthShow[playerid], 1);
//==========================
PHP:
public OnPlayerDisconnect(playerid, reason)
PHP:
TextDrawDestroy(SpeedShow[playerid]);
TextDrawDestroy(VehicleShow[playerid]);
TextDrawDestroy(VehiclenameShow[playerid]);
TextDrawDestroy(KMShow[playerid]);
TextDrawDestroy(FuelShow[playerid]);
TextDrawDestroy(Box[playerid]);
TextDrawDestroy(EngineShow[playerid]);
TextDrawDestroy(EnginShow[playerid]);
TextDrawDestroy(CarShow[playerid]);
TextDrawDestroy(HealthShow[playerid]);
TextDrawDestroy(FillShow[playerid]);
PHP:
public OnPlayerStateChange(playerid, newstate, oldstate)
PHP:
new tacha = GetPlayerVehicleID(playerid);
if(newstate == PLAYER_STATE_DRIVER)
{
if(!IsAPlane(tacha) && !IsABoat(tacha) && !IsANoSpeed(tacha))
{
TextDrawShowForPlayer(playerid,SpeedShow[playerid]);
TextDrawShowForPlayer(playerid,KMShow[playerid]);
TextDrawShowForPlayer(playerid,FuelShow[playerid]);
TextDrawShowForPlayer(playerid,Box[playerid]);
TextDrawShowForPlayer(playerid,EngineShow[playerid]);
TextDrawShowForPlayer(playerid,EnginShow[playerid]);
TextDrawShowForPlayer(playerid,CarShow[playerid]);
TextDrawShowForPlayer(playerid,HealthShow[playerid]);
TextDrawShowForPlayer(playerid,FillShow[playerid]);
TextDrawShowForPlayer(playerid,VehicleShow[playerid]);
TextDrawShowForPlayer(playerid,VehiclenameShow[playerid]);
Arrester[playerid] = true;
}
}
if(newstate == PLAYER_STATE_ONFOOT)
{
if(!IsAPlane(tacha) && !IsABoat(tacha) && !IsANoSpeed(tacha))
{
TextDrawHideForPlayer(playerid,SpeedShow[playerid]);
TextDrawHideForPlayer(playerid,KMShow[playerid]);
TextDrawHideForPlayer(playerid,EngineShow[playerid]);
TextDrawHideForPlayer(playerid,EnginShow[playerid]);
TextDrawHideForPlayer(playerid,FillShow[playerid]);
TextDrawHideForPlayer(playerid,Box[playerid]);
TextDrawHideForPlayer(playerid,FuelShow[playerid]);
TextDrawHideForPlayer(playerid,HealthShow[playerid]);
TextDrawHideForPlayer(playerid,CarShow[playerid]);
TextDrawHideForPlayer(playerid,VehicleShow[playerid]);
TextDrawHideForPlayer(playerid,VehiclenameShow[playerid]);
Arrester[playerid] = false;
}
}
PHP:
public UpdateSpeedometr()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new string[128];
new vehicleid = GetPlayerVehicleID(i);
new Float: carhp;
GetVehicleHealth(vehicleid, carhp);
if(IsPlayerInAnyVehicle(i))
{
format(str1, sizeof(str1), "%d", SpeedVehicle(i));
if(Fuell[vehicleid] <= 45) format(str2, sizeof(str2), "~r~%.0f", Fuell[vehicleid]);
else if(Fuell[vehicleid] <= 100) format(str2, sizeof(str2), "~y~%.0f", Fuell[vehicleid]);
else if(Fuell[vehicleid] <= 300) format(str2, sizeof(str2), "~g~%.0f", Fuell[vehicleid]);
format(str4, sizeof(str4), "Fuel");
format(str8, sizeof(str8), "%.0f%", carhp);
format(str9, sizeof(str9), "%s", VehicleNames[GetVehicleModel(GetPlayerVehicleID(i))-400]);
if(carhp < 500) format(str8, sizeof(str8), "~g~%.0f%", carhp);
else if(carhp < 300) format(str8, sizeof(str8), "~r~%.0f%", carhp);
if(EngineState[i] == true)
{
format(str5, sizeof(str5), "~g~ ON");
}
else { format(str5, sizeof(str5), "~r~ OFF"); }
if(Fuell[vehicleid] <= 0)
{
if(!IsAPlane(vehicleid) && !IsABoat(vehicleid) && !IsANoSpeed(vehicleid))
{
format(string, sizeof(string), "~r~FUEL END");
Fuell[vehicleid] = 0;
GameTextForPlayer(i, string, 5000, 1);
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
EngineState[i] = false;
}
}
if(!IsAPlane(vehicleid) && !IsABoat(vehicleid) && !IsANoSpeed(vehicleid))
{
if(SpeedVehicle(i) != 0 || EngineState[i] == true)
{
Fuell[vehicleid] -= 0.0096;
}
}
TextDrawSetString(SpeedShow[i],str1);
TextDrawSetString(FuelShow[i],str4);
TextDrawSetString(EngineShow[i],str5);
TextDrawSetString(FillShow[i],str2);
TextDrawSetString(HealthShow[i],str8);
TextDrawSetString(VehiclenameShow[i],str9);
}
}
}
PHP:
public OnGameModeInit()
PHP:
SpeedoTimer = SetTimer("UpdateSpeedometr", 100, true);// сам спидометр.
PHP:
stock IsABoat(carid){switch(GetVehicleModel(carid)){case 472,473,493,595,484,430,452..454,446:return true;}return false;}
stock IsAPlane(carid){switch(GetVehicleModel(carid)){case 592,577,511,512,593,520,553,476,519,460,513,548,417,487,488,497,563,447,469:return true;}return false;}
stock IsANoSpeed(carid){switch(GetVehicleModel(carid)){case 441,448,449,450,462,464,465,481,501,509,510,537,538,564,569,570,590,591,594,606,607,608,610,611:return true;}return false;}
Вот на этом и закончили..
Автор Спидометра: Nourthmar.
Автор заводки: мод Cherbet ( я лишь редактировал кнопку )
Ошибки будут - пишите в теме - исправим!
Дополнение:
ко всем new:
PHP:
new VehicleNames[212][] = { "Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster","Stretch","Manana","Infernus", "Voodoo","Pony","Mule","Cheetah","Ambulance","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","ZR3 50","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 A","Hotring 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","Police Car","Police Car", "Police Car","Police Ranger","Picador","S.W.A.T.","Alpha","Phoenix","Glendale","Sadler","L Trailer A","L Trailer B", "Stair Trailer","Boxville","Farm Plow","U Trailer" };
PHP:
Arrester // удаляем - это лишнее.
ко всем массивам ( в конец мода или у кого как )
PHP:
stock SpeedVehicle(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)) * 100.3;
return floatround(ST[3]);
}
Последнее редактирование модератором: