Бих ли могъл под SlotID (5 - c4) да създам други други итеми ?
Код за потвърждение: Избери целия код
string WeaponName
byte PrimaryAmmoID
byte PrimaryAmmoMaxAmount
byte SecondaryAmmoID
byte SecondaryAmmoMaxAmount
byte SlotID
byte NumberInSlot
byte WeaponID
byte Flags
Ако имах мод който би имал "раница" и в нея да има употреби, бих ли могъл да ги инвентаризирам някъде из WeaponList ?
Код за потвърждение: Избери целия код
new MsgIndexWeaponList;
public plugin_init()
{
RegisterHam( Ham_Item_AddToPlayer, "weapon_knife", "OnAddToPlayerKnife", .Post = true );
RegisterHam( Ham_Item_ItemSlot, "weapon_knife", "OnItemSlotKnife" );
MsgIndexWeaponList = get_user_msgid( "WeaponList" );
}
public OnAddToPlayerKnife( const item, const player )
{
if( pev_valid( item ) && is_user_alive( player ) ) // just for safety.
{
message_begin( MSG_ONE, MsgIndexWeaponList, .player = player );
{
write_string("weapon_ArkFlare"); // WeaponName
write_byte( -1 ); // PrimaryAmmoID
write_byte( -1 ); // PrimaryAmmoMaxAmount
write_byte( -1 ); // SecondaryAmmoID
write_byte( -1 ); // SecondaryAmmoMaxAmount
write_byte(4); // SlotID (0...N) <== Changed here (was 2)
write_byte( 1 ); // NumberInSlot (1...N)
write_byte( CSW_KNIFE ); // WeaponID
write_byte( 0 ); // Flags
}
message_end();
}
}
public OnItemSlotKnife( const item )
{
SetHamReturnInteger(5);
return HAM_SUPERCEDE;
}
https://forums.alliedmods.net/showthread.php?t=175632
https://wiki.alliedmods.net/Half-Life_1 ... WeaponList
Код за потвърждение: Избери целия код
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
new MsgIndexWeaponList;
public plugin_precache()
{
precache_generic( "sprites/weapon_ArkFlare.txt" );
precache_generic( "sprites/640hud19.spr" );
precache_generic( "sprites/640hud20.spr" );
}
public plugin_init()
{
RegisterHam( Ham_Item_AddToPlayer, "weapon_knife", "OnAddToPlayerKnife", .Post = true );
RegisterHam( Ham_Item_ItemSlot, "weapon_knife", "OnItemSlotKnife" );
register_clcmd( "weapon_ArkFlare", "ClientCommand_SelectFlare" );
MsgIndexWeaponList = get_user_msgid( "WeaponList" );
}
public ClientCommand_SelectFlare( const client )
{
engclient_cmd( client, "weapon_knife" );
}
public OnAddToPlayerKnife( const item, const player )
{
if( pev_valid( item ) && is_user_alive( player ) ) // just for safety.
{
message_begin( MSG_ONE, MsgIndexWeaponList, .player = player );
{
write_string( "weapon_ArkFlare" ); // WeaponName
write_byte( -1 ); // PrimaryAmmoID
write_byte( -1 ); // PrimaryAmmoMaxAmount
write_byte( -1 ); // SecondaryAmmoID
write_byte( -1 ); // SecondaryAmmoMaxAmount
write_byte( 4 ); // SlotID (0...N)
write_byte( 1 ); // NumberInSlot (1...N)
write_byte( CSW_KNIFE ); // WeaponID
write_byte( 0 ); // Flags
}
message_end();
}
}
public OnItemSlotKnife( const item )
{
SetHamReturnInteger( 5 );
return HAM_SUPERCEDE;
}
The drawbacks are :
Must be based on an original weapon - Meaning you replace an existing weapon, you can't add
Therefore you can have only 29 new weapons at once - which is actually good and you could handle different set of weapons per player
Slot redirection might not work always properly - Discovered while writing the tutorial, it doesn't work well