[APORTE] Crear tus propias armas
#1
Hola, vengo aportar una utileria para sus plugin's (?
Consiste en que puedas crear un arma desde 0

El autor de la base de este plugin le pertenece a NightFury
Se puede crear cosas muy buenas con esta base, lo aporto ya que me retiro de pawn
deje unos ejemplos de como se crean las armas... ya hay ustedes ven como se hace.

PD: no se si sera la mejor manera de crear un arma pero estoy seguro que es mejor que los items de armas que rondan por allied.
PD2: falta agregar para que la mira al disparar se mueva, no lo agrege ya que me da mucha paja :p si alguno lo agrega y lo comparte, actualizo el post

Requisitos
  • Reapi
  • INC
  • Half-Life Model Viewer (Para ver las secuencias)

Que se puede hacer ?
  • Agregar balas
  • Agregar maximo de cartuchos
  • Agregar daño del disparo
  • Agregar velocidad de disparo
  • Agregar velocidad de recarga
  • Agregar model V & P
  • Agregar sonido de disparo
  • Modificar animaciones

Para crear sus propias armas, deben fijarse sus animaciones de su models... tambien recomiendo que lean los inc para que no se sientan perdidos.
codigo:
Código PHP:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <reapi>
#include <weapons>
#include <zombieplague>
#include <engine>
#include <cstrike>

#define id_player(%1) g_give_weapon[%1]


/*=====WEAPONS: ENUMS & DEFINES =====*/
enum {
 
WEAPON_RIFLE,
 
WEAPON_SHOTGUNS,
 
 
WEAPON_FIRE_CLICK,
 
WEAPON_FIRE_AUTO
}
enum _:struct_weapons {
 
WEAPON_CSW,
 
WEAPON_ID,
 
WEAPON_ENT[62],
 
WEAPON_CLIP,
 
WEAPON_MAXAMMO,
 
WEAPON_VMODEL[62],
 
WEAPON_PMODEL[62],
 
WEAPON_SOUND[62],
 
 
WEAPON_SLOTS_ID,
 
WEAPON_STR_ID[32],
 
WEAPON_STR_AMMOID,
 
WEAPON_STR_AMMOMAX,
 
WEAPON_STR_POSITION,
 
WEAPON_STR_ENT,
}
enum _:struct_weapons_anim {
 
WEAPON_ANIM_IDLE,
 
WEAPON_ANIM_SHOOT1,
 
WEAPON_ANIM_SHOOT2,
 
 
WEAPON_ANIM_INSERT1,
 
WEAPON_ANIM_INSERT2,
 
WEAPON_ANIM_AFTER_RELOAD,
 
WEAPON_ANIM_START_RELOAD,
 
WEAPON_ANIM_DRAW,
 
 
WEAPON_MODEWEAPON_FIRE
}
enum _:struct_weapon_atributos {
 
Float:WEAPON_DAMAGE
 
Float:WEAPON_SPEED_RELOAD,
 
Float:WEAPON_SPEED_FIRE
}

/*=====WEAPONS: ESTRUCTURA BASICA DEL ARMA =====*/

new const INDEX_MDL[] = "cs_weapons";
new const 
g_const_weapons[][_:struct_weapons] = { 
 
// CSW   /*ID ENT CLIPS MAXAMMO  V_MODEL    P_MODEL    SOUND_SHOT*/
 
CSW_M37634188"weapon_m3"532"v_spas12""p_spas12""CS_m3",  SLOT_PRIMARYSTRN_M3AMMOID_M3MAXAMMO_M3POSITION_M3ID_M3 },
 { 
CSW_XM10147634198"weapon_xm1014"1090"v_xm1014""p_xm1014""CS_xm1014",  SLOT_PRIMARYSTRN_XM1014AMMOID_XM1014MAXAMMO_XM1014POSITION_XM1014ID_XM1014 },
 { 
CSW_AWP7634196"weapon_awp"290"v_awp""p_awp""CS_awp",  SLOT_PRIMARYSTRN_AWPAMMOID_AWPMAXAMMO_AWPPOSITION_AWPID_AWP},
}
/*=====WEAPONS: ESTRUCTURA BASICA DEL ARMA =====*/

/*=====WEAPONS: ESTRUCTURA DE ANIMACIONES DEL ARMA =====*/
new const g_anim_weapons[][_:struct_weapons_anim] = {
 
/*ESCOPETA*/
 
{  012334,  56,  WEAPON_SHOTGUNSWEAPON_FIRE_AUTO },
 {
  012334,  56,  WEAPON_SHOTGUNSWEAPON_FIRE_AUTO },
 
 
/*RIFLE AWP*/
 
{  01200045WEAPON_RIFLEWEAPON_FIRE_AUTO }
}

/*=====WEAPONS: ESTRUCTURA DE ANIMACIONES DEL ARMA =====*/

/*=====WEAPONS: ESTRUCTURA DE VELOCIDADES =====*/
new const g_weapon_atributos[][_:struct_weapon_atributos] = {
 
// ESTRUCTURA DE ESCOPETAS
 
6.900.471.0 },
 { 
0.550.550.20 },
 
 
// ESTRUCTURA DE AWP
 
90.302.301.15 }
}
/*=====WEAPONS: ESTRUCTURA DE VELOCIDADES =====*/

/*=====WEAPONS: VARIABLES =====*/
new Float:g_flLastDrop[33];
new 
g_give_weapon[33];
new 
g_len[350];

new 
pPlayerpEntityHookChain:TakeDamage
/*=====WEAPONS: VARIABLES =====*/

/*=====ZOMBIE PLAGUE ITEMS IDS=====*/
enum _:struct_items {
 
ITEM_WEAPON_SPAS12,
 
ITEM_WEAPON_AUTO_M3,
 
ITEM_WEAPON_AWP
}

new 
g_items[struct_items];
/*=============================*/

public plugin_precache()
{
 new 
i;
 
 for (
0sizeof (g_const_weapons); i++) {
 
formatex(g_lencharsmax(g_len), "%s/%s.wav"INDEX_MDLg_const_weapons[i][WEAPON_SOUND])
 
engfunc(EngFunc_PrecacheSoundg_len);
 
 
formatex(g_lencharsmax(g_len), "models/%s/%s.mdl"INDEX_MDL,  g_const_weapons[i][WEAPON_VMODEL])
 
engfunc(EngFunc_PrecacheModelg_len);
 
 
formatex(g_lencharsmax(g_len), "models/%s/%s.mdl",  INDEX_MDLg_const_weapons[i][WEAPON_PMODEL])
 
engfunc(EngFunc_PrecacheModelg_len);
 }
}

