Veteran Member
|
03-05-2015
, 01:49
[REQ]Drop unlimited clip
|
#1
|
I know i have exotic requests... but...
Can someone do it, or help me out in creating the following
If player has unlimited clip and is infected/killed the unlimited clip to drop just like the jetpack
i posted the code that spawns a jetpack, if anyone could delete the useless stuff from it and merge it into the unlimited clip code, it would be great, thx
Short Explanation:
How to make an entity spawn when a player with unlimited clip dies or is infected ( like jetpack or bat ) ?
Also when a player touches the entity, the entity to dissapear and the player to recieve unlimited clip
Code:
#include <amxmodx>
#include <fakemeta>
#include <zp50_core>
#include <zp50_items>
#include <zp50_colorchat>
/*================================================================================
[Plugin Customization]
=================================================================================*/
/*============================================================================*/
// CS Offsets
#if cellbits == 32
const OFFSET_CLIPAMMO = 51
#else
const OFFSET_CLIPAMMO = 65
#endif
const OFFSET_LINUX_WEAPONS = 4
// Max Clip for weapons
new const MAXCLIP[] = { -1, 13, -1, 10, 1, 7, -1, 30, 30, 1, 30, 20, 25, 30, 35, 25, 12, 20,
10, 30, 100, 8, 30, 30, 20, 2, 7, 30, 30, -1, 50 }
new g_itemid_infammo, g_has_unlimited_clip[33]
public plugin_init()
{
register_plugin("[ZP] Extra: Unlimited Clip", "1.0", "MeRcyLeZZ")
g_itemid_infammo = zp_items_register("Unlimited Clip", 30)
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
register_event("DeathMsg","DeathMsg","a")
}
public DeathMsg(id)
{
new id = read_data(2)
g_has_unlimited_clip[id] = false
}
public zp_fw_core_infect_post(id)
{
g_has_unlimited_clip[id] = false
}
// Player buys our upgrade, set the unlimited ammo flag
public zp_fw_items_select_pre(id, itemid, igc)
{
if( itemid == g_itemid_infammo)
{
if( zp_core_is_zombie(id))
return ZP_ITEM_DONT_SHOW
}
return ZP_ITEM_AVAILABLE
}
public zp_fw_items_select_post(id, item, igc)
{
if(item == g_itemid_infammo)
{
if(g_has_unlimited_clip[id])
{
zp_colored_print(id, "^x04[ZP]^x01 You Already have Unlimited Clip!")
return PLUGIN_HANDLED
}
else
{
zp_colored_print(id, "^x04[ZP]^x01 You bought Unlimited Clip")
g_has_unlimited_clip[id] = true
}
}
return PLUGIN_CONTINUE
}
// Unlimited clip code
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
// Player doesn't have the unlimited clip upgrade
if (!g_has_unlimited_clip[msg_entity])
return;
// Player not alive or not an active weapon
if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1)
return;
static weapon, clip
weapon = get_msg_arg_int(2) // get weapon ID
clip = get_msg_arg_int(3) // get weapon clip
// Unlimited Clip Ammo
if (MAXCLIP[weapon] > 2) // skip grenades
{
set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon]) // HUD should show full clip all the time
if (clip < 2) // refill when clip is nearly empty
{
// Get the weapon entity
static wname[32], weapon_ent
get_weaponname(weapon, wname, sizeof wname - 1)
weapon_ent = fm_find_ent_by_owner(-1, wname, msg_entity)
// Set max clip on weapon
fm_set_weapon_ammo(weapon_ent, MAXCLIP[weapon])
}
}
}
// Find entity by its owner (from fakemeta_util)
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) {}
return entity;
}
// Set Weapon Clip Ammo
stock fm_set_weapon_ammo(entity, amount)
{
set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS);
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/
Helpful jetpack code
Code:
public OnTouchJetPack(ent, id)
{
if(is_valid_ent(ent) && is_user_connected(id))
{
if(!is_user_alive(id)) return PLUGIN_HANDLED;
if(bHasJetpack[id] || zp_get_user_zombie(id) || zp_get_user_survivor(id)) return PLUGIN_HANDLED;
entity_set_int(ent, EV_INT_solid, SOLID_NOT)
remove_entity(ent)
CreateJetPack(id, 0)
client_print(id, print_chat, "[ZP] You got a Jetpack, fly like a BOSS. Hold 'JUMP+DUCK' to fly.")
client_print(id, print_chat, "[ZP] Press mouse 'right-click' to shoot rocket.")
emit_sound(id, CHAN_STATIC, SoundPickup, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
return PLUGIN_CONTINUE;
}
CreateWorldJetPack(id)
{
new ent = create_entity("info_target")
if(!is_valid_ent(ent)) return;
new Float:Aim[3], Float:Origin[3], iColor[3]
velocity_by_aim(id, 32, Aim)
entity_get_vector(id, EV_VEC_origin, Origin)
Origin[0] += 2*Aim[0]
Origin[1] += 2*Aim[1]
entity_set_string(ent, EV_SZ_classname, ClassJetpack)
entity_set_model(ent, ModelJetpack_W)
#if defined MAKE_JETPACK_BOUNCING
entity_set_int(ent, EV_INT_movetype, MOVETYPE_BOUNCE)
#else
entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
#endif
entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)
entity_set_size(ent, Float:{-8.0, -8.0, -8.0}, Float:{8.0, 8.0, 8.0})
entity_set_float(ent, EV_FL_gravity, 1.25)
entity_set_vector(ent, EV_VEC_origin, Origin)
velocity_by_aim(id, 400, Aim)
entity_set_vector(ent, EV_VEC_velocity, Aim)
}
Last edited by Depresie; 03-05-2015 at 03:11.
|
|