Make Extra-Item for VIPs Only

Helping Topics
User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

Make Extra-Item for VIPs Only

#1

Post by Raheem » 2 Years Ago

Extra-Item for VIPs

Scince Zombie Escape v1.3 Jack GamePlay suggested to make native to simply handle the item if it's for VIPs or not. To make item for VIPs you will need to use: ze_set_item_vip(iItemid, szFlag[]) native. It's very simple. Check the following example:
    1. #include <zombie_escape>
    2.  
    3. new g_iItemID
    4.  
    5. public plugin_init()
    6. {
    7.     register_plugin("VIP Extra-Item", "1.0", "Raheem")
    8.    
    9.     // Register the item and save it's id
    10.     g_iItemID = ze_register_item("Ak47", 10, 0) // Item name, Cost, Limit
    11.    
    12.     // Make it just for VIPs - Item on flag A
    13.     ze_set_item_vip(g_iItemID, "VIP_A")
    14. }
    15.  
    16. public ze_select_item_pre(id, itemid)
    17. {
    18.     // This not our item?
    19.     if (itemid != g_iItemID)
    20.         return ZE_ITEM_AVAILABLE
    21.    
    22.     // Available for Humans only, So don't show it for zombies
    23.     if (ze_is_user_zombie(id))
    24.         return ZE_ITEM_DONT_SHOW
    25.    
    26.     // Finally return that it's available
    27.     return ZE_ITEM_AVAILABLE
    28. }
    29.  
    30. public ze_select_item_post(id, itemid)
    31. {
    32.     // This is not our item, Block it here and don't execute the blew code
    33.     if (itemid != g_iItemID)
    34.         return
    35.    
    36.     rg_give_item(id, "weapon_ak47", GT_APPEND)
    37. }
You will find in ze_extraitems.ini generated code like: Notes:
  1. Check VIP flags you can use Avialable Flags.
  2. You can change this access now from ze_extraitems.ini without need to edit it from code again.
  3. Make sure that ze_items_vip.amxx enabled in plugins-zombie_escape.ini

Hope this helps you :smiley:. Thanks.
Last edited by Raheem on 01 Aug 2018, 11:30, edited 1 time in total.
Reason: Updated to work with Zombie Escape v1.3
You don't know? Learn and you will know.

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 626
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 49 times
Age: 19
Contact:

#2

Post by Mohamed Alaa » 2 Years Ago

Fix the code.
It'll show the item for normal players only.
Want your own mod edition? PM me.
Accepting web projects.
CS 1.6 hosting: powergamingtech.com

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#3

Post by Raheem » 2 Years Ago

Ja[C]k GamePlay wrote:
2 Years Ago
Fix the code.
It'll show the item for normal players only.
Oh, I forget to use Not operator (!). Fixed now :) .
You don't know? Learn and you will know.

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 626
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 49 times
Age: 19
Contact:

#4

Post by Mohamed Alaa » 2 Years Ago

Also, this is just advice:
  1. if (ze_is_user_zombie(id))
  2.         return ZE_ITEM_DONT_SHOW
  3.    
  4.     // Player Not VIP?
  5.     if (!(get_user_flags(id) & VIP_ACCESS))
  6.         return ZE_ITEM_DONT_SHOW
To
  1. if (ze_is_user_zombie(id) || (!(get_user_flags(id) & VIP_ACCESS)))
  2.         return ZE_ITEM_DONT_SHOW
Want your own mod edition? PM me.
Accepting web projects.
CS 1.6 hosting: powergamingtech.com

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#5

Post by Raheem » 2 Years Ago

You are right but i do it like this so if someone noob not understand more in codes he just add these lines only and also so i can say what i add.
You don't know? Learn and you will know.

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#6

Post by johnnysins2000 » 2 Years Ago

so u are saying is that we only have to add these lines to make an vip extra item ?


Can We Turn any zp extra item into ze extra item ?

Raheem ?
Nobody Is That Busy If They Make Time :roll:

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#7

Post by Raheem » 2 Years Ago

johnnysins2000, Yes you can convert any ZP5.0 item to our ZE simply without more experience in code. Also with adding these lines you already make the item for VIPs only, This is very simple.
You don't know? Learn and you will know.

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#8

Post by johnnysins2000 » 2 Years Ago

Code: Select all

#include <amxmodx>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
#include <cstrike>
#include <zombie_escape>

#define PLUGIN "OICW"
#define VERSION "1.0"
#define AUTHOR "Dias"

#define V_MODEL "models/v_oicw.mdl"
#define P_MODEL "models/p_oicw.mdl"
#define W_MODEL "models/w_oicw.mdl"
#define S_MODEL "models/s_oicw.mdl"

#define CSW_OICW CSW_M4A1
#define weapon_oicw "weapon_m4a1"
#define OLD_W_MODEL "models/w_m4a1.mdl"
#define WEAPON_EVENT "events/m4a1.sc"
#define WEAPON_SECRETCODE 1992

#define DAMAGE 62
#define GRENADE_DAMAGE 500
#define GRENADE_RADIUS 250
#define BPAMMO 240
#define GRENADE_DEFAULT 6
#define RELOAD_TIME 3.5
#define GRENADE_RELOAD_TIME 3.0
#define CHANGE_TIME 1.0

#define TASK_CHANGE 1987

new const WeaponSounds[8][] = 
{
	"weapons/oicw-1.wav",
	"weapons/oicw_grenade_shoot1.wav",
	"weapons/oicw_grenade_shoot2.wav",
	"weapons/oicw_foley1.wav",
	"weapons/oicw_foley2.wav",
	"weapons/oicw_foley3.wav",
	"weapons/oicw_move_carbine.wav",
	"weapons/oicw_move_grenade.wav"
}

new const WeaponResources[3][] =
{
	"sprites/weapon_oicw.txt",
	"sprites/640hud7_2.spr",
	"sprites/640hud79_2.spr"
}

enum
{
	ANIM_CARBINE_IDLE = 0,
	ANIM_CARBINE_SHOOT1,
	ANIM_CARBINE_SHOOT2,
	ANIM_CARBINE_SHOOT3,
	ANIM_CARBINE_RELOAD,
	ANIM_CARBINE_DRAW,
	ANIM_GRENADE_IDLE,
	ANIM_GRENADE_SHOOT1,
	ANIM_GRENADE_SHOOT2,
	ANIM_MOVE_TO_GRENADE,
	ANIM_MOVE_TO_CARBINE
}

enum
{
	OICW_MODE_CARBINE = 1,
	OICW_MODE_GRENADE
}

new g_OICW
new g_iItemID
new g_Had_Oicw[33], g_WeaponMode[33], g_IsChanging[33], g_GrenadeAmmo[33]
new g_old_weapon[33], g_smokepuff_id, g_ham_bot, shells_model, g_oiwc_event, spr_trail, g_expspr_id, g_SmokeSprId

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
	g_iItemID = ze_register_item("OICW", 10)
	
	register_forward(FM_Think, "fw_Think")
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)	
	register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")	
	register_forward(FM_SetModel, "fw_SetModel")
	register_forward(FM_CmdStart, "fw_CmdStart")
	
	RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack")
	RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")		
	RegisterHam(Ham_Weapon_Reload, weapon_oicw, "fw_Weapon_Reload")
	RegisterHam(Ham_Weapon_Reload, weapon_oicw, "fw_Weapon_Reload_Post", 1)
	RegisterHam(Ham_Weapon_WeaponIdle, weapon_oicw, "fw_Weapon_WeaponIdle_Post", 1)
	RegisterHam(Ham_Item_AddToPlayer, weapon_oicw, "fw_Item_AddToPlayer_Post", 1)
	
	//register_clcmd("admin_get_oicw", "Get_OICW", ADMIN_KICK)
	register_clcmd("weapon_oicw", "hook_weapon")
}

public plugin_precache()
{
	engfunc(EngFunc_PrecacheModel, V_MODEL)
	engfunc(EngFunc_PrecacheModel, P_MODEL)
	engfunc(EngFunc_PrecacheModel, W_MODEL)
	engfunc(EngFunc_PrecacheModel, S_MODEL)
	
	new i 
	for(i = 0; i < sizeof(WeaponSounds); i++)
		engfunc(EngFunc_PrecacheSound, WeaponSounds[i])
	for(i = 0; i < sizeof(WeaponResources); i++)
	{
		if(i == 0) engfunc(EngFunc_PrecacheGeneric, WeaponResources[i])
		else engfunc(EngFunc_PrecacheModel, WeaponResources[i])
	}
	
	g_smokepuff_id = engfunc(EngFunc_PrecacheModel, "sprites/wall_puff1.spr")
	shells_model = engfunc(EngFunc_PrecacheModel, "models/rshell.mdl")
	spr_trail = engfunc(EngFunc_PrecacheModel, "sprites/laserbeam.spr")
	g_expspr_id = engfunc(EngFunc_PrecacheModel, "sprites/zerogxplode.spr")
	g_SmokeSprId = engfunc(EngFunc_PrecacheModel, "sprites/steam1.spr")
	
	register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
	
}

public fw_PrecacheEvent_Post(type, const name[])
{
	if(equal(WEAPON_EVENT, name))
		g_oiwc_event = get_orig_retval()		
}

