Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * SA-MP Editor Attached Objets v1.0 beta
- *
- * За основу был взят стандартный FS attachments.
- *
- * Описание:
- * Это редактор пириатаченых объектов. За основу был взят стандартный FS attachments.
- *
- * Особенности:
- * Можно крипить объекты к игроку
- * Можно выбрать объект из списка или указать свой ID.
- * Можно крепить объекты на разные части тела.
- * Можно удалять объекты с игрока
- * Можно сохранять данные в sql-таблицу.
- * Автоматическое создание таблицы (если ее нет)
- * Скрипт использует MySQL R6
- * Если выбрали объект который уже есть в базе, то его координаты будут загружены и вы сможете продолжить редактирование.
- *
- * Copyright © 2012 MacMiller. All Rights Reserved.
- */
- // Инклуды
- #include <a_samp>
- #include <a_mysql>
- #include <sscanf2>
- // Данные БД
- #define bd_HOST "localhost"
- #define bd_USER "root"
- #define bd_NAME "reality"
- #define bd_PASS ""
- #define bd:: mysql_
- #define CMD(%0) if(strcmp(%0) == 0)
- // Диалоги
- #define D_INDEX 13500
- #define D_ATTACH_SLOT D_INDEX+100
- #define D_ATTACH_EDIT D_INDEX+200
- #define D_ATTACH_BONE D_INDEX+300
- #define D_ATTACH_EXIT D_INDEX+400
- #define D_ATTACH_SAVE D_INDEX+500
- #define D_ATTACH_MODEL D_INDEX+600
- #define Send SendClientMessage
- #define SPD ShowPlayerDialog
- new
- tmp [512],
- dlgstr [2048]
- ;
- new
- Text:TD_EAO,
- Text:TD_EAO2
- ;
- enum aEnum
- {
- aModel,
- aName[24 char]
- }
- new AttachObjects[][aEnum] = {
- {18632, !"Удочка"},
- {18633, !"GTASAWrench1"},
- {18634, !"GTASACrowbar1"},
- {18635, !"GTASAHammer1"},
- {18636, !"Кепка мента"},
- {18637, !"PoliceShield"},
- {18638, !"HardHat1"},
- {18639, !"BlackHat1"},
- {18640, !"Hair1"},
- {18975, !"Hair2"},
- {19136, !"Hair4"},
- {19274, !"Hair5"},
- {18641, !"Фонарик"},
- {18642, !"Тазер"},
- {18643, !"LaserPointer1"},
- {19080, !"LaserPointer2"},
- {19081, !"LaserPointer3"},
- {19082, !"LaserPointer4"},
- {19083, !"LaserPointer5"},
- {19084, !"LaserPointer6"},
- {18644, !"Screwdriver1"},
- {18645, !"MotorcycleHelmet1"},
- {18865, !"MobilePhone1"},
- {18866, !"MobilePhone2"},
- {18867, !"MobilePhone3"},
- {18868, !"MobilePhone4"},
- {18869, !"MobilePhone5"},
- {18870, !"MobilePhone6"},
- {18871, !"MobilePhone7"},
- {18872, !"MobilePhone8"},
- {18873, !"MobilePhone9"},
- {18874, !"MobilePhone10"},
- {18875, !"Pager1"},
- {18890, !"Rake1"},
- {18891, !"Бандана1"},
- {18892, !"Бандана2"},
- {18893, !"Бандана3"},
- {18894, !"Бандана4"},
- {18895, !"Бандана5"},
- {18896, !"Бандана6"},
- {18897, !"Бандана7"},
- {18898, !"Бандана8"},
- {18899, !"Бандана9"},
- {18900, !"Бандана10"},
- {18901, !"Bandana11"},
- {18902, !"Бандана12"},
- {18903, !"Бандана13"},
- {18904, !"Бандана14"},
- {18905, !"Бандана15"},
- {18906, !"Бандана16"},
- {18907, !"Бандана17"},
- {18908, !"Бандана18"},
- {18909, !"Бандана19"},
- {18910, !"Бандана20"},
- {18911, !"Mask1"},
- {18912, !"Mask2"},
- {18913, !"Mask3"},
- {18914, !"Mask4"},
- {18915, !"Mask5"},
- {18916, !"Mask6"},
- {18917, !"Mask7"},
- {18918, !"Mask8"},
- {18919, !"Mask9"},
- {18920, !"Mask10"},
- {18921, !"Beret1"},
- {18922, !"Beret2"},
- {18923, !"Beret3"},
- {18924, !"Beret4"},
- {18925, !"Beret5"},
- {18926, !"Hat1"},
- {18927, !"Hat2"},
- {18928, !"Hat3"},
- {18929, !"Hat4"},
- {18930, !"Hat5"},
- {18931, !"Hat6"},
- {18932, !"Hat7"},
- {18933, !"Hat8"},
- {18934, !"Hat9"},
- {18935, !"Hat10"},
- {18936, !"Helmet1"},
- {18937, !"Helmet2"},
- {18938, !"Helmet3"},
- {18939, !"CapBack1"},
- {18940, !"CapBack2"},
- {18941, !"CapBack3"},
- {18942, !"CapBack4"},
- {18943, !"CapBack5"},
- {18944, !"HatBoater1"},
- {18945, !"HatBoater2"},
- {18946, !"HatBoater3"},
- {18947, !"HatBowler1"},
- {18948, !"HatBowler2"},
- {18949, !"HatBowler3"},
- {18950, !"HatBowler4"},
- {18951, !"HatBowler5"},
- {18952, !"BoxingHelmet1"},
- {18953, !"CapKnit1"},
- {18954, !"CapKnit2"},
- {18955, !"CapOverEye1"},
- {18956, !"CapOverEye2"},
- {18957, !"CapOverEye3"},
- {18958, !"CapOverEye4"},
- {18959, !"CapOverEye5"},
- {18960, !"CapRimUp1"},
- {18961, !"CapTrucker1"},
- {18962, !"CowboyHat2"},
- {18963, !"CJElvisHead"},
- {18964, !"SkullyCap1"},
- {18965, !"SkullyCap2"},
- {18966, !"SkullyCap3"},
- {18967, !"HatMan1"},
- {18968, !"HatMan2"},
- {18969, !"HatMan3"},
- {18970, !"HatTiger1"},
- {18971, !"HatCool1"},
- {18972, !"HatCool2"},
- {18973, !"HatCool3"},
- {18974, !"MaskZorro1"},
- {18976, !"MotorcycleHelmet2"},
- {18977, !"MotorcycleHelmet3"},
- {18978, !"MotorcycleHelmet4"},
- {18979, !"MotorcycleHelmet5"},
- {19006, !"Очки 1"},
- {19007, !"Очки 2"},
- {19008, !"Очки 3"},
- {19009, !"Очки 4"},
- {19010, !"Очки 5"},
- {19011, !"Очки 6"},
- {19012, !"Очки 7"},
- {19013, !"Очки 8"},
- {19014, !"Очки 9"},
- {19015, !"Очки 10"},
- {19016, !"Очки 11"},
- {19017, !"Очки 12"},
- {19018, !"Очки 13"},
- {19019, !"Очки 14"},
- {19020, !"Очки 15"},
- {19021, !"Очки 16"},
- {19022, !"Очки 17"},
- {19023, !"Очки 18"},
- {19024, !"Очки 19"},
- {19025, !"Очки 20"},
- {19026, !"Очки 21"},
- {19027, !"Очки 22"},
- {19028, !"Очки 23"},
- {19029, !"Очки 24"},
- {19030, !"Очки 25"},
- {19031, !"Очки 26"},
- {19032, !"Очки 27"},
- {19033, !"Очки 28"},
- {19034, !"Очки 29"},
- {19035, !"Очки 30"},
- {19036, !"HockeyMask1"},
- {19037, !"HockeyMask2"},
- {19038, !"HockeyMask3"},
- {19039, !"WatchType1"},
- {19040, !"WatchType2"},
- {19041, !"WatchType3"},
- {19042, !"WatchType4"},
- {19043, !"WatchType5"},
- {19044, !"WatchType6"},
- {19045, !"WatchType7"},
- {19046, !"WatchType8"},
- {19047, !"WatchType9"},
- {19048, !"WatchType10"},
- {19049, !"WatchType11"},
- {19050, !"WatchType12"},
- {19051, !"WatchType13"},
- {19052, !"WatchType14"},
- {19053, !"WatchType15"},
- {19085, !"EyePatch1"},
- {19086, !"ChainsawDildo1"},
- {19090, !"PomPomBlue"},
- {19091, !"PomPomRed"},
- {19092, !"PomPomGreen"},
- {19093, !"HardHat2"},
- {19094, !"BurgerShotHat1"},
- {19095, !"CowboyHat1"},
- {19096, !"CowboyHat3"},
- {19097, !"CowboyHat4"},
- {19098, !"CowboyHat5"},
- {19099, !"PoliceCap2"},
- {19100, !"PoliceCap3"},
- {19101, !"ArmyHelmet1"},
- {19102, !"ArmyHelmet2"},
- {19103, !"ArmyHelmet3"},
- {19104, !"ArmyHelmet4"},
- {19105, !"ArmyHelmet5"},
- {19106, !"ArmyHelmet6"},
- {19107, !"ArmyHelmet7"},
- {19108, !"ArmyHelmet8"},
- {19109, !"ArmyHelmet9"},
- {19110, !"ArmyHelmet10"},
- {19111, !"ArmyHelmet11"},
- {19112, !"ArmyHelmet12"},
- {19113, !"SillyHelmet1"},
- {19114, !"SillyHelmet2"},
- {19115, !"SillyHelmet3"},
- {19116, !"PlainHelmet1"},
- {19117, !"PlainHelmet2"},
- {19118, !"PlainHelmet3"},
- {19119, !"PlainHelmet4"},
- {19120, !"PlainHelmet5"},
- {19137, !"CluckinBellHat1"},
- {19138, !"PoliceGlasses1"},
- {19139, !"PoliceGlasses2"},
- {19140, !"PoliceGlasses3"},
- {19141, !"SWATHelmet1"},
- {19142, !"SWATArmour1"},
- {19160, !"HardHat3"},
- {19161, !"PoliceHat1"},
- {19162, !"PoliceHat2"},
- {19163, !"GimpMask1"},
- {19317, !"bassguitar01"},
- {19318, !"flyingv01"},
- {19319, !"warlock01"},
- {19330, !"fire_hat01"},
- {19331, !"fire_hat02"},
- {19346, !"hotdog01"},
- {19347, !"badge01"},
- {19348, !"cane01"},
- {19349, !"monocle01"},
- {19350, !"moustache01"},
- {19351, !"moustache02"},
- {19352, !"tophat01"},
- {19487, !"tophat02"},
- {19488, !"HatBowler6"},
- {19513, !"whitephone"}
- };
- enum boneInfo
- {
- bID,
- bName[24 char]
- }
- new Bones[][boneInfo] = {
- {1, !"Торс"},
- {2, !"Голова"},
- {3, !"Левое плечо"},
- {4, !"Правое плечо"},
- {5, !"Левая рука"},
- {6, !"Правая рука"},
- {7, !"Левое бедро"},
- {8, !"Правое бедро"},
- {9, !"Левая нога"},
- {10, !"Правая нога"},
- {11, !"Правая голень"},
- {12, !"Левая голень"},
- {13, !"Левое предплечье"},
- {14, !"Правое предплечье"},
- {15, !"Левая ключица"},
- {16, !"Правая ключица"},
- {17, !"Шея"},
- {18, !"Челюсть"}
- };
- new Table[][64 char] = {
- {!"CREATE TABLE IF NOT EXISTS `AttachObj` ("},
- {!" `Skin` int(11) NOT NULL DEFAULT '1',"},
- {!" `Slot` int(11) NOT NULL DEFAULT '0',"},
- {!" `Model` int(11) NOT NULL DEFAULT '18632',"},
- {!" `Bone` int(11) NOT NULL DEFAULT '1',"},
- {!" `objOffset` varchar(256) NOT NULL DEFAULT '0.0,0.0,0.0',"},
- {!" `objRot` varchar(256) NOT NULL DEFAULT '0.0,0.0,0.0',"},
- {!" `objScale` varchar(256) NOT NULL DEFAULT '0.0,0.0,0.0'"},
- {!") ENGINE=MyISAM DEFAULT CHARSET=utf8;"}
- };
- public OnFilterScriptInit()
- {
- if(!IsDBConnection()) sqlConnect();
- for(new i; i < sizeof(Table); i++)
- {
- strunpack(tmp, Table[i], sizeof(tmp));
- strcat(dlgstr, tmp);
- }
- bd::query(dlgstr); bd::free_result();
- TD_EAO = TextDrawCreate(320.000, 410.000, "~b~Editor Attached Objects");
- TextDrawAlignment(TD_EAO, 2);
- TextDrawBackgroundColor(TD_EAO, 0x000000ff);
- TextDrawFont(TD_EAO, 0);
- TextDrawLetterSize(TD_EAO, 0.6, 1.8);
- TextDrawColor(TD_EAO, 0xffffffff);
- TextDrawSetShadow(TD_EAO, 1);
- TextDrawSetOutline(TD_EAO, 1);
- TextDrawSetProportional(TD_EAO,1);
- TD_EAO2 = TextDrawCreate(320.000, 428, "~r~Use command /attach");
- TextDrawAlignment(TD_EAO2, 2);
- TextDrawBackgroundColor(TD_EAO2, 0x000000ff);
- TextDrawFont(TD_EAO2, 1);
- TextDrawLetterSize(TD_EAO2, 0.3, 1.2);
- TextDrawColor(TD_EAO2, 0xffffffff);
- TextDrawSetShadow(TD_EAO2, 1);
- TextDrawSetOutline(TD_EAO2, 1);
- TextDrawSetProportional(TD_EAO2,1);
- TextDrawHideForAll( TD_EAO ); TextDrawShowForAll( TD_EAO );
- TextDrawHideForAll( TD_EAO2 ); TextDrawShowForAll( TD_EAO2 );
- ///**************************************************************************
- print("\t_________________________________________________________________");
- print("\t ");
- print("\t| Editor Attached Objects |");
- print("\t| successfully loaded! |");
- print("\t| |");
- print("\t| Version: v1.1 |");
- print("\t| Copyright [c] 2012 MacMailler |");
- print("\t_________________________________________________________________");
- ///*************************************************************************
- return 1;
- }
- public OnFilterScriptExit()
- {
- TextDrawDestroy( TD_EAO ); TextDrawDestroy( TD_EAO2 );
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- TextDrawShowForPlayer(playerid, TD_EAO);
- TextDrawShowForPlayer(playerid, TD_EAO2);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[32], params[128];
- sscanf(cmdtext, "s[24]s[128]", cmd, params);
- CMD(cmd, "/attach", true)
- {
- format(dlgstr, sizeof(dlgstr), "");
- for(new x; x < MAX_PLAYER_ATTACHED_OBJECTS; x++)
- {
- if(IsPlayerAttachedObjectSlotUsed(playerid, x)) format(tmp, sizeof(tmp), "%d\t[ {AA3333}Used{ffffff} ]\n", x);
- else format(tmp, sizeof(tmp), "%d\t[ {33AA33}Free{ffffff} ]\n", x);
- strcat(dlgstr, tmp);
- }
- SPD(playerid, D_ATTACH_SLOT, DIALOG_STYLE_LIST,
- "{FF0000}Выбирете слот для объекта", dlgstr, "Выбор", "Отмена");
- return 1;
- }
- CMD(cmd, "/setanim", true)
- {
- if(IsAdmin(playerid, 1338))
- {
- new animlib[24], animname[24];
- if(sscanf(params, "s[24]s[24]", animlib, animname)) return Send(playerid, -1, "Введите: /setanim [animlib] [animname]");
- ApplyAnimation(playerid, animlib, animname, 4.1,0,1,1,1,1); return 1;
- }
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case D_ATTACH_SLOT:
- {
- if(response)
- {
- SetPVarInt(playerid, "AttachSlot", listitem);
- if(IsPlayerAttachedObjectSlotUsed(playerid, listitem))
- {
- SPD(playerid, D_ATTACH_EDIT, 0,
- "{FF0000}Редактирование объекта",
- "Вы можете изменить объект в этом слоте или удалить!",
- "Изменить", "Удалить");
- }
- else
- {
- SPD(playerid, D_ATTACH_SLOT+1, DIALOG_STYLE_LIST,
- "{FF0000}Объекты",
- "Ввести свой ID\n\
- Выбрать из списка", "Выбор", "Отмена");
- }
- }
- }
- case D_ATTACH_SLOT+1:
- {
- if(response)
- {
- switch(listitem)
- {
- case 0:
- {
- SPD(playerid, D_ATTACH_MODEL+1, DIALOG_STYLE_INPUT,
- "{FF0000}Свой объект",
- "Введите ID объета который хотите прекрипить к игроку", "Ввод", "Назад");
- }
- case 1:
- {
- new aname[36]; format(dlgstr, sizeof(dlgstr), "");
- for(new x; x < sizeof(AttachObjects); x++)
- {
- strunpack(aname, AttachObjects[x][aName], sizeof(aname));
- format(tmp, sizeof(tmp), "%s\n", aname); strcat(dlgstr, tmp);
- }
- SPD(playerid, D_ATTACH_MODEL, DIALOG_STYLE_LIST,
- "{FF0000}Выберете объект", dlgstr, "Выбор", "Назад");
- }
- }
- }
- else
- {
- format(dlgstr, sizeof(dlgstr), "");
- for(new x; x < MAX_PLAYER_ATTACHED_OBJECTS; x++)
- {
- if(IsPlayerAttachedObjectSlotUsed(playerid, x)) format(tmp, sizeof(tmp), "%d\t[ {AA3333}Used{ffffff} ]\n", x);
- else format(tmp, sizeof(tmp), "%d\t[ {33AA33}Free{ffffff} ]\n", x);
- strcat(dlgstr, tmp);
- }
- SPD(playerid, D_ATTACH_SLOT, DIALOG_STYLE_LIST,
- "{FF0000}Выбирете слот для объекта", dlgstr, "Выбор", "Отмена");
- }
- }
- case D_ATTACH_EDIT:
- {
- if(response)
- {
- EditAttachedObject(playerid, GetPVarInt(playerid, "AttachSlot"));
- }
- else
- {
- SPD(playerid, D_ATTACH_EXIT, DIALOG_STYLE_LIST,
- "{FF0000}Удалить объект?",
- "Нет\n\
- Удалить объект\n\
- Удалить объект + запись в БД\n\
- Удалить запись в БД", "Выбор", "Отмена");
- }
- }
- case D_ATTACH_MODEL:
- {
- if(response)
- {
- new bones[36]; format(dlgstr, sizeof(dlgstr), "");
- SetPVarInt(playerid, "AttachModel", AttachObjects[listitem][aModel]);
- for(new x; x < sizeof(Bones); x++)
- {
- strunpack(bones, Bones[x][bName], sizeof(bones));
- format(tmp, sizeof(tmp), "%s\n", bones); strcat(dlgstr, tmp);
- }
- SPD(playerid, D_ATTACH_BONE, DIALOG_STYLE_LIST,
- "{FF0000}Куда прикрепить объект?", dlgstr, "Выбор", "Назад");
- }
- else
- {
- SPD(playerid, D_ATTACH_SLOT+1, DIALOG_STYLE_LIST,
- "{FF0000}Объекты",
- "Ввести свой ID\n\
- Выбрать из списка", "Выбор", "Отмена");
- }
- }
- case D_ATTACH_MODEL+1:
- {
- if(response)
- {
- if(!sscanf(inputtext, "i", inputtext[0]))
- {
- new bones[36]; format(dlgstr, sizeof(dlgstr), "");
- SetPVarInt(playerid, "AttachModel", inputtext[0]);
- for(new x; x < sizeof(Bones); x++)
- {
- strunpack(bones, Bones[x][bName], sizeof(bones));
- format(tmp, sizeof(tmp), "%s\n", bones); strcat(dlgstr, tmp);
- }
- SPD(playerid, D_ATTACH_BONE, DIALOG_STYLE_LIST,
- "{FF0000}Куда прикрепить объект?", dlgstr, "Выбор", "Назад");
- }
- else
- {
- SPD(playerid, 0, 0,
- "{FF0000}ERROR", "Произошла ошибка!\nПовторите ввод.", "OK", "");
- }
- }
- else
- {
- SPD(playerid, D_ATTACH_SLOT+1, DIALOG_STYLE_LIST,
- "{FF0000}Объекты",
- "Ввести свой ID\n\
- Выбрать из списка", "Выбор", "Отмена");
- }
- }
- case D_ATTACH_BONE:
- {
- if(response)
- {
- SetPVarInt(playerid, "AttachBone", listitem+1);
- if(ObjExists(playerid)) LoadObj(playerid);
- else
- {
- SetPlayerAttachedObject
- (
- playerid,
- GetPVarInt(playerid, "AttachSlot"),
- GetPVarInt(playerid, "AttachModel"),
- GetPVarInt(playerid, "AttachBone")
- );
- EditAttachedObject(playerid, GetPVarInt(playerid, "AttachSlot"));
- }
- }
- else
- {
- format(dlgstr, sizeof(dlgstr), "");
- for(new x; x < MAX_PLAYER_ATTACHED_OBJECTS; x++)
- {
- if(IsPlayerAttachedObjectSlotUsed(playerid, x)) format(tmp, sizeof(tmp), "%d\t[ {AA3333}Used{ffffff} ]\n", x);
- else format(tmp, sizeof(tmp), "%d\t[ {33AA33}Free{ffffff} ]\n", x);
- strcat(dlgstr, tmp);
- }
- SPD(playerid, D_ATTACH_SLOT, DIALOG_STYLE_LIST,
- "{FF0000}Выбирете слот для объекта", dlgstr, "Выбор", "Отмена");
- }
- }
- case D_ATTACH_EXIT:
- {
- if(response)
- {
- switch(listitem)
- {
- case 0: return 1;
- case 1:
- {
- RemovePlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachSlot"));
- DeletePVar(playerid, "AttachSlot"); DeletePVar(playerid, "AttachModel");
- SPD(playerid, 0, 0, "Удаление", "Вы удалили объект!", "OK", "");
- }
- case 2:
- {
- DeleteObj(playerid);
- RemovePlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachSlot"));
- DeletePVar(playerid, "AttachSlot"); DeletePVar(playerid, "AttachModel");
- SPD(playerid, 0, 0, "Удаление", "Вы полностью удалили объект!", "OK", "");
- }
- case 3:
- {
- DeleteObj(playerid);
- SPD(playerid, 0, 0, "Удаление", "Вы удалили запись в БД!", "OK", "");
- }
- }
- }
- else
- {
- EditAttachedObject(playerid, GetPVarInt(playerid, "AttachSlot"));
- }
- }
- case D_ATTACH_SAVE:
- {
- if(response)
- {
- switch(listitem)
- {
- case 0:
- {
- SetPlayerAttachedObject
- (
- playerid,
- GetPVarInt(playerid, "AttachSlot"),
- GetPVarInt(playerid, "AttachModel"),
- GetPVarInt(playerid, "AttachBone"),
- GetPVarFloat(playerid, "fOffsetX"),
- GetPVarFloat(playerid, "fOffsetY"),
- GetPVarFloat(playerid, "fOffsetZ"),
- GetPVarFloat(playerid, "fRotX"),
- GetPVarFloat(playerid, "fRotY"),
- GetPVarFloat(playerid, "fRotZ"),
- GetPVarFloat(playerid, "fScaleX"),
- GetPVarFloat(playerid, "fScaleY"),
- GetPVarFloat(playerid, "fScaleZ")
- );
- SPD(playerid, 0, 0, "{FF0000}Сохранение", "Объект сохранен!", "OK", "");
- }
- case 1:
- {
- if(ObjExists(playerid)) UpdateObj(playerid); else SaveObj(playerid);
- SetPlayerAttachedObject
- (
- playerid,
- GetPVarInt(playerid, "AttachSlot"),
- GetPVarInt(playerid, "AttachModel"),
- GetPVarInt(playerid, "AttachBone"),
- GetPVarFloat(playerid, "fOffsetX"),
- GetPVarFloat(playerid, "fOffsetY"),
- GetPVarFloat(playerid, "fOffsetZ"),
- GetPVarFloat(playerid, "fRotX"),
- GetPVarFloat(playerid, "fRotY"),
- GetPVarFloat(playerid, "fRotZ"),
- GetPVarFloat(playerid, "fScaleX"),
- GetPVarFloat(playerid, "fScaleY"),
- GetPVarFloat(playerid, "fScaleZ")
- );
- SPD(playerid, 0, 0, "{FF0000}Сохранение", "Объект сохранен!", "OK", "");
- }
- case 2:
- {
- RemovePlayerAttachedObject(playerid, GetPVarInt(playerid, "AttachSlot"));
- DeletePVar(playerid, "AttachSlot"); DeletePVar(playerid, "AttachModel");
- }
- }
- }
- else
- {
- SetPlayerAttachedObject
- (
- playerid,
- GetPVarInt(playerid, "AttachSlot"),
- GetPVarInt(playerid, "AttachModel"),
- GetPVarInt(playerid, "AttachBone"),
- GetPVarFloat(playerid, "fOffsetX"),
- GetPVarFloat(playerid, "fOffsetY"),
- GetPVarFloat(playerid, "fOffsetZ"),
- GetPVarFloat(playerid, "fRotX"),
- GetPVarFloat(playerid, "fRotY"),
- GetPVarFloat(playerid, "fRotZ"),
- GetPVarFloat(playerid, "fScaleX"),
- GetPVarFloat(playerid, "fScaleY"),
- GetPVarFloat(playerid, "fScaleZ")
- );
- EditAttachedObject(playerid, GetPVarInt(playerid, "AttachSlot"));
- }
- }
- }
- return 1;
- }
- public OnPlayerEditAttachedObject( playerid, response, index, modelid, boneid,
- Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,
- Float:fRotX, Float:fRotY, Float:fRotZ,
- Float:fScaleX, Float:fScaleY, Float:fScaleZ )
- {
- if(response)
- {
- SetPVarInt(playerid, "AttachSlot", index);
- SetPVarInt(playerid, "AttachModel", modelid);
- SetPVarInt(playerid, "AttachBone", boneid);
- SetPVarFloat(playerid, "fOffsetX", fOffsetX);
- SetPVarFloat(playerid, "fOffsetY", fOffsetY);
- SetPVarFloat(playerid, "fOffsetZ", fOffsetZ);
- SetPVarFloat(playerid, "fRotX", fRotX);
- SetPVarFloat(playerid, "fRotY", fRotY);
- SetPVarFloat(playerid, "fRotZ", fRotZ);
- SetPVarFloat(playerid, "fScaleX", fScaleX);
- SetPVarFloat(playerid, "fScaleY", fScaleY);
- SetPVarFloat(playerid, "fScaleZ", fScaleZ);
- SPD(playerid, D_ATTACH_SAVE, DIALOG_STYLE_LIST,
- "{FF0000}Сохранить объект?",
- "Cохранить\n\
- Cохранить + запись в БД\n\
- Нет", "Выбор", "Отмена");
- }
- else
- {
- SetPVarInt(playerid, "AttachSlot", index);
- SetPVarInt(playerid, "AttachModel", modelid);
- SetPVarInt(playerid, "AttachBone", boneid);
- SPD(playerid, D_ATTACH_EXIT, DIALOG_STYLE_LIST,
- "{FF0000}Удалить объект?",
- "Нет\n\
- Удалить объект\n\
- Удалить объект + запись в БД\n\
- Удалить запись в БД", "Выбор", "Отмена");
- }
- return 1;
- }
- stock DeleteObj(playerid)
- {
- format(tmp, sizeof(tmp), "DELETE FROM `AttachObj` WHERE `Skin`='%i' AND `Model`='%i' AND `Bone`='%i'",
- GetPlayerSkin(playerid), GetPVarInt(playerid, "AttachModel"), GetPVarInt(playerid, "AttachBone"));
- bd::query(tmp); bd::store_result(); return;
- }
- stock UpdateObj(playerid)
- {
- new offset[128], rot[128], scale[128];
- format(offset, sizeof(offset), "%f,%f,%f", GetPVarFloat(playerid, "fOffsetX"), GetPVarFloat(playerid, "fOffsetY"), GetPVarFloat(playerid, "fOffsetZ"));
- format(rot, sizeof(rot), "%f,%f,%f", GetPVarFloat(playerid, "fRotX"), GetPVarFloat(playerid, "fRotY"), GetPVarFloat(playerid, "fRotZ"));
- format(scale, sizeof(scale), "%f,%f,%f", GetPVarFloat(playerid, "fScaleX"), GetPVarFloat(playerid, "fScaleY"), GetPVarFloat(playerid, "fScaleZ"));
- format(tmp, sizeof(tmp), "UPDATE `AttachObj` SET `objOffset`='%s',`objRot`='%s',`objScale`='%s' WHERE `Skin`='%i' AND `Model`='%i' AND `Bone`='%i'",
- offset, rot, scale, GetPlayerSkin(playerid), GetPVarInt(playerid, "AttachModel"), GetPVarInt(playerid, "AttachBone"));
- bd::query(tmp); bd::free_result();
- return;
- }
- stock SaveObj(playerid)
- {
- new offset[128], rot[128], scale[128];
- format(offset, sizeof(offset), "%f,%f,%f", GetPVarFloat(playerid, "fOffsetX"), GetPVarFloat(playerid, "fOffsetY"), GetPVarFloat(playerid, "fOffsetZ"));
- format(rot, sizeof(rot), "%f,%f,%f", GetPVarFloat(playerid, "fRotX"), GetPVarFloat(playerid, "fRotY"), GetPVarFloat(playerid, "fRotZ"));
- format(scale, sizeof(scale), "%f,%f,%f", GetPVarFloat(playerid, "fScaleX"), GetPVarFloat(playerid, "fScaleY"), GetPVarFloat(playerid, "fScaleZ"));
- format(tmp, sizeof(tmp), "INSERT INTO `AttachObj` (`Skin`,`Slot`,`Model`,`Bone`,`objOffset`,`objRot`,`objScale`)");
- strcat(tmp, " VALUES ('%i','%i','%i','%i','%s','%s','%s')");
- format(dlgstr, sizeof(dlgstr), tmp,
- GetPlayerSkin(playerid), GetPVarInt(playerid, "AttachSlot"), GetPVarInt(playerid, "AttachModel"), GetPVarInt(playerid, "AttachBone"),
- offset, rot, scale);
- bd::query(dlgstr); bd::free_result();
- return;
- }
- stock LoadObj(playerid)
- {
- new
- index, modelid, boneid,
- Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,
- Float:fRotX, Float:fRotY, Float:fRotZ,
- Float:fScaleX, Float:fScaleY, Float:fScaleZ,
- offset[128], rot[128], scale[128]
- ;
- format(tmp, sizeof(tmp), "SELECT * FROM `AttachObj` WHERE `Skin`='%i' AND `Model`='%i' AND `Bone`='%i'",
- GetPlayerSkin(playerid), GetPVarInt(playerid, "AttachModel"), GetPVarInt(playerid, "AttachBone"));
- if(bd::query(tmp) && bd::store_result())
- {
- if(bd::num_rows())
- {
- bd::fetch_row_format(dlgstr);
- sscanf
- (
- dlgstr,
- "p<|>iiiis[128]s[128]s[128]",
- dlgstr[0], index, modelid, boneid,
- offset, rot, scale
- );
- sscanf
- (
- offset,
- "p<,>fff",
- fOffsetX, fOffsetY, fOffsetZ
- );
- sscanf
- (
- rot,
- "p<,>fff",
- fRotX, fRotY, fRotZ
- );
- sscanf
- (
- scale,
- "p<,>fff",
- fScaleX, fScaleY, fScaleZ
- );
- SetPlayerAttachedObject
- (
- playerid,
- GetPVarInt(playerid, "AttachSlot"), modelid, boneid,
- fOffsetX, fOffsetY, fOffsetZ,
- fRotX, fRotY, fRotZ,
- fScaleX, fScaleY, fScaleZ
- );
- EditAttachedObject(playerid, GetPVarInt(playerid, "AttachSlot"));
- }
- }
- return;
- }
- stock ObjExists(playerid)
- {
- format(tmp, sizeof(tmp), "SELECT * FROM `AttachObj` WHERE `Skin`='%i' AND `Model`='%i' AND `Bone`='%i'",
- GetPlayerSkin(playerid), GetPVarInt(playerid, "AttachModel"), GetPVarInt(playerid, "AttachBone"));
- if(bd::query(tmp) && bd::store_result()) if(bd::num_rows()) return true;
- return false;
- }
- stock sqlConnect()
- {
- bd::debug(1);
- bd::connect(bd_HOST, bd_USER, bd_NAME, bd_PASS);
- if(bd::ping() == 1) printf("Подключение к MySQL прошло успешно!");
- else print("Соединение с MySQL не установленно!");
- return;
- }
- stock sqlDisconnect()
- {
- bd::close();
- if(bd::ping()) print("MySQL не была отключина!");
- else print("MySQL успешно отключина!");
- return;
- }
- stock IsDBConnection()
- {
- if(bd::ping() == 1) return true;
- return false;
- }
- stock GetObjectName( objectid, array[], len = sizeof array )
- {
- for( new i; i < sizeof( AttachObjects ) i++ )
- {
- if( AttachObjects[ i ][ aModel ] == objectid )
- return strunpack( array, AttachObjects[ i ][ aName ], len );
- }
- return strunpack( array, !"unknown", len );
- }
- stock GetBoneName( boneid, array[], len = sizeof array )
- {
- for( new i; i < sizeof( Bones ); i++ )
- {
- if( Bones[ i ][ bID ] == boneid)
- return strunpack( array, Bones[ i ][ bName ], len );
- }
- return strunpack( array, !"unknown", len );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement