Mathian
Мастер
Всем Хай!
Давненько я не выкладывал работ на Pawn. Так вот, решил сделать и выложить свой первый спидометр.
Правда есть не большой косяк со здоровьем, кто знает - отпишите. Вообщем оценивайте xD
Давненько я не выкладывал работ на Pawn. Так вот, решил сделать и выложить свой первый спидометр.
Правда есть не большой косяк со здоровьем, кто знает - отпишите. Вообщем оценивайте xD
Скрины:
И так приступим к написанию.
Ко всем переменным:
PHP:
new Text:Box[2];
new Text:Speed[4][MAX_PLAYERS];
new CarName[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:
SetTimer("SpeedoUpdate",100,1);
Box[0] = TextDrawCreate(510.000000, 388.000000, "_");
TextDrawBackgroundColor(Box[0], 255);
TextDrawFont(Box[0], 5);
TextDrawLetterSize(Box[0], 0.899999, 1.000000);
TextDrawColor(Box[0], 170);
TextDrawSetOutline(Box[0], 0);
TextDrawSetProportional(Box[0], 1);
TextDrawSetShadow(Box[0], 1);
TextDrawUseBox(Box[0], 1);
TextDrawBoxColor(Box[0], 255);
TextDrawTextSize(Box[0], 122.000000, 51.000000);
TextDrawSetSelectable(Box[0], 0);
Box[1] = TextDrawCreate(510.000000, 364.000000, "_");
TextDrawBackgroundColor(Box[1], 255);
TextDrawFont(Box[1], 5);
TextDrawLetterSize(Box[1], 0.899999, 1.000000);
TextDrawColor(Box[1], 170);
TextDrawSetOutline(Box[1], 0);
TextDrawSetProportional(Box[1], 1);
TextDrawSetShadow(Box[1], 1);
TextDrawUseBox(Box[1], 1);
TextDrawBoxColor(Box[1], 255);
TextDrawTextSize(Box[1], 122.000000, 21.000000);
TextDrawSetSelectable(Box[1], 0);
PHP:
TextDrawHideForAll(Box[0]);
TextDrawDestroy(Box[0]);
TextDrawHideForAll(Box[1]);
TextDrawDestroy(Box[1]);
PHP:
Speed[0][playerid] = TextDrawCreate(571.000000, 368.000000, "NRG-500");
TextDrawAlignment(Speed[0][playerid], 2);
TextDrawBackgroundColor(Speed[0][playerid], 255);
TextDrawFont(Speed[0][playerid], 2);
TextDrawLetterSize(Speed[0][playerid], 0.449999, 1.299998);
TextDrawColor(Speed[0][playerid], -1);
TextDrawSetOutline(Speed[0][playerid], 1);
TextDrawSetProportional(Speed[0][playerid], 1);
TextDrawSetSelectable(Speed[0][playerid], 0);
Speed[1][playerid] = TextDrawCreate(516.000000, 391.000000, "~r~S~w~peed:");
TextDrawBackgroundColor(Speed[1][playerid], 255);
TextDrawFont(Speed[1][playerid], 1);
TextDrawLetterSize(Speed[1][playerid], 0.439999, 1.600000);
TextDrawColor(Speed[1][playerid], -1);
TextDrawSetOutline(Speed[1][playerid], 1);
TextDrawSetProportional(Speed[1][playerid], 1);
TextDrawSetSelectable(Speed[1][playerid], 0);
Speed[2][playerid] = TextDrawCreate(515.000000, 405.000000, "~r~F~w~uel:");
TextDrawBackgroundColor(Speed[2][playerid], 255);
TextDrawFont(Speed[2][playerid], 1);
TextDrawLetterSize(Speed[2][playerid], 0.439999, 1.600000);
TextDrawColor(Speed[2][playerid], -1);
TextDrawSetOutline(Speed[2][playerid], 1);
TextDrawSetProportional(Speed[2][playerid], 1);
TextDrawSetSelectable(Speed[2][playerid], 0);
Speed[3][playerid] = TextDrawCreate(517.000000, 418.000000, "~r~H~w~ealth:");
TextDrawBackgroundColor(Speed[3][playerid], 255);
TextDrawFont(Speed[3][playerid], 1);
TextDrawLetterSize(Speed[3][playerid], 0.439999, 1.600000);
TextDrawColor(Speed[3][playerid], -1);
TextDrawSetOutline(Speed[3][playerid], 1);
TextDrawSetProportional(Speed[3][playerid], 1);
TextDrawSetSelectable(Speed[3][playerid], 0);
PHP:
TextDrawHideForAll(Speed[0][playerid]);
TextDrawDestroy(Speed[0][playerid]);
TextDrawHideForAll(Speed[1][playerid]);
TextDrawDestroy(Speed[1][playerid]);
TextDrawHideForAll(Speed[2][playerid]);
TextDrawDestroy(Speed[2][playerid]);
TextDrawHideForAll(Speed[3][playerid]);
TextDrawDestroy(Speed[3][playerid]);
PHP:
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
TextDrawShowForPlayer(playerid, Box[0]);
TextDrawShowForPlayer(playerid, Box[1]);
TextDrawShowForPlayer(playerid, Speed[0][playerid]);
TextDrawShowForPlayer(playerid, Speed[1][playerid]);
TextDrawShowForPlayer(playerid, Speed[2][playerid]);
TextDrawShowForPlayer(playerid, Speed[3][playerid]);
}
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
TextDrawHideForPlayer(playerid, Box[0]);
TextDrawHideForPlayer(playerid, Box[1]);
TextDrawHideForPlayer(playerid, Speed[0][playerid]);
TextDrawHideForPlayer(playerid, Speed[1][playerid]);
TextDrawHideForPlayer(playerid, Speed[2][playerid]);
TextDrawHideForPlayer(playerid, Speed[3][playerid]);
}
В конец:
PHP:
forward SpeedoUpdate();
public SpeedoUpdate()
{
new string[255];
for(new i; i<MAX_PLAYERS; i++)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new Float:vhealth;
GetVehicleHealth(GetPlayerVehicleID(i), vhealth);
format(string, sizeof(string), "%s", CarName[GetVehicleModel(GetPlayerVehicleID(i))-400]);
TextDrawSetString(Speed[0][i], string);
format(string, sizeof(string), "~r~S~w~peed: %d", GetVehicleSpeed(i));
TextDrawSetString(Speed[1][i], string);
format(string, sizeof(string), "~r~F~w~uel: %d", /*ваш бензин*/);
TextDrawSetString(Speed[2][i], string);
format(string, sizeof(string), "~r~H~w~ealth: %.1f", vhealth/10);
TextDrawSetString(Speed[3][i], string);
}
}
return 1;
}
GetVehicleSpeed(playerid)
{
new Float:speed[3];
GetVehicleVelocity(GetPlayerVehicleID(playerid),speed[0],speed[1],speed[2]);
return floatround(floatsqroot(floatpower(floatabs(speed[0]), 2.0) + floatpower(floatabs(speed[1]), 2.0) + floatpower(floatabs(speed[2]), 2.0)) * 253.3);
}
Если вы посмотрели тему и есть, что ответить или посоветовать - не держите, отпишите. Я с удовольствием почитаю.
Отдельное спасибо #iBlack и Vano_Glad за то, что пытались объяснить как это делается т.к. с TD я не очень, хоть ничего и не вышло xD
Автор: Я ((Lev_Popov))
Последнее редактирование:
