Skip to content

Instantly share code, notes, and snippets.

@ArKaNeMaN
Created July 17, 2023 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArKaNeMaN/8720ae20f87245c0fe00d28c387065e0 to your computer and use it in GitHub Desktop.
Save ArKaNeMaN/8720ae20f87245c0fe00d28c387065e0 to your computer and use it in GitHub Desktop.
#include <amxmodx>
#include <json>
#include <VipModular>
#include <ultimate_weapons>
/*
Параметры:
Name - Название оружия в UW (buy_name)
GiveType - Тип выдачи:
"append" - оружие добавится к существующему
"drop" - выкинуть существующие
"replace" - уничтожить существующее
"ignore" - не выдавать тогда оружие
BpAmmo - Кол-во патрон в запасе
Ammo - Кол-во патрон в обойме
Example:
{
"Type": "UW-Weapon",
"Name": "ultimate_goldak47",
"GiveType": "Replace"
}
*/
#pragma semicolon 1
#pragma compress 1
public stock const PluginName[] = "[VipM-I] Ultimate Weapons";
public stock const PluginVersion[] = "1.0.0";
public stock const PluginAuthor[] = "ArKaNeMaN";
public stock const PluginURL[] = "t.me/arkanaplugins";
new const TYPE_NAME[] = "UW-Weapon";
public VipM_IC_OnInitTypes() {
register_plugin(PluginName, PluginVersion, PluginAuthor);
VipM_IC_RegisterType(TYPE_NAME);
VipM_IC_RegisterTypeEvent(TYPE_NAME, ItemType_OnRead, "@OnRead");
VipM_IC_RegisterTypeEvent(TYPE_NAME, ItemType_OnGive, "@OnGive");
}
@OnRead(const JSON:jItem, const Trie:tParams) {
TrieSetCell(tParams, "BpAmmo", -1);
if (json_object_has_value(jItem, "BpAmmo", JSONNumber)) {
TrieSetCell(tParams, "BpAmmo", json_object_get_number(jItem, "BpAmmo"));
}
TrieSetCell(tParams, "Ammo", -1);
if (json_object_has_value(jItem, "Ammo", JSONNumber)) {
TrieSetCell(tParams, "Ammo", json_object_get_number(jItem, "Ammo"));
}
TrieSetCell(tParams, "GiveType", 0);
if (json_object_has_value(jItem, "GiveType", JSONString)) {
new sGiveType[16];
json_object_get_string(jItem, "GiveType", sGiveType, charsmax(sGiveType));
TrieSetCell(tParams, "GiveType", StrToGiveType(sGiveType));
}
}
@OnGive(const UserId, const Trie:tParams) {
static sWeaponName[64];
VipM_Params_GetStr(tParams, "Name", sWeaponName, charsmax(sWeaponName));
weapons_give_user_ultimate(
UserId,
.buy_name=sWeaponName,
.replace=VipM_Params_GetInt(tParams, "GiveType", 0),
.bpammo=VipM_Params_GetInt(tParams, "BpAmmo", -1),
.ammo=VipM_Params_GetInt(tParams, "Ammo", -1)
);
}
StrToGiveType(const sGiveType[]) {
// 0 - оружие добавится к существующему
// 1 - выкинуть существующие
// 2 - уничтожить существующее
// 3 - не выдавать тогда оружие
if (equali(sGiveType, "append")) {
return 0;
} else if (equali(sGiveType, "drop")) {
return 1;
} else if (equali(sGiveType, "replace")) {
return 2;
} else if (equali(sGiveType, "ignore")) {
return 3;
} else {
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment