HLMOD.HU Forrás Megtekintés
- www.hlmod.hu/* Plugin generated by AMXX-Studio */
/* Based on: https://wiki.alliedmods.net/CS_WeaponList_Message_Dump */
#include <amxmodx>
#include <amxmisc>
#include <msg_weap_sprites_api_const>
#define PLUGIN "MSG Weapon Sprite API"
#define VERSION "1.0"
#define AUTHOR "Vieni"
new const gWeaponNameList[][] =
{
"", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
"weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
"weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
"weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
"weapon_ak47", "weapon_knife", "weapon_p90"
}
new const gWeaponAmmoIdList[] =
{
0, 9, 0, 2, 12, 5, 14, 6,
4, 13, 10, 7, 6, 4,
4, 4, 6, 10, 1, 10, 3,
5, 4, 10, 2, 11, 8, 4,
2, -1, 7
}
new const gWeaponMaxAmmoList[] =
{
0, 52, 0, 90, 1, 32, 1, 100,
90, 1, 120, 100, 100, 90,
90, 90, 100, 120, 30, 120, 200,
32, 90, 120, 90, 2, 35, 90,
90, -1, 100
}
new const gWeaponSlotId[] =
{
-1, 1, -1, 0, 3, 0, 4, 0,
0, 3, 1, 1, 0, 0,
0, 0, 1, 1, 0, 0, 0,
0, 0, 0, 0, 3, 1, 0,
0, 2, 0
}
new const gWeaponNumberInSlot[] =
{
0, 3, 0, 9, 1, 12, 3, 13,
14, 3, 5, 6, 15, 16,
17, 18, 4, 2, 2, 7, 4,
5, 6, 11, 3, 2, 1, 10,
1, 1, 8
}
new const gWeaponFlags[] =
{
0, 0, 0, 0, (WEAP_FL_EXHAUSTIBLE|WEAP_FL_LIMITINWORLD), 0, (WEAP_FL_EXHAUSTIBLE|WEAP_FL_LIMITINWORLD), 0,
0, (WEAP_FL_EXHAUSTIBLE|WEAP_FL_LIMITINWORLD), 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, (WEAP_FL_EXHAUSTIBLE|WEAP_FL_LIMITINWORLD), 0, 0,
0, 0, 0
}
// Bytes with secondary ammo type are usually -1
new Array:arrayUserWeaponList[33]
new Array:arrayUserWeaponId[33]
new gMsgWeaponList
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
gMsgWeaponList = get_user_msgid("WeaponList")
}
public plugin_natives()
{
register_native("msg_set_player_weapon_sprite", "native_set_player_weapon_sprite")
register_native("msg_reset_player_weapon_sprite", "native_reset_player_weapon_sprite")
}
public client_putinserver(id)
{
ArrayDestroy(arrayUserWeaponList[id])
ArrayDestroy(arrayUserWeaponId[id])
arrayUserWeaponList[id] = ArrayCreate(30)
arrayUserWeaponId[id] = ArrayCreate(1)
}
public client_disconnected(id)
{
ArrayDestroy(arrayUserWeaponList[id])
ArrayDestroy(arrayUserWeaponId[id])
}
public client_command(id)
{
if(!is_user_alive(id))
return PLUGIN_CONTINUE
static lCommand[34], lArrayId
read_argv(0, lCommand, charsmax(lCommand))
remove_quotes(lCommand)
lArrayId = ArrayFindString(arrayUserWeaponList[id], lCommand)
if(lArrayId == -1)
return PLUGIN_CONTINUE
engclient_cmd(id, gWeaponNameList[ArrayGetCell(arrayUserWeaponId[id], lArrayId)])
return PLUGIN_HANDLED
}
public native_set_player_weapon_sprite(plugin_id, param_num)
{
new id = get_param(1)
new lWeaponId = get_param(2)
new lNewWeaponName[30]
new lFlags = get_param(4)
if(!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "[MSG] Player is not in game (%d)", id)
return false
}
get_string(3, lNewWeaponName, charsmax(lNewWeaponName))
setPlayerWeaponSprite(id, lWeaponId, lNewWeaponName, lFlags)
return true
}
public native_reset_player_weapon_sprite(plugin_id, param_num)
{
new id = get_param(1)
new lWeaponId = get_param(2)
new lFlags = get_param(3)
if(!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "[MSG] Player is not in game (%d)", id)
return false
}
resetPlayerWeaponSprite(id, lWeaponId, lFlags)
return true
}
setPlayerWeaponSprite(id, weaponId, newWeaponName[], flags)
{
if(ArrayFindString(arrayUserWeaponList[id], newWeaponName) == -1)
{
ArrayPushString(arrayUserWeaponList[id], newWeaponName)
ArrayPushCell(arrayUserWeaponId[id], weaponId)
}
message_begin(MSG_ONE, gMsgWeaponList, {0, 0, 0}, id)
{
write_string(newWeaponName) // WeaponName
write_byte(gWeaponAmmoIdList[weaponId]) // PrimaryAmmoID
write_byte(gWeaponMaxAmmoList[weaponId]) // PrimaryAmmoMaxAmount
write_byte(-1) // SecondaryAmmoID
write_byte(-1) // SecondaryAmmoMaxAmount
write_byte(gWeaponSlotId[weaponId]) // SlotID (0...N)
write_byte(gWeaponNumberInSlot[weaponId]) // NumberInSlot (1...N)
write_byte(weaponId) // WeaponID
if(flags == -1)
write_byte(gWeaponFlags[weaponId]) // Flags
else
write_byte(flags) // Flags
}
message_end()
}
resetPlayerWeaponSprite(id, weaponId, flags)
{
new lArrayId = ArrayFindValue(arrayUserWeaponId[id], weaponId)
while(lArrayId != -1)
{
ArrayDeleteItem(arrayUserWeaponList[id], lArrayId)
ArrayDeleteItem(arrayUserWeaponId[id], lArrayId)
lArrayId = ArrayFindValue(arrayUserWeaponId[id], weaponId)
}
message_begin(MSG_ONE, gMsgWeaponList, {0, 0, 0}, id)
{
write_string(gWeaponNameList[weaponId]) // WeaponName
write_byte(gWeaponAmmoIdList[weaponId]) // PrimaryAmmoID
write_byte(gWeaponMaxAmmoList[weaponId]) // PrimaryAmmoMaxAmount
write_byte(-1) // SecondaryAmmoID
write_byte(-1) // SecondaryAmmoMaxAmount
write_byte(gWeaponSlotId[weaponId]) // SlotID (0...N)
write_byte(gWeaponNumberInSlot[weaponId]) // NumberInSlot (1...N)
write_byte(weaponId) // WeaponID
if(flags == -1)
write_byte(gWeaponFlags[weaponId]) // Flags
else
write_byte(flags) // Flags
}
message_end()
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3076\\ f0\\ fs16 \n\\ par }
*/