public ze_select_item_pre(id, itemid) 
{
	if(itemid == g_OICW) Get_OICW(id)
	return ZE_ITEM_AVAILABLE 

	if (ze_is_user_zombie(id))
         return ZE_ITEM_DONT_SHOW
} 

public ze_select_item_post(id, itemid)
{
    // This is not our item, Block it here and don't execute the blew code
    if (itemid != g_iItemID) 
        return
   
    rg_give_item(id, "weapon_m4a1", GT_APPEND)
} 

public Get_OICW(id)
{
	if(!is_user_alive(id))
		return
		
	g_Had_Oicw[id] = 1
	g_WeaponMode[id] = OICW_MODE_CARBINE
	g_IsChanging[id] = 0
	g_GrenadeAmmo[id] = GRENADE_DEFAULT
	
	fm_give_item(id, weapon_oicw)
	
	cs_set_user_bpammo(id, CSW_OICW, BPAMMO)
	update_ammo(id)
}

public update_ammo(id)
{
	if(!is_user_alive(id))
		return
	
	static weapon_ent; weapon_ent = fm_find_ent_by_owner(-1, weapon_oicw, id)
	if(pev_valid(weapon_ent))
	{
		engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, get_user_msgid("CurWeapon"), {0, 0, 0}, id)
		write_byte(1)
		write_byte(CSW_OICW)
		write_byte(cs_get_weapon_ammo(weapon_ent))
		message_end()		
	}
	
	message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("AmmoX"), _, id)
	write_byte(1)
	write_byte(cs_get_user_bpammo(id, CSW_OICW))
	message_end()
}

public Remove_OICW(id)
{
	if(!is_user_connected(id))
		return
		
	g_Had_Oicw[id] = 0
	g_WeaponMode[id] = 0
	g_IsChanging[id] = 0
	g_GrenadeAmmo[id] = 0
}

public hook_weapon(id)
{
	engclient_cmd(id, weapon_oicw)
	return PLUGIN_HANDLED
}

public client_putinserver(id)
{
	if(!g_ham_bot && is_user_bot(id))
	{
		g_ham_bot = 1
		set_task(0.1, "Do_Register_HamBot", id)
	}
}

public Do_Register_HamBot(id)
{
	RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
}

public Event_CurWeapon(id)
{
	if(!is_user_alive(id))
		return
		
	if((get_user_weapon(id) == CSW_OICW && g_Had_Oicw[id]) && g_old_weapon[id] != CSW_OICW)
	{ // Draw
		set_pev(id, pev_viewmodel2, V_MODEL)
		set_pev(id, pev_weaponmodel2, P_MODEL)
		
		if(g_WeaponMode[id] == OICW_MODE_GRENADE)
		{
			static Ent; Ent = fm_get_user_weapon_entity(id, CSW_OICW)
			update_ammo2(id, pev(Ent, pev_iuser3), pev(Ent, pev_iuser4))
		}
		g_WeaponMode[id] = OICW_MODE_CARBINE
		
		set_weapon_anim(id, ANIM_CARBINE_DRAW)
	} else {
		g_IsChanging[id] = 0
	}
	
	g_old_weapon[id] = get_user_weapon(id)
}

public fw_Think(ent)
{
	if(!pev_valid(ent))
		return
		
	static Classname[32]
	pev(ent, pev_classname, Classname, sizeof(Classname))
	
	if(!equal(Classname, "grenade2"))
		return
		
	Make_Explosion(ent)
	engfunc(EngFunc_RemoveEntity, ent)
}

public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
{
	if(!is_user_alive(id) || !is_user_connected(id))
		return FMRES_IGNORED	
	if(get_user_weapon(id) == CSW_OICW && g_Had_Oicw[id])
		set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001) 
	
	return FMRES_HANDLED
}

public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if (!is_user_connected(invoker))
		return FMRES_IGNORED	
	if(get_user_weapon(invoker) != CSW_OICW || !g_Had_Oicw[invoker])
		return FMRES_IGNORED
	
	if(eventid == g_oiwc_event)
	{
		engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
		
		set_weapon_anim(invoker, random_num(ANIM_CARBINE_SHOOT1, ANIM_CARBINE_SHOOT3))
		emit_sound(invoker, CHAN_WEAPON, WeaponSounds[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
		
		make_shell(invoker)
		
		return FMRES_SUPERCEDE
	} 
	
	return FMRES_HANDLED
}

public fw_SetModel(entity, model[])
{
	if(!pev_valid(entity))
		return FMRES_IGNORED
	
	static Classname[32]
	pev(entity, pev_classname, Classname, sizeof(Classname))
	
	if(!equal(Classname, "weaponbox"))
		return FMRES_IGNORED
	
	static iOwner
	iOwner = pev(entity, pev_owner)
	
	if(equal(model, OLD_W_MODEL))
	{
		static weapon; weapon = fm_find_ent_by_owner(-1, weapon_oicw, entity)
		
		if(!pev_valid(weapon))
			return FMRES_IGNORED;
		
		if(g_Had_Oicw[iOwner])
		{
			set_pev(weapon, pev_impulse, WEAPON_SECRETCODE)
			engfunc(EngFunc_SetModel, entity, W_MODEL)
			
			return FMRES_SUPERCEDE
		}
	}

	return FMRES_IGNORED;
}

public fw_CmdStart(id, uc_handle, seed)
{
	if(!is_user_alive(id))
		return FMRES_IGNORED	
	if(get_user_weapon(id) != CSW_OICW || !g_Had_Oicw[id])	
		return FMRES_IGNORED
		
	static NewButton; NewButton = get_uc(uc_handle, UC_Buttons)
	
	if(NewButton & IN_ATTACK)
	{
		if(g_IsChanging[id])
		{
			NewButton &= ~IN_ATTACK
			set_uc(uc_handle, UC_Buttons, NewButton)
			
			return FMRES_IGNORED
		}
		
		if(g_WeaponMode[id] != OICW_MODE_GRENADE)
			return FMRES_IGNORED
			
		NewButton &= ~IN_ATTACK
		set_uc(uc_handle, UC_Buttons, NewButton)
		
		Shoot_Grenade_Handle(id)
	} 
	
	if(NewButton & IN_ATTACK2) {
		NewButton &= ~IN_ATTACK2
		set_uc(uc_handle, UC_Buttons, NewButton)
		
		NewButton &= ~IN_ATTACK
		set_uc(uc_handle, UC_Buttons, NewButton)
		
		if((pev(id, pev_oldbuttons) & IN_ATTACK2))
			return FMRES_IGNORED
		if(get_pdata_float(id, 83, 5) > 0.0)
			return FMRES_IGNORED
			
		g_IsChanging[id] = 1
			
		set_weapons_timeidle(id, CHANGE_TIME + 0.1)
		set_player_nextattack(id, CHANGE_TIME)	
			
		set_weapon_anim(id, g_WeaponMode[id] == OICW_MODE_CARBINE ? ANIM_MOVE_TO_GRENADE : ANIM_MOVE_TO_CARBINE)
		set_task(CHANGE_TIME, "OICW_CHANGE_COMPLETE", id+TASK_CHANGE)
	}
	
	return FMRES_IGNORED
}

public OICW_CHANGE_COMPLETE(id)
{
	id -= TASK_CHANGE
	
	if(!is_user_alive(id))
		return
	if(get_user_weapon(id) != CSW_OICW || !g_Had_Oicw[id])	
		return
	if(!g_IsChanging[id])
		return
		
	g_IsChanging[id] = 0
			
	if(g_WeaponMode[id] == OICW_MODE_CARBINE) g_WeaponMode[id] = OICW_MODE_GRENADE
	else if(g_WeaponMode[id] == OICW_MODE_GRENADE) g_WeaponMode[id] = OICW_MODE_CARBINE
	
	Change_Complete(id, g_WeaponMode[id])
}

public Shoot_Grenade_Handle(id)
{
	if(get_pdata_float(id, 83, 5) > 0.0)
		return
	if(g_WeaponMode[id] != OICW_MODE_GRENADE)	
		return
	if(g_IsChanging[id])
		return
	if(!g_GrenadeAmmo[id])
	{
		client_print(id, print_center, "Out Of Ammo")
		set_pdata_float(id, 83, 1.0, 5)
		
		return
	}
	
	g_GrenadeAmmo[id]--
	update_ammo2(id, -1, g_GrenadeAmmo[id])
	
	static weapon_ent; weapon_ent = fm_find_ent_by_owner(-1, "weapon_knife", id)
	if(pev_valid(weapon_ent)) ExecuteHamB(Ham_Weapon_PrimaryAttack, weapon_ent)	
	
	if(g_GrenadeAmmo[id]) 
	{
		set_weapons_timeidle(id, GRENADE_RELOAD_TIME + 0.1)
		set_player_nextattack(id, GRENADE_RELOAD_TIME)
		
		set_weapon_anim(id, ANIM_GRENADE_SHOOT1)
		emit_sound(id, CHAN_WEAPON, WeaponSounds[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
	} else {
		set_weapons_timeidle(id, (GRENADE_RELOAD_TIME / 3.0) + 0.1)
		set_player_nextattack(id, (GRENADE_RELOAD_TIME / 3.0))
		
		set_weapon_anim(id, ANIM_GRENADE_SHOOT2)
		emit_sound(id, CHAN_WEAPON, WeaponSounds[2], 1.0, ATTN_NORM, 0, PITCH_NORM)
	}
	
	static Float:PunchAngles[3]
	PunchAngles[0] = random_float(-2.0, -4.0)
	PunchAngles[2] = random_float(5.0, -5.0)
	
	set_pev(id, pev_punchangle, PunchAngles)
	
	Create_Grenade(id)
}

public Create_Grenade(id)
{
	static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	if(!pev_valid(Ent)) return
	
	static Float:Origin[3], Float:Angles[3]
	
	get_weapon_attachment(id, Origin, 24.0)
	pev(id, pev_angles, Angles)
	
	set_pev(Ent, pev_movetype, MOVETYPE_PUSHSTEP)
	set_pev(Ent, pev_solid, SOLID_BBOX)
	set_pev(Ent, pev_nextthink, get_gametime() + 2.5)
	
	set_pev(Ent, pev_classname, "grenade2")
	engfunc(EngFunc_SetModel, Ent, S_MODEL)
	set_pev(Ent, pev_origin, Origin)
	set_pev(Ent, pev_angles, Angles)
	set_pev(Ent, pev_owner, id)
	
	// Create Velocity
	static Float:Velocity[3], Float:TargetOrigin[3]
	
	fm_get_aim_origin(id, TargetOrigin)
	get_speed_vector(Origin, TargetOrigin, 900.0, Velocity)
	
	set_pev(Ent, pev_velocity, Velocity)
	
	// Make a Beam
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_BEAMFOLLOW)
	write_short(Ent) // entity
	write_short(spr_trail) // sprite
	write_byte(20)  // life
	write_byte(2)  // width
	write_byte(200) // r
	write_byte(200);  // g
	write_byte(200);  // b
	write_byte(200); // brightness
	message_end();
}

public Make_Explosion(ent)
{
	static Float:Origin[3]
	pev(ent, pev_origin, Origin)
	
	message_begin(MSG_BROADCAST ,SVC_TEMPENTITY)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(g_expspr_id)	// sprite index
	write_byte(30)	// scale in 0.1's
	write_byte(30)	// framerate
	write_byte(0)	// flags
	message_end()
	
	// Put decal on "world" (a wall)
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_WORLDDECAL)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_byte(random_num(46, 48))
	message_end()	
	
	message_begin(MSG_BROADCAST ,SVC_TEMPENTITY)
	write_byte(TE_SMOKE)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(g_SmokeSprId)	// sprite index 
	write_byte(30)	// scale in 0.1's 
	write_byte(10)	// framerate 
	message_end()
	
	static Float:Origin2[3]
	
	for(new i = 0; i < get_maxplayers(); i++)
	{
		if(!is_user_alive(i))
			continue
		pev(i, pev_origin, Origin2)
		if(get_distance_f(Origin, Origin2) > float(GRENADE_RADIUS))
			continue

		ExecuteHamB(Ham_TakeDamage, i, 0, pev(ent, pev_owner), float(GRENADE_DAMAGE), DMG_BULLET)
	}
}

public Change_Complete(id, Mode)
{
	static Ent; Ent = fm_get_user_weapon_entity(id, CSW_OICW)
	if(!pev_valid(Ent))
		return
		
	if(Mode == OICW_MODE_CARBINE)
	{
		update_ammo2(id, pev(Ent, pev_iuser3), pev(Ent, pev_iuser4))
	} else if(Mode == OICW_MODE_GRENADE) {
		set_pev(Ent, pev_iuser3, cs_get_weapon_ammo(Ent))
		set_pev(Ent, pev_iuser4, cs_get_user_bpammo(id, CSW_OICW))
		
		update_ammo2(id, -1, g_GrenadeAmmo[id])
	}
}

public fw_TraceAttack(ent, attacker, Float:Damage, Float:fDir[3], ptr, iDamageType)
{
	if(!is_user_alive(attacker) || !is_user_connected(attacker))
		return HAM_IGNORED	
	if(get_user_weapon(attacker) != CSW_OICW || !g_Had_Oicw[attacker])
		return HAM_IGNORED
		
	static Float:flEnd[3], Float:vecPlane[3]
	
	get_tr2(ptr, TR_vecEndPos, flEnd)
	get_tr2(ptr, TR_vecPlaneNormal, vecPlane)		
		
	if(!is_user_alive(ent))
	{
		make_bullet(attacker, flEnd)
		fake_smoke(attacker, ptr)
	}
		
	SetHamParamFloat(3, float(DAMAGE))	

	return HAM_HANDLED
}

public fw_Weapon_Reload(ent)
{
	static id; id = pev(ent, pev_owner)
	if(!is_user_alive(id))
		return HAM_IGNORED
	if(!g_Had_Oicw[id])
		return HAM_IGNORED
	if(g_WeaponMode[id] == OICW_MODE_GRENADE)
		return HAM_SUPERCEDE
	
	return HAM_HANDLED
}

public fw_Weapon_Reload_Post(ent)
{
	static id; id = pev(ent, pev_owner)
	if(!is_user_alive(id))
		return HAM_IGNORED
	if(!g_Had_Oicw[id])
		return HAM_IGNORED
	if(g_WeaponMode[id] == OICW_MODE_GRENADE)
		return HAM_IGNORED
		
	if((get_pdata_int(ent, 54, 4) == 1) && g_WeaponMode[id] == OICW_MODE_CARBINE)
	{ // Reload
		set_weapon_anim(id, ANIM_CARBINE_RELOAD)
		set_pdata_float(id, 83, RELOAD_TIME, 5)
	}
	
	return HAM_HANDLED
}

public fw_Weapon_WeaponIdle_Post(ent)
{
	static id; id = pev(ent, pev_owner)
	if(!is_user_alive(id))
		return HAM_IGNORED
	if(!g_Had_Oicw[id])
		return HAM_IGNORED
		
	if(get_pdata_float(ent, 48, 4) <= 0.1) 
	{
		set_weapon_anim(id, g_WeaponMode[id] == OICW_MODE_CARBINE ? ANIM_CARBINE_IDLE : ANIM_GRENADE_IDLE)
		set_pdata_float(ent, 48, 20.0, 4)
	}
	
	return HAM_IGNORED
}

public fw_Item_AddToPlayer_Post(ent, id)
{
	if(!pev_valid(ent))
		return HAM_IGNORED
		
	if(pev(ent, pev_impulse) == WEAPON_SECRETCODE)
	{
		g_Had_Oicw[id] = 1
		set_pev(ent, pev_impulse, 0)
	}		
	
	message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("WeaponList"), .player = id)
	write_string(g_Had_Oicw[id] == 1 ? "weapon_oicw" : "weapon_m4a1")
	write_byte(4) // PrimaryAmmoID
	write_byte(90) // PrimaryAmmoMaxAmount
	write_byte(-1) // SecondaryAmmoID
	write_byte(-1) // SecondaryAmmoMaxAmount
	write_byte(0) // SlotID (0...N)
	write_byte(6) // NumberInSlot (1...N)
	write_byte(g_Had_Oicw[id] == 1 ? CSW_OICW : CSW_M4A1) // WeaponID
	write_byte(0) // Flags
	message_end()

	return HAM_HANDLED	
}

stock make_bullet(id, Float:Origin[3])
{
	// Find target
	new decal = random_num(41, 45)
	const loop_time = 2
	
	static Body, Target
	get_user_aiming(id, Target, Body, 999999)
	
	if(is_user_connected(Target))
		return
	
	for(new i = 0; i < loop_time; i++)
	{
		// Put decal on "world" (a wall)
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_WORLDDECAL)
		engfunc(EngFunc_WriteCoord, Origin[0])
		engfunc(EngFunc_WriteCoord, Origin[1])
		engfunc(EngFunc_WriteCoord, Origin[2])
		write_byte(decal)
		message_end()
		
		// Show sparcles
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_GUNSHOTDECAL)
		engfunc(EngFunc_WriteCoord, Origin[0])
		engfunc(EngFunc_WriteCoord, Origin[1])
		engfunc(EngFunc_WriteCoord, Origin[2])
		write_short(id)
		write_byte(decal)
		message_end()
	}
}

public fake_smoke(id, trace_result)
{
	static Float:vecSrc[3], Float:vecEnd[3], TE_FLAG
	
	get_weapon_attachment(id, vecSrc)
	global_get(glb_v_forward, vecEnd)
    
	xs_vec_mul_scalar(vecEnd, 8192.0, vecEnd)
	xs_vec_add(vecSrc, vecEnd, vecEnd)

	get_tr2(trace_result, TR_vecEndPos, vecSrc)
	get_tr2(trace_result, TR_vecPlaneNormal, vecEnd)
    
	xs_vec_mul_scalar(vecEnd, 2.5, vecEnd)
	xs_vec_add(vecSrc, vecEnd, vecEnd)
    
	TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
	TE_FLAG |= TE_EXPLFLAG_NOSOUND
	TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
	
	engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, vecEnd[0])
	engfunc(EngFunc_WriteCoord, vecEnd[1])
	engfunc(EngFunc_WriteCoord, vecEnd[2] - 10.0)
	write_short(g_smokepuff_id)
	write_byte(2)
	write_byte(50)
	write_byte(TE_FLAG)
	message_end()
}

stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
{ 
	new Float:vfEnd[3], viEnd[3] 
	get_user_origin(id, viEnd, 3)  
	IVecFVec(viEnd, vfEnd) 
	
	new Float:fOrigin[3], Float:fAngle[3]
	
	pev(id, pev_origin, fOrigin) 
	pev(id, pev_view_ofs, fAngle)
	
	xs_vec_add(fOrigin, fAngle, fOrigin) 
	
	new Float:fAttack[3]
	
	xs_vec_sub(vfEnd, fOrigin, fAttack)
	xs_vec_sub(vfEnd, fOrigin, fAttack) 
	
	new Float:fRate
	
	fRate = fDis / vector_length(fAttack)
	xs_vec_mul_scalar(fAttack, fRate, fAttack)
	
	xs_vec_add(fOrigin, fAttack, output)
}

stock set_weapon_anim(id, anim)
{
	if(!is_user_alive(id))
		return
	
	set_pev(id, pev_weaponanim, anim)
	
	message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
	write_byte(anim)
	write_byte(pev(id, pev_body))
	message_end()
}

public make_shell(id)
{
	static Float:player_origin[3], Float:origin[3], Float:origin2[3], Float:gunorigin[3], Float:oldangles[3], Float:v_forward[3], Float:v_forward2[3], Float:v_up[3], Float:v_up2[3], Float:v_right[3], Float:v_right2[3], Float:viewoffsets[3];
	
	pev(id,pev_v_angle, oldangles); pev(id,pev_origin,player_origin); pev(id, pev_view_ofs, viewoffsets);

	engfunc(EngFunc_MakeVectors, oldangles)
	
	global_get(glb_v_forward, v_forward); global_get(glb_v_up, v_up); global_get(glb_v_right, v_right);
	global_get(glb_v_forward, v_forward2); global_get(glb_v_up, v_up2); global_get(glb_v_right, v_right2);
	
	xs_vec_add(player_origin, viewoffsets, gunorigin);
	
	xs_vec_mul_scalar(v_forward, 10.3, v_forward); xs_vec_mul_scalar(v_right, 2.9, v_right);
	xs_vec_mul_scalar(v_up, -3.7, v_up);
	xs_vec_mul_scalar(v_forward2, 10.0, v_forward2); xs_vec_mul_scalar(v_right2, 3.0, v_right2);
	xs_vec_mul_scalar(v_up2, -4.0, v_up2);
	
	xs_vec_add(gunorigin, v_forward, origin);
	xs_vec_add(gunorigin, v_forward2, origin2);
	xs_vec_add(origin, v_right, origin);
	xs_vec_add(origin2, v_right2, origin2);
	xs_vec_add(origin, v_up, origin);
	xs_vec_add(origin2, v_up2, origin2);

	static Float:velocity[3]
	get_speed_vector(origin2, origin, random_float(140.0, 160.0), velocity)

	static angle; angle = random_num(0, 360)

	message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
	write_byte(TE_MODEL)
	engfunc(EngFunc_WriteCoord, origin[0])
	engfunc(EngFunc_WriteCoord,origin[1])
	engfunc(EngFunc_WriteCoord,origin[2])
	engfunc(EngFunc_WriteCoord,velocity[0])
	engfunc(EngFunc_WriteCoord,velocity[1])
	engfunc(EngFunc_WriteCoord,velocity[2])
	write_angle(angle)
	write_short(shells_model)
	write_byte(1)
	write_byte(20)
	message_end()
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
{
	new_velocity[0] = origin2[0] - origin1[0]
	new_velocity[1] = origin2[1] - origin1[1]
	new_velocity[2] = origin2[2] - origin1[2]
	new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
	new_velocity[0] *= num
	new_velocity[1] *= num
	new_velocity[2] *= num
	
	return 1;
}

stock set_weapons_timeidle(id, Float:TimeIdle)
{
	if(!is_user_alive(id))
		return
		
	new entwpn = fm_get_user_weapon_entity(id, CSW_OICW)
	if(!pev_valid(entwpn)) 
		return
	
	set_pdata_float(entwpn, 46, TimeIdle, 4)
	set_pdata_float(entwpn, 47, TimeIdle, 4)
	set_pdata_float(entwpn, 48, TimeIdle + 1.0, 4)
}

stock set_player_nextattack(id, Float:nexttime)
{
	if(!is_user_alive(id))
		return
		
	set_pdata_float(id, 83, nexttime, 5)
}

public update_ammo2(id, ammo, bpammo)
{
	if(!is_user_alive(id))
		return
	
	engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, get_user_msgid("CurWeapon"), {0, 0, 0}, id)
	write_byte(1)
	write_byte(CSW_OICW)
	write_byte(ammo)
	message_end()
	
	message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("AmmoX"), _, id)
	write_byte(1)
	write_byte(bpammo)
	message_end()
	
	cs_set_user_bpammo(id, CSW_OICW, bpammo)
}

raheem take a look at this i tried to make oicw as an extra item i got three warnings


could u correct this code plz ?
Nobody Is That Busy If They Make Time :roll:

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#9

Post by Raheem » 2 Years Ago

-Just see your thread: Here.
You don't know? Learn and you will know.

User avatar
sam_bhosale4
Mod Tester
Mod Tester
India
Posts: 109
Joined: 2 Years Ago
Location: INDIA
Has thanked: 5 times
Been thanked: 2 times
Age: 21
Contact:

#10

Post by sam_bhosale4 » 2 Years Ago

Raheem wrote:
2 Years Ago
Extra-Item for VIPs

-You can simply make any extra-item for VIPs only. You don't need to have much experience in scripting, Just with simple things to add it will make the Extra-Item for VIPs only. Let's start with simple example, If we have this item for humans it will give player AK-47 when he buy this item and now the code:

  1. #include <zombie_escape>
  2.  
  3. new g_iItemID
  4.  
  5. public plugin_init()
  6. {
  7.     register_plugin("Human Extra-Item Example", "1.0", "Raheem")
  8.    
  9.     // Register the item and save it's id
  10.     g_iItemID = ze_register_item("Ak47", 10)
  11. }
  12.  
  13. public ze_select_item_pre(id, itemid)
  14. {
  15.     // This not our item?
  16.     if (itemid != g_iItemID)
  17.         return ZE_ITEM_AVAILABLE
  18.    
  19.     // Available for Humans only, So don't show it for zombies
  20.     if (ze_is_user_zombie(id))
  21.         return ZE_ITEM_DONT_SHOW
  22.    
  23.     // Finally return that it's available
  24.     return ZE_ITEM_AVAILABLE
  25. }
  26.  
  27. public ze_select_item_post(id, itemid)
  28. {
  29.     // This is not our item, Block it here and don't execute the blew code
  30.     if (itemid != g_iItemID)
  31.         return
  32.    
  33.     rg_give_item(id, "weapon_ak47", GT_APPEND)
  34. }