public 
plugin_init()
{
 
register_plugin("CREATE_WPN""16.11.2018""406")
 
 
g_items[ITEM_WEAPON_SPAS12] = zp_register_items("Escopeta (Spas 12)"90HUMAN80.00);
 
g_items[ITEM_WEAPON_AUTO_M3] = zp_register_items("Escopeta Automatica"110HUMAN90.00);
 
g_items[ITEM_WEAPON_AWP] = zp_register_items("Awp de caza"150HUMAN50.00);
 
 
new  CS_SHOTGUNS = (1<<CSW_M3)|(1<<CSW_XM1014);
 for (new 
0sizeof (g_const_weapons); i++) {
 
RegisterHam(Ham_Item_Deployg_const_weapons[i][WEAPON_STR_ID], "fw_ItemDeployPre"1)
 
RegisterHam(Ham_Weapon_PrimaryAttackg_const_weapons[i][WEAPON_STR_ID], "fw_WeaponPrimaryAttackPre")
 
RegisterHam(Ham_Weapon_Reloadg_const_weapons[i][WEAPON_STR_ID], "fw_WeaponReloadPre")
 
RegisterHam(Ham_Item_AddToPlayerg_const_weapons[i][WEAPON_STR_ID], "fw_ItemAddToPlayerPost"1)
 
RegisterHam(Ham_Weapon_WeaponIdleg_const_weapons[i][WEAPON_STR_ID], "fw_WeaponWeaponIdlePost"1)
 
 
RegisterHam(Ham_Weapon_PrimaryAttackg_const_weapons[i][WEAPON_STR_ID], "fw_Weapon_PrimaryAttack_Post"1)
 
RegisterHam(Ham_Weapon_Reloadg_const_weapons[i][WEAPON_STR_ID], ((1<<i) & CS_SHOTGUNS) ? "Weapon_Reload_Post" "Shotgun_Reload_Post"1
 
 
//register_clcmd( g_const_weapons[i][WEAPON_ENT], "lastinv_m1911a1")
 
}
 
RegisterHam(Ham_Touch"weaponbox""fw_TouchWeapon")
 
register_forward(FM_SetModel"fw_SetModel")
 
 
register_forward(FM_UpdateClientData"fm_UpdateClientDataPost"1)
 
TakeDamage RegisterHookChain(RG_CBasePlayer_TakeDamage"rg_CBasePlayerTakeDamagePre")
 
DisableHookChain(TakeDamage)
 
 
register_clcmd("drop""clcmd_drop")
}

public 
fw_WeaponWeaponIdlePost(entity)
{
 
pPlayer get_member(entitym_pPlayer)
 if(
get_entvar(entityvar_impulse) != g_const_weapons[id_player(pPlayer)][WEAPON_ID] || get_member(entitym_Weapon_flTimeWeaponIdle) > 0.0) return
 
 switch (
g_anim_weapons[id_player(pPlayer)][WEAPON_MODE]) {
 case 
WEAPON_SHOTGUNS: {
 
DefaultWeaponIdleShotGun(entityget_member(entitym_pPlayer), g_const_weapons[id_player(pPlayer)][WEAPON_STR_AMMOID],
 
g_const_weapons[id_player(pPlayer)][WEAPON_CLIP], g_anim_weapons[id_player(pPlayer)][WEAPON_ANIM_INSERT1], g_anim_weapons[id_player(pPlayer)][WEAPON_ANIM_IDLE], 0.53)
 }
 case 
WEAPON_RIFLE: {
 
set_entvar(get_member(entitym_pPlayer), var_weaponanimg_anim_weapons[id_player(pPlayer)][WEAPON_ANIM_IDLE])
 
set_member(entitym_Weapon_flTimeWeaponIdle99999.0)
 }
 }
}
public 
fw_ItemAddToPlayerPost(entityplayer)
{
 new 
iCustom get_entvar(entityvar_impulse)
 
 if(
iCustom && (iCustom != g_const_weapons[id_player(player)][WEAPON_ID]))
 return;
 
 
// ICONO DE WEAPON LIST
 
SendWeaponList(playerg_const_weapons[id_player(player)][WEAPON_ENT],
 
g_const_weapons[id_player(player)][WEAPON_STR_AMMOID], g_const_weapons[id_player(player)][WEAPON_STR_AMMOMAX], 
 
g_const_weapons[id_player(player)][WEAPON_SLOTS_ID], g_const_weapons[id_player(player)][WEAPON_STR_POSITION], g_const_weapons[id_player(player)][WEAPON_STR_ENT])

}

public 
fw_ItemDeployPre(entity)
{
 
pPlayer get_member(entitym_pPlayer)
 
 if(
get_member(pPlayerm_pLastItem) == entity)
 {
 
formatex(g_lencharsmax(g_len), "models/%s/%s.mdl"INDEX_MDLg_const_weapons[id_player(pPlayer)][WEAPON_VMODEL])
 
set_entvar(pPlayervar_viewmodelg_len);
 
 
formatex(g_lencharsmax(g_len), "models/%s/%s.mdl"INDEX_MDLg_const_weapons[id_player(pPlayer)][WEAPON_PMODEL])
 
set_entvar(pPlayervar_weaponmodelg_len)
 return 
HAM_SUPERCEDE
 
}
 if(
get_entvar(entityvar_impulse) != g_const_weapons[id_player(pPlayer)][WEAPON_ID])
 return 
HAM_IGNORED
 
 ExecuteHam
(Ham_Item_Deployentity)
 
 
formatex(g_lencharsmax(g_len), "models/%s/%s.mdl"INDEX_MDLg_const_weapons[id_player(pPlayer)][WEAPON_VMODEL])
 
set_entvar(pPlayervar_viewmodelg_len);
 
 
formatex(g_lencharsmax(g_len), "models/%s/%s.mdl"INDEX_MDL,  g_const_weapons[id_player(pPlayer)][WEAPON_PMODEL])
 
set_entvar(pPlayervar_weaponmodelg_len)
 
 
set_entvar(pPlayervar_weaponanimg_anim_weapons[id_player(pPlayer)][WEAPON_ANIM_DRAW])//
 
 /*TIEMPO DE ANIMACION DRAW*/
 
set_member(pPlayerm_flNextAttack0.9)
 
set_member(entitym_Weapon_flTimeWeaponIdle0.9)
 return 
HAM_SUPERCEDE
}

public 
fw_WeaponReloadPre(entity)

 new 
iClip get_member(entitym_Weapon_iClip)
 
pPlayer get_member(entitym_pPlayer)
 
 if(
get_entvar(entityvar_impulse) != g_const_weapons[id_player(pPlayer)][WEAPON_ID])
 return 
HAM_IGNORED
 
 
if(iClip >= g_const_weapons[id_player(pPlayer)][WEAPON_CLIP] || !get_member(pPlayerm_rgAmmog_const_weapons[id_player(pPlayer)][WEAPON_STR_AMMOID])) 
 return 
HAM_SUPERCEDE
 
 
switch (g_anim_weapons[id_player(pPlayer)][WEAPON_MODE]) {
 case 
WEAPON_SHOTGUNS: {
 
DefaultReloadShotGun(entitypPlayer
 
g_const_weapons[id_player(pPlayer)][WEAPON_STR_AMMOID], iClip,
 
g_const_weapons[id_player(pPlayer)][WEAPON_CLIP],
 
g_anim_weapons[id_player(pPlayer)][WEAPON_ANIM_START_RELOAD],
 
g_anim_weapons[id_player(pPlayer)][WEAPON_ANIM_INSERT1], 0.530.46)
 
 }
 case 
WEAPON_RIFLE: {
 
set_member(pPlayerm_flNextAttack3.23)
 
set_member(entitym_Weapon_flTimeWeaponIdle3.23)
 
 
// ANIMACION DE RELOAD 
 
rg_set_animation(pPlayerPLAYER_RELOAD)
 
set_entvar(pPlayervar_weaponanimg_anim_weapons[id_player(pPlayer)][WEAPON_ANIM_START_RELOAD])
 }
 }
 
ExecuteHam(Ham_Weapon_Reloadentity)
 return 
HAM_SUPERCEDE
}

public 
fw_WeaponPrimaryAttackPre(entity)
{
 
pPlayer get_member(entitym_pPlayer)
 
 if(
get_entvar(entityvar_impulse) != g_const_weapons[id_player(pPlayer)][WEAPON_ID])
 return 
HAM_IGNORED;
 
 
// CONVIERTE LOS DISPAROS EN CLICKS
 
if( g_anim_weapons[id_player(pPlayer)][WEAPON_FIRE] == WEAPON_FIRE_CLICK && get_member(entitym_Weapon_iShotsFired))
 return 
HAM_SUPERCEDE;
 
 static 
iClipiTraceLineiPlaybackEvent
 iClip 
get_member(entitym_Weapon_iClip)
 
 if(
iClip) {
 
iTraceLine register_forward(FM_TraceLine"fm_TraceLinePost"1)
 
iPlaybackEvent register_forward(FM_PlaybackEvent"fm_PlaybackEventPre")
 
EnableHookChain(TakeDamage)
 }
 
 
ExecuteHam(Ham_Weapon_PrimaryAttackentity)
 
 if(!
iClip)
 return 
HAM_SUPERCEDE;
 
 
unregister_forward(FM_TraceLineiTraceLine1)
 
unregister_forward(FM_PlaybackEventiPlaybackEvent)
 
DisableHookChain(TakeDamage)
 
 
formatex(g_lencharsmax(g_len), "%s/%s.wav"INDEX_MDLg_const_weapons[id_player(pPlayer)][WEAPON_SOUND])
 
emit_sound(pPlayerCHAN_WEAPONg_len1.0ATTN_NORM0PITCH_NORM);
 
 
// ANIMACION DE DISPAROS
 
set_entvar(pPlayervar_weaponanimiClip g_anim_weapons[id_player(pPlayer)][WEAPON_ANIM_SHOOT1] : g_anim_weapons[id_player(pPlayer)][WEAPON_ANIM_SHOOT2])
 
 return 
HAM_SUPERCEDE
}

public 
fm_TraceLinePost(Float:vecStart[3], Float:vecEnd[3], noMonsterspentToSkipiTrace)
{
 if(
noMonsters
 return;
 
 if(!
GunshotDecalTrace(iTracetrue)) 
 return;
 
 
get_tr2(iTraceTR_vecEndPosvecEnd)
 
get_tr2(iTraceTR_vecPlaneNormalvecStart)
 
 
/*DATO: SMOKE_RIFLE ES EL HUMO QUE SALE CUANDO LA BALA CHOCA EN ALGO, ACA ES EL EFECTO DE LOS RIFLES, SE PUEDE CAMBIAR POR DE PISTOLAS.*/
 
CreateSmoke(SMOKE_RIFLEvecEndvecStart0.5Float:{40.040.040.0})
}

public 
fm_PlaybackEventPre() 
 return 
FMRES_SUPERCEDE;
 
public 
lastinv_m1911a1(player
 
engclient_cmd(playerg_const_weapons[id_player(player)][WEAPON_STR_ID]);
 
public 
rg_CBasePlayerTakeDamagePre(victiminflictorattackerFloat:flDamage
 
SetHookChainArg(4ATYPE_FLOATflDamage g_weapon_atributos[id_player(attacker)][WEAPON_DAMAGE]);
 
ForwardReload(entity
 
fw_WeaponReloadPre(entity);
 
public 
fm_UpdateClientDataPost(playersendWeaponscd)
{
 if(!
is_user_alive(player)) 
 return;
 
 
pEntity get_member(playerm_pActiveItem)
 
 if(
is_entity(pEntity) && get_entvar(pEntityvar_impulse) == g_const_weapons[id_player(player)][WEAPON_ID])
 
set_cd(cdCD_flNextAttack99999.0)
}

/*====== ITEM DE ZOMBIE PLAGUE ====*/
public zp_item_selected(iditem) {
 
 if (
item == g_items[ITEM_WEAPON_SPAS12]) {
 
g_give_weapon[id] = 0buy_weapons(id);
 return;
 }
 else if (
item == g_items[ITEM_WEAPON_AUTO_M3]) {
 
g_give_weapon[id] = 1buy_weapons(id);
 return;
 }
 else if (
item == g_items[ITEM_WEAPON_AWP]) {
 
g_give_weapon[id] = 2buy_weapons(id);
 return;
 }
 return;
}
/*====== ITEM DE ZOMBIE PLAGUE ====*/

/*SACADO DE POR AHI */
public fw_TouchWeapon(weaponid) {
 if(!
is_user_connected(id))
 return 
HAM_IGNORED
    
 
if(get_gametime() - g_flLastDrop[id] < 0.2)
 return 
HAM_SUPERCEDE
    
 
static iNum;iNum pev(weaponpev_iuser3)
    
 
if(iNum && !cs_get_user_hasprim(id))
 
g_give_weapon[id] = iNum;
 
 return 
HAM_IGNORED
}

public 
fw_SetModel(entity, const model[])
{
 static 
classname[10]
 
pev(entitypev_classnameclassnamecharsmax(classname))
    
 
if (equal(classname"weaponbox"))
 {
 static 
id;id pev(entitypev_owner)
        
 
if(get_user_weapon(id) == g_const_weapons[g_give_weapon[id]][WEAPON_CSW]  && g_give_weapon[id] > 0)
 {
 
set_pev(entitypev_iuser3g_give_weapon[id])
 
g_give_weapon[id] = 0
 g_flLastDrop
[id] = get_gametime()
 }
 }


public 
clcmd_drop(id) {
 if((
1<<get_user_weapon(id)) & g_const_weapons[g_give_weapon[id]][WEAPON_CSW])  set_task(0.1"Clear"id)
    
 
return PLUGIN_CONTINUE;
}

public 
Clear(idg_give_weapon[id] = 0

/***/
public fw_Weapon_PrimaryAttack_Post(weapon_ent)

 new 
id get_pdata_cbase(weapon_ent414
 
 if(!
is_user_alive(id)) 
 return 
HAM_IGNORED
 
 
if(get_entvar(weapon_entvar_impulse) != g_const_weapons[id_player(id)][WEAPON_ID])
 return 
HAM_SUPERCEDE;
        
 
if(cs_get_weapon_id(weapon_ent) != g_const_weapons[g_give_weapon[id]][WEAPON_CSW] || cs_get_weapon_id(weapon_ent) == CSW_FAMAS)
 return 
HAM_IGNORED 
    
 
static Float:flRate 
 flRate 
g_weapon_atributos[g_give_weapon[id]][WEAPON_SPEED_FIRE]
        
 set_pdata_float
(weapon_ent46flRate4
 
set_pdata_float(weapon_ent47flRate4
 
set_pdata_float(weapon_ent48flRate4
    
 
return HAM_IGNORED 
}
public 
Weapon_Reload_Post(iEnt) {
 
 static 
idid get_pdata_cbase(iEnt414
 
 if(
get_entvar(iEntvar_impulse) != g_const_weapons[id_player(id)][WEAPON_ID])
 return;
 
 if (
get_pdata_int(iEnt544))  {
 
set_pdata_float(id83g_weapon_atributos[g_give_weapon[id]][WEAPON_SPEED_RELOAD], 5// m_flNextAttack
 
set_pdata_float(iEnt48g_weapon_atributos[g_give_weapon[id]][WEAPON_SPEED_RELOAD] + 0.54// m_flTimeWeaponIdle
 
set_pev(idpev_frame200.0)
 }
}
public 
Shotgun_Reload_Post(iEnt) {
 if (
get_pdata_int(iEnt554) != 1) return;
 
 static 
idid get_pdata_cbase(iEnt414);
 
 if(
get_entvar(iEntvar_impulse) != g_const_weapons[id_player(id)][WEAPON_ID])
 return;
 
 new 
Float:flTimeWeaponIdle get_pdata_float(iEnt484);
 
 if (
flTimeWeaponIdle != 0.55
 return;
 
 if (
get_pdata_int(iEnt544)) {
 
set_pdata_float(id83g_weapon_atributos[g_give_weapon[id]][WEAPON_SPEED_RELOAD], 5);
 
set_pdata_float(iEnt48g_weapon_atributos[g_give_weapon[id]][WEAPON_SPEED_RELOAD] + 0.54);
 
set_pev(idpev_frame200.0)
 }
}
/************/
public buy_weapons(player)
{
 if(!
is_user_alive(player)) return
 
 
pEntity rg_give_custom_item(playerg_const_weapons[id_player(player)][WEAPON_STR_ID], GT_DROP_AND_REPLACEg_const_weapons[id_player(player)][WEAPON_ID])
 
 
set_member(pEntitym_Weapon_iClipg_const_weapons[id_player(player)][WEAPON_CLIP])
 
 
rg_set_iteminfo(pEntityItemInfo_iMaxClipg_const_weapons[id_player(player)][WEAPON_CLIP])
 
 if(
get_member(playerm_rgAmmog_const_weapons[id_player(player)][WEAPON_STR_AMMOID]) < g_const_weapons[id_player(player)][WEAPON_MAXAMMO])
 
set_member(playerm_rgAmmog_const_weapons[id_player(player)][WEAPON_MAXAMMO], g_const_weapons[id_player(player)][WEAPON_STR_AMMOID])



El registro de items extra que esta puesto es de mi zp, no recuerdo como es el de mercylez, pero pueden guiarse facilmente


Archivos adjuntos
.rar   models.rar (Tamaño: 2.29 MB / Descargas: 4)
.inc   weapons.inc (Tamaño: 8.94 KB / Descargas: 2)
.inc   weapons_const.inc (Tamaño: 4.62 KB / Descargas: 2)
.sma   Descargar AMXX / CS_weapons.sma (Tamaño: 15.24 KB / Descargas: 3)
Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)