PHP- Kodu:
/*
ZP_weapon m249 from CSO by CEP}I{.
*/
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <cstrike>
#include <basebuilder>
#define is_valid_player(%1) (1 <= %1 <= 32)
#define ENG_NULLENT -1
#define EV_INT_WEAPONKEY EV_INT_impulse
#define GAK_WEAPONKEY 666
new const g_GAKEnt[] = "weapon_m249"
new AK_V_MODEL[64] = "models/v_mv36.mdl"
new AK_P_MODEL[64] = "models/p_mv36.mdl"
new AK_W_MODEL[64] = "models/w_mv36.mdl"
/* Pcvars */
new cvar_dmgmultiplier, cvar_goldbullets, cvar_custommodel, cvar_uclip, cvar_fiyat
new bool:g_HasAk[33]
new g_hasZoom[ 33 ]
new bullets[ 33 ]
// Sprite
new m_spriteTexture
const Wep_ak47 = ((1<<CSW_M249))
public plugin_init()
{
register_clcmd("say /mg36","zp_extra_item_selected")
register_clcmd("say_team /mg36","zp_extra_item_selected")
register_logevent("eRoundStart", 2, "1=Round_Start")
/* CVARS */
cvar_dmgmultiplier = register_cvar("zp_mg_dmg_multiplier", "5")
cvar_custommodel = register_cvar("zp_mg_custom_model", "1")
cvar_goldbullets = register_cvar("zp_mg_gold_bullets", "0")
cvar_uclip = register_cvar("zp_mg_unlimited_clip", "0")
cvar_fiyat = register_cvar("bb_m36_fiyat","1250")
// Register The Plugin
register_plugin("mg36", "1.1", "CEP}I{")
register_cvar("Cep}I{", "[ZP] mg36 [w_ model added]", FCVAR_SERVER|FCVAR_SPONLY)
// Death Msg
register_event("DeathMsg", "Death", "a")
// Weapon Pick Up
register_event("WeapPickup","checkModel","b","1=19")
// Current Weapon Event
register_event("CurWeapon","checkWeapon","be","1=1")
register_event("CurWeapon", "make_tracer", "be", "1=1", "3>0")
// Ham TakeDamage
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
register_forward( FM_CmdStart, "fw_CmdStart" )
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
RegisterHam(Ham_Item_AddToPlayer, g_GAKEnt, "fw_GAK47AddToPlayer")
register_forward(FM_SetModel, "fw_SetModel")
}
public client_connect(id)
{
g_HasAk[id] = false
}
public client_disconnect(id)
{
g_HasAk[id] = false
}
public Death()
{
g_HasAk[read_data(2)] = false
}
public fwHamPlayerSpawnPost(id)
{
g_HasAk[id] = false
}
public plugin_precache()
{
precache_model(AK_V_MODEL)
precache_model(AK_P_MODEL)
precache_model(AK_W_MODEL)
m_spriteTexture = precache_model("sprites/dot.spr")
precache_sound("weapons/zoom.wav")
}
public checkModel(id)
{
if ( bb_is_user_zombie(id) )
return PLUGIN_HANDLED
new szWeapID = read_data(2)
if ( szWeapID == CSW_M249 && g_HasAk[id] == true && get_pcvar_num(cvar_custommodel) )
{
set_pev(id, pev_viewmodel2, AK_V_MODEL)
set_pev(id, pev_weaponmodel2, AK_P_MODEL)
}
return PLUGIN_HANDLED
}
public checkWeapon(id)
{
new plrClip, plrAmmo, plrWeap[32]
new plrWeapId
plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
if (plrWeapId == CSW_M249 && g_HasAk[id])
{
checkModel(id)
}
else
{
return PLUGIN_CONTINUE
}
if (plrClip == 0 && get_pcvar_num(cvar_uclip))
{
// If the user is out of ammo..
get_weaponname(plrWeapId, plrWeap, 31)
// Get the name of their weapon
give_item(id, plrWeap)
engclient_cmd(id, plrWeap)
engclient_cmd(id, plrWeap)
engclient_cmd(id, plrWeap)
}
return PLUGIN_HANDLED
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
if ( is_valid_player( attacker ) && get_user_weapon(attacker) == CSW_M249 && g_HasAk[attacker] )
{
SetHamParamFloat(4, damage * get_pcvar_float( cvar_dmgmultiplier ) )
}
}
public fw_CmdStart( id, uc_handle, seed )
{
if( !is_user_alive( id ) )
return PLUGIN_HANDLED
if( ( get_uc( uc_handle, UC_Buttons ) & IN_ATTACK2 ) && !( pev( id, pev_oldbuttons ) & IN_ATTACK2 ) )
{
new szClip, szAmmo
new szWeapID = get_user_weapon( id, szClip, szAmmo )
if( szWeapID == CSW_M249 && g_HasAk[id] == true && !g_hasZoom[id] == true)
{
g_hasZoom[id] = true
cs_set_user_zoom( id, CS_SET_AUGSG552_ZOOM, 0 )
emit_sound( id, CHAN_ITEM, "weapons/zoom.wav", 0.20, 2.40, 0, 100 )
}
else if ( szWeapID == CSW_M249 && g_HasAk[id] == true && g_hasZoom[id])
{
g_hasZoom[ id ] = false
cs_set_user_zoom( id, CS_RESET_ZOOM, 0 )
}
}
return PLUGIN_HANDLED
}
public make_tracer(id)
{
if (get_pcvar_num(cvar_goldbullets))
{
new clip,ammo
new wpnid = get_user_weapon(id,clip,ammo)
new pteam[16]
get_user_team(id, pteam, 15)
if ((bullets[id] > clip) && (wpnid == CSW_M249) && g_HasAk[id])
{
new vec1[3], vec2[3]
get_user_origin(id, vec1, 1) // origin; your camera point.
get_user_origin(id, vec2, 4) // termina; where your bullet goes (4 is cs-only)
//BEAMENTPOINTS
message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
write_byte (0) //TE_BEAMENTPOINTS 0
write_coord(vec1[0])
write_coord(vec1[1])
write_coord(vec1[2])
write_coord(vec2[0])
write_coord(vec2[1])
write_coord(vec2[2])
write_short( m_spriteTexture )
write_byte(1) // framestart
write_byte(5) // framerate
write_byte(2) // life
write_byte(10) // width
write_byte(0) // noise
write_byte( 255 ) // r, g, b
write_byte( 215 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte(200) // brightness
write_byte(150) // speed
message_end()
}
bullets[id] = clip
}
}
public zp_extra_item_selected(id)
{
if(!is_user_alive(id)) return;
if(!(get_user_flags(id) & ADMIN_RCON)) {
return PLUGIN_HANDLED
}
new fiyat = get_pcvar_num(cvar_fiyat)
new oyuncu_para = cs_get_user_money(id)
if(oyuncu_para >= fiyat) {
cs_set_user_money(id, fiyat - oyuncu_para)
if(user_has_weapon(id, CSW_M249))
{
drop_prim(id)
}
give_item(id, "weapon_m249")
client_print(id, print_chat, "[BaseBuilder]: MG36 satin alindi.")
g_HasAk[id] = true;
} else {
client_print(id, print_center, "Yetersiz Para")
}
}
public eRoundStart() {
new players[32], inum
static id
get_players(players, inum)
for(new i;i<inum;i++) {
id = players[i]
g_HasAk[id] = false
}
}
// Added by Shidla
public fw_SetModel(entity, model[])
{
// Entity is not valid
if(!is_valid_ent(entity))
return FMRES_IGNORED;
// Entity model is not w_ak47
if(!equal(model, "models/w_m249.mdl"))
return FMRES_IGNORED;
// Get classname
static szClassName[33]
entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
// Not a Weapon box
if(!equal(szClassName, "weaponbox"))
return FMRES_IGNORED
// Some vars
static iOwner, iStoredGalilID
// Get owner
iOwner = entity_get_edict(entity, EV_ENT_owner)
// Get drop weapon index (galil) to use in fw_Galil_AddToPlayer forward
iStoredGalilID = find_ent_by_owner(ENG_NULLENT, "weapon_m249", entity)
// Entity classname is weaponbox, and galil has founded
if(g_HasAk[iOwner] && is_valid_ent(iStoredGalilID))
{
// Setting weapon options
entity_set_int(iStoredGalilID, EV_INT_WEAPONKEY, GAK_WEAPONKEY)
// Reset user vars
g_HasAk[iOwner] = false
// Set weaponbox new model
entity_set_model(entity, AK_W_MODEL)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
// Added by Shidla
public fw_GAK47AddToPlayer (GAK47, id)
{
// Make sure that this is M79
if( is_valid_ent(GAK47) && is_user_connected(id) && entity_get_int(GAK47, EV_INT_WEAPONKEY) == GAK_WEAPONKEY)
{
// Update
g_HasAk[id] = true
// Reset weapon options
entity_set_int(GAK47, EV_INT_WEAPONKEY, 0)
return HAM_HANDLED
}
return HAM_IGNORED
}
stock drop_prim(id)
{
new weapons[32], num
get_user_weapons(id, weapons, num)
for (new i = 0; i < num; i++) {
if (Wep_ak47 & (1<<weapons[i]))
{
static wname[32]
get_weaponname(weapons[i], wname, sizeof wname - 1)
engclient_cmd(id, "drop", wname)
}
}
}