-Now i add some simple lines you can note them:
  • #define VIP_ACCESS ADMIN_LEVEL_H
  • if (!(get_user_flags(id) & VIP_ACCESS))
  • return ZE_ITEM_DONT_SHOW

-Final Code:

  1. #include <zombie_escape>
  2.  
  3. #define VIP_ACCESS ADMIN_LEVEL_H
  4.  
  5. new g_iItemID
  6.  
  7. public plugin_init()
  8. {
  9.     register_plugin("VIP Human Extra-Item Example", "1.0", "Raheem")
  10.    
  11.     // Register the item and save it's id
  12.     g_iItemID = ze_register_item("Ak47", 10)
  13. }
  14.  
  15. public ze_select_item_pre(id, itemid)
  16. {
  17.     // This not our item?
  18.     if (itemid != g_iItemID)
  19.         return ZE_ITEM_AVAILABLE
  20.    
  21.     // Available for Humans only, So don't show it for zombies
  22.     if (ze_is_user_zombie(id))
  23.         return ZE_ITEM_DONT_SHOW
  24.    
  25.     // Player Not VIP?
  26.     if (!(get_user_flags(id) & VIP_ACCESS))
  27.         return ZE_ITEM_DONT_SHOW
  28.    
  29.     // Finally return that it's available
  30.     return ZE_ITEM_AVAILABLE
  31. }
  32.  
  33. public ze_select_item_post(id, itemid)
  34. {
  35.     // This is not our item, Block it here and don't execute the blew code
  36.     if (itemid != g_iItemID)
  37.         return
  38.    
  39.     rg_give_item(id, "weapon_ak47", GT_APPEND)
  40. }

-And make sure that the Access in the VIP System plugin same with one you add to the Extra-Item. If you done these simple steps now compile the extra-item and install it on your server and then see now this item only will be shown for the humans vips only. Hope this be simple for you. If you can't do these steps just post in the item topic that you need to convert it to VIPs only and one of the supporters team will help you :). Have Fun.
Nice one raheem bro! Simple and good!
but can you also add ammo code in that? because the example u given ak47 it will get ak47 with 30 ammo only cant reload! no bakpack ammo!
so if you add bakpack ammo it will be good!
-=SeRious-GaminG|Zombie Escape[Alien vs. Predator]|Asia=-
206.189.132.169:40000
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest