[Pawn.CMD] /veh с админ-машиной

Sun_Deep

• Зарегистрированный •
Регистрация
29 Июл 2018
Сообщения
8
Реакции
1
Доброго времени суток дорогие друзья. С вами я Sun Deep

Сегодня хочу вам показать систему админ-машин.

Сперва давайте добавим два переменных.

PHP:
new aveh[MAX_PLAYERS];//создание машин
new cars[MAX_PLAYERS];//добавление машин
Теперь перейдём на команду

PHP:
cmd:veh(playerid, params[])
{
    if(/*авторизован ли*/ == false) return LSCM
    if(/*админ проверка*/ < 3) return true;
    if(/*проверка админ авторизации*/ == false) return SendClientMessage(playerid,-1,"{ff0000}* {FFFFFF}/alogin");
    new string[100];
    new Float: X, Float: Y, Float: Z, Float: Angle;
    if(sscanf(params,"iii", params[0], params[1], params[2])) return SendClientMessage(playerid, 0xffffffff, "Введите: /veh [id] [color1] [color2]");
    if(params[0] < 400 || params[0] > 611) return SendClientMessage(playerid, 0x808080ff, "ID машин не больше 400 и не меньше 611!");
    if(params[1] < 0 || params[1] > 255) return SendClientMessage(playerid, 0x808080ff, "ID цветов не меньше 0 и не больше 255!");
    if(params[2] < 0 || params[2] > 255) return SendClientMessage(playerid, 0x808080ff, "ID цветов не меньше 0 и не больше 255");
    if(vehiclek[playerid] != 0) DestroyVehicle(AdminVehicle[playerid]), vehiclek[playerid]--;
    format(string, sizeof(string), "Àâòîìîáèëü ID: %d ñîçäàíî", params[0]);
    SendClientMessage(playerid, 0xff0000ff, string);
    GetPlayerFacingAngle(playerid, Angle);
    GetPlayerPos(playerid, X,Y,Z);
    cars[playerid]++;
    aveh[playerid] = CreateVehicle(params[0], X, Y, Z, Angle, params[1], params[2], 99999);
    PutPlayerInVehicle(playerid, aveh[playerid], 0);
    return true;
}
Теперь переходим сюда
PHP:
public OnPlayerDisconnect(playerid, reason)
Пишем туда вот это. Для того чтобы при выходе администратора его созданные машины удалились
PHP:
    if(/*админ проверка*/ > 0 || cars[playerid] > 0)
	{
	    aveh[playerid] = 0;
	    cars[playerid] = 0;
	}
Вот и всё. Меняйте на свои. Думаю + заслуживает

-------------------------------------------------------------

Забыл при коннекте обнулить сорри

Переходим сюда

PHP:
public OnPlayerConnect(playerid)
Пишем сюда то что я написал тут
PHP:
aveh[playerid] = 0;
cars[playerid] = 0;
 
Последнее редактирование:

$Blade#

Участник форума
Пользователь
Регистрация
24 Фев 2019
Сообщения
101
Реакции
7
Даже скопировать не смог нормально...

что это?

PHP:
format(string, sizeof(string), "Àâòîìîáèëü ID: %d ñîçäàíî", params[0]);
 

#pragma

Участник форума
Пользователь
Регистрация
4 Дек 2017
Сообщения
417
Реакции
45
Что это?
PHP:
vehiclek[playerid]
А это что?
PHP:
AdminVehicle[playerid]
Я инопланетянский не учил
PHP:
format(string, sizeof(string), "Àâòîìîáèëü ID: %d ñîçäàíî", params[0]);
Нуу ты понял...
PHP:
LSCM
Думаю тут бы и 30 хватило.
PHP:
new string[100];
 
Последнее редактирование:

red.inc

Участник форума
Пользователь
Регистрация
20 Июл 2019
Сообщения
130
Реакции
6
Очень слабый код. Постарался бы ты над работой
 

Valera_Kovshikov

Специалист
Пользователь
Регистрация
28 Сен 2013
Сообщения
754
Реакции
125
Предложу такой вариант

Использовать очень легко, /veh id тачки/её название <цвет1> <цвет2>

PHP:
CMD:veh(playerid, params[])
{
    new model[32], color1, color2, string[MAX_CHATBUBBLE_LENGTH +1];
    
    if (sscanf(params, "s[32]I(-1)I(-1)", model, color1, color2))
    return SendClientMessage(playerid, -1, "/veh [model id/name] <color 1> <color 2>");
    
    if ((model[0] = GetVehicleModelByName(model)) == 0)
    return SendClientMessage(playerid, -1, "Неверный ID автомобиля.");
    
    new Float:x, Float:y, Float:z, Float:a, vehicleid;
    
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);
    
    vehicleid = CreateVehicle(model[0], x, y + 2, z, a, color1, color2, 0);
    
    if (GetPlayerInterior(playerid) != 0)
    LinkVehicleToInterior(vehicleid, GetPlayerInterior(playerid));
    
    if (GetPlayerVirtualWorld(playerid) != 0)
    SetVehicleVirtualWorld(vehicleid, GetPlayerVirtualWorld(playerid));
    
    PutPlayerInVehicle(playerid, vehicleid, 0);
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    format(string, sizeof(string), "Вы создали автомобиль %s, с цветами %d и %d.", ReturnVehicleModelName(model[0]), color1, color2);
    SendClientMessage(playerid, -1, string);
    return true;
}
PHP:
new stock Vehicles[][] = {
    "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", "SWAT Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan",
    "Blade", "Streak", "Freight", "Vortex", "Vincent", "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder",
    "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor", "Monster", "Monster",
    "Uranus", "Jester", "Sultan", "Stratum", "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", "LSPD Car", "SFPD Car", "LVPD Car",
    "Police Rancher", "Picador", "S.W.A.T", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs",
    "Boxville", "Tiller", "Utility Trailer"
};
IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return false;
    }
    return true;
}
GetVehicleModelByName(const name[])
{
    if (IsNumeric(name) && (strval(name) >= 400 && strval(name) <= 611))
    return strval(name);
    
    for (new i = 0; i < sizeof(Vehicles); i ++)
    {
        if (strfind(Vehicles[i], name, true) != -1)
        {
            return i + 400;
        }
    }
    return false;
}
ReturnVehicleModelName(model)
{
    new name[32] = "None";
    
    if (model < 400 || model > 611)
    return name;
    
    format(name, sizeof(name), Vehicles[model - 400]);
    return name;
}
 
Последнее редактирование:

execution

Участник форума
Пользователь
Регистрация
23 Июн 2017
Сообщения
351
Реакции
53
Предложу такой вариант

Использовать очень легко, /veh id тачки/её название <цвет1> <цвет2>

PHP:
CMD:veh(playerid, params[])
{
    new model[32], color1, color2, string[MAX_CHATBUBBLE_LENGTH +1];
    
    if (sscanf(params, "s[32]I(-1)I(-1)", model, color1, color2))
    return SendClientMessage(playerid, -1, "/veh [model id/name] <color 1> <color 2>");
    
    if ((model[0] = GetVehicleModelByName(model)) == 0)
    return SendClientMessage(playerid, -1, "Неверный ID автомобиля.");
    
    new Float:x, Float:y, Float:z, Float:a, vehicleid;
    
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);
    
    vehicleid = CreateVehicle(model[0], x, y + 2, z, a, color1, color2, 0);
    
    if (GetPlayerInterior(playerid) != 0)
    LinkVehicleToInterior(vehicleid, GetPlayerInterior(playerid));
    
    if (GetPlayerVirtualWorld(playerid) != 0)
    SetVehicleVirtualWorld(vehicleid, GetPlayerVirtualWorld(playerid));
    
    PutPlayerInVehicle(playerid, vehicleid, 0);
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    format(string, sizeof(string), "Вы создали автомобиль %s, с цветами %d и %d.", ReturnVehicleModelName(model[0]), color1, color2);
    SendClientMessage(playerid, -1, string);
    return true;
}
PHP:
new stock Vehicles[][] = {
    "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", "SWAT Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan",
    "Blade", "Streak", "Freight", "Vortex", "Vincent", "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder",
    "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor", "Monster", "Monster",
    "Uranus", "Jester", "Sultan", "Stratum", "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", "LSPD Car", "SFPD Car", "LVPD Car",
    "Police Rancher", "Picador", "S.W.A.T", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs",
    "Boxville", "Tiller", "Utility Trailer"
};
IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return false;
    }
    return true;
}
GetVehicleModelByName(const name[])
{
    if (IsNumeric(name) && (strval(name) >= 400 && strval(name) <= 611))
    return strval(name);
    
    for (new i = 0; i < sizeof(Vehicles); i ++)
    {
        if (strfind(Vehicles[i], name, true) != -1)
        {
            return i + 400;
        }
    }
    return false;
}
ReturnVehicleModelName(model)
{
    new name[32] = "None";
    
    if (model < 400 || model > 611)
    return name;
    
    format(name, sizeof(name), Vehicles[model - 400]);
    return name;
}
Только забыл объявить переменные
PHP:
engine,lights,alarm,doors,bonnet,boot,objective
Можно воспользоваться лишь раз функцией strval
PHP:
GetVehicleModelByName(const name[])
{
	new
		valueVehicle = strval(name);
    if (IsNumeric(name) && (400 <= valueVehicle <= 611))
    	return valueVehicle;
    
    for (new i = 0; i < sizeof(Vehicles); i ++)
    {
        if (strfind(Vehicles[i], name, true) != -1)
        {
            return i + 400;
        }
    }
    return false;
}
Почему бы не хотел сделать функцию, по типу GetVehicleModelName и передавать туда уже массив для записи, дабы не забивать стэк?
PHP:
GetVehicleModelName(model, string, const size = sizeof string)
{
	static const MAX_VEHICLE_NAME_LENGTH = sizeof(Vehicles[]);
	if (strlen(string) < MAX_VEHICLE_NAME_LENGTH
	|| !(400 <= model <= 611))
		return 0;
	
	strcat(string, Vehicles[model-400], size);
	
	return 1;
}
 
Последнее редактирование:

bogdasha12

Участник форума
Пользователь
Регистрация
1 Фев 2019
Сообщения
105
Реакции
2
Как машина будет удалятся при оффе играка?
 

Sapph1re

• Зарегистрированный •
Регистрация
8 Дек 2019
Сообщения
1
Реакции
0
Аналог паблика, оптимизации нету, проверки старые.:an:
 

Команда форума онлайн

  • Serg_Brain
    • Главный Супер Модератор •
  • ReCaptcha
    • Модератор 2 lvl •

Реклама

Сверху