Иконка ресурса

amxx [AUW] Weapons On Maps 0.0.1

Нет прав для скачивания
Для CS 1.6
Автор
Albertio
Исходный код
#include <amxmodx>
#include <auw>
#include <reapi>

#define AUW_TASK_ID 27272

enum _:WeaponInfo
{
Map[32],
Weapon[32],
Key[64]
};

enum _:WeaponData
{
eAUWWeaponIdReturn:iWeapon,
Flag,
AuthID[MAX_AUTHID_LENGTH]
};

enum _:playerWeapons
{
FIRST_SLOT[32],
SECOND_SLOT[32],
THIRD_SLOT[32]
};

new g_ePlayerWeapons[MAX_PLAYERS + 1][PlayerWeapons];

new Array:g_eWeaponData, Array:g_eWeaponIndexes;

new g_iWeaponCount;

public plugin_precache()
{
new szPath[128], iLen = get_localinfo("amxx_configsdir", szPath, charsmax(szPath));
formatex(szPath[iLen], charsmax(szPath) - iLen, "/auw_weapons_on_maps.ini");

new hFile = fopen(szPath, "rt");

if(!hFile)
{
set_fail_state("Can't %s '%s'", file_exists(szPath) ? "read" : "find", szPath);
return;
}

g_eWeaponData = ArrayCreate(WeaponInfo);

new szLine[128], szMap[32], szWeapon[32], szKey[64], aWeaponData[WeaponInfo];

while(!feof(hFile))
{
fgets(hFile, szLine, charsmax(szLine));
trim(szLine);

if(szLine[0] == ';')
continue;

if(parse(szLine, szMap, charsmax(szMap), szWeapon, charsmax(szWeapon), szKey, charsmax(szKey)) == 3)
{
if(szMap[0] == EOS)
continue;

copy(aWeaponData[Map], charsmax(aWeaponData[Map]), szMap);
copy(aWeaponData[Weapon], charsmax(aWeaponData[Weapon]), szWeapon);
copy(aWeaponData[Key], charsmax(aWeaponData[Key]), szKey);

ArrayPushArray(g_eWeaponData, aWeaponData);
}
}

fclose(hFile);
}

public plugin_init()
{
register_plugin("[AUW] Weapons On Maps", "0.0.1", "Albertio");

g_eWeaponIndexes = ArrayCreate(WeaponData);

new szMapName[32];
get_mapname(szMapName, charsmax(szMapName));

for(new i, aWeaponData[WeaponInfo], aWeaponIndexes[WeaponData]; i < ArraySize(g_eWeaponData); i++)
{
ArrayGetArray(g_eWeaponData, i, aWeaponData);

if(containi(szMapName, aWeaponData[Map]) != -1)
{
aWeaponIndexes[iWeapon] = eAUWWeaponIdReturn:__auw__native__auw_get_weapon_uid(aWeaponData[Weapon], false);

if(aWeaponIndexes[iWeapon] != eAUWWeaponIdReturn_InvalidId)
{
if(aWeaponData[Key][0] == 'S' || aWeaponData[Key][0] == 'V')
copy(aWeaponIndexes[AuthID], charsmax(aWeaponIndexes[AuthID]), aWeaponData[Key]);
else
aWeaponIndexes[Flag] = read_flags(aWeaponData[Key]);

ArrayPushArray(g_eWeaponIndexes, aWeaponIndexes);
arrayset(aWeaponIndexes, 0, sizeof(aWeaponIndexes));
}
}
}

if(!(g_iWeaponCount = ArraySize(g_eWeaponIndexes)))
pause("d");

RegisterHookChain(RG_CSGameRules_RestartRound, "CSGameRules_RestartRound_Pre");
RegisterHookChain(RG_CBasePlayer_OnSpawnEquip, "CBasePlayer_OnSpawnEquip_Pre");
}

public CSGameRules_RestartRound_Pre()
{
arrayset(g_ePlayerWeapons[0][_:0], 0, sizeof(g_ePlayerWeapons) * sizeof(g_ePlayerWeapons[]));
}

public CBasePlayer_OnSpawnEquip_Pre(const id)
{
set_task(0.1, "OnSpawnEquip", id + AUW_TASK_ID);
}

public OnSpawnEquip(id)
{
id -= AUW_TASK_ID;

for(new i, aWeaponIndexes[WeaponData], szAuthID[MAX_AUTHID_LENGTH]; i < g_iWeaponCount; i++)
{
ArrayGetArray(g_eWeaponIndexes, i, aWeaponIndexes);

if(UTIL_PlayerHasCustomWeapon(id, aWeaponIndexes))
continue;

if(aWeaponIndexes[AuthID][0] != EOS)
{
get_user_authid(id, szAuthID, charsmax(szAuthID));

if(equali(szAuthID, aWeaponIndexes[AuthID]))
UTIL_GiveCustomWeapon(id, aWeaponIndexes);
}
else if(get_user_flags(id) & aWeaponIndexes[Flag])
UTIL_GiveCustomWeapon(id, aWeaponIndexes);
}
}

stock UTIL_PlayerHasCustomWeapon(const id, const aWeaponIndexes[WeaponData])
{
new aWeaponData[eAUWData];

if(__auw__native__auw_get_weapons_data(aWeaponIndexes[iWeapon], aWeaponData, false))
if(equali(aWeaponData[eAUWData_WEAPON_REFERENCE], g_ePlayerWeapons[id][FIRST_SLOT]) ||
equali(aWeaponData[eAUWData_WEAPON_REFERENCE], g_ePlayerWeapons[id][SECOND_SLOT]) ||
equali(aWeaponData[eAUWData_WEAPON_REFERENCE], g_ePlayerWeapons[id][THIRD_SLOT]))
return 1;

return 0;
}

stock UTIL_GiveCustomWeapon(const id, const aWeaponIndexes[WeaponData])
{
if(__auw__native__auw_give_weapon(id, NULL_STRING, false, aWeaponIndexes[iWeapon], false))
{
new aWeaponData[eAUWData];
__auw__native__auw_get_weapons_data(aWeaponIndexes[iWeapon], aWeaponData, false);

switch(aWeaponData[eAUWData_WEAPON_SLOT])
{
case 0: copy(g_ePlayerWeapons[id][THIRD_SLOT], charsmax(g_ePlayerWeapons[][THIRD_SLOT]), aWeaponData[eAUWData_WEAPON_REFERENCE]);
case 1: copy(g_ePlayerWeapons[id][FIRST_SLOT], charsmax(g_ePlayerWeapons[][FIRST_SLOT]), aWeaponData[eAUWData_WEAPON_REFERENCE]);
case 2: copy(g_ePlayerWeapons[id][SECOND_SLOT], charsmax(g_ePlayerWeapons[][SECOND_SLOT]), aWeaponData[eAUWData_WEAPON_REFERENCE]);
}
}
}
Требования
AUW 0.1.1b + Bypass
Требование ReAPI
Да
Поддержка русского языка
Да
Совместимость
  1. HLDS
  2. REHLDS
Сверху Снизу