[ZP] Gold System - How to Make and Add Items
Aug 7, 2017 19:18:08 GMT
$h@DoW, P!KaChu~, and 2 more like this
Post by $h@DoW on Aug 7, 2017 19:18:08 GMT
This is a requested tutorial to me by Members
In this Tutorial I Will show you how to make and add items in Gold Menu
So players can buy and add items according to their own will!
Please Download the Gold System from link below (in case if u haven't)
www.mediafire.com/file/ar42a50d31l80rj/ZP_Gold_System.rar
Just follow me in 3 simple steps !
Step 1 :-
Open any extra item u want to add in Gold Menu
Example
Let's take Blaze ak 47 sma (it is a edited version of golden ak 47)
It's sma looks like this
first add this
It should look like this for now !
Step 2:-
find this code in your extra item
I will find this line in that blaze ak 47
so u find this line in your extra items because every extra item has different code
Go find public plugin_init()
and find this line
Change this zp_register_extra_item -> zp_register_golden_item
Code should look like this
Simple enough ?
just change this single line zp_register_extra_item -> zp_register_golden_item
Ok now these two things are optional
1- If u want to add limit in this Item u will do it like this
Notice here that this 3 thing is the limit
it means the limit of buying this item is 3
ok if u wan't to change limit from 3 to 1 ?
See just change the amount by yourselves?
instead of 3 it is 1
if u want limit 5 ,6 ,7 ,8 or any value just change that last value
2- U want the item only for V.I.P?
Notice this highlighted line
g_itemid = zp_register_golden_item("Blaze Ak 47", 30, ZP_TEAM_HUMAN, 0, 1)
u can see here i have highlighted 0 ?
i have written 0 here because i don't want this item for VIP
0= NOT FOR V.I.P BUT FOR ALL PLAYERS
1= FOR V.I.P ONLY
if u want this Item for V.I.P
write it like this
Limit is 5
and this number 1 is added to define item for V.I.P only
I Hope now u know
1- Add item for All Players
2- Add Item with limit for All Players
3- Add item for V.I.P Only
Let's move on to last and final step 3
Step 3 :-
Find this code in your extra item
public zp_extra_item_selected(player, itemid)
I am going to find it in blaze ak 47
Code in blaze ak 47 looks like this
change this zp_extra_item_selected -> zp_golden_item_selected
so it should look like this
Final Code will look like this
Done and Now compile the sma !
If all steps were done correctly
then u should not get any error !
I hope u all find this tutorial helpful
--------------------------------------------------------------------------------------------------------------------------------------
How to add Gold in Hud Info ?
Step 1 : -
Open zombieplague40.sma
and write this
Step 2 : -
Find this line in the sma
Change it to --->
Done and Now compile the sma !
If all steps were done correctly
then u should not get any error !
I hope u all find this tutorial helpful
Any Questions?
Ask in the comment section below!
In this Tutorial I Will show you how to make and add items in Gold Menu
So players can buy and add items according to their own will!
Please Download the Gold System from link below (in case if u haven't)
www.mediafire.com/file/ar42a50d31l80rj/ZP_Gold_System.rar
Just follow me in 3 simple steps !
Step 1 :-
Open any extra item u want to add in Gold Menu
Example
Let's take Blaze ak 47 sma (it is a edited version of golden ak 47)
It's sma looks like this
#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <cstrike>
#include <zombieplague>
#define is_valid_player(%1) (1 <= %1 <= 32)
new AK_V_MODEL[64] = "models/zombie_plague/v_fire47v1.mdl"
new AK_P_MODEL[64] = "models/zombie_plague/p_fire47v1.mdl"
new AK_W_MODEL[64] = "models/zombie_plague/w_fire47v1.mdl"
/* Pcvars */
new cvar_dmgmultiplier, cvar_goldbullets, cvar_custommodel, cvar_uclip
// Item ID
new g_itemid
new bool:g_HasAk[33]
new g_hasZoom[ 33 ]
new bullets[ 33 ]
// Sprite
new m_spriteTexture
const Wep_ak47 = ((1<<CSW_AK47))
public plugin_init()
{
/* CVARS */
cvar_dmgmultiplier = register_cvar("zp_blazeak_dmg_multiplier", "2.3")
cvar_custommodel = register_cvar("zp_blazeak_custom_model", "1")
cvar_goldbullets = register_cvar("zp_blazeak_gold_bullets", "1")
cvar_uclip = register_cvar("zp_blazeak_unlimited_clip", "1")
// Register The Plugin
register_plugin("[ZP] Extra: Blaze Ak 47", "1.1", "$h@DoW")
// Register Zombie Plague extra item
g_itemid = zp_register_extra_item("Blaze Ak 47", 30, ZP_TEAM_HUMAN)
// 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)
}
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 zp_user_infected_post(id)
{
if (zp_get_user_zombie(id))
{
g_HasAk[id] = false
}
}
public checkModel(id)
{
if ( zp_get_user_zombie(id) )
return PLUGIN_HANDLED
new szWeapID = read_data(2)
if ( szWeapID == CSW_AK47 && 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_AK47 && 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_AK47 && 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_AK47 && 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_AK47 && 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_AK47) && 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(15) // width
write_byte(3) // noise
write_byte( 245 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte(220) // brightness
write_byte(140) // speed
message_end()
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(20) // width
write_byte(6) // noise
write_byte( 0 ) // r, g, b
write_byte( 245 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte(220) // brightness
write_byte(140) // speed
message_end()
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(25) // width
write_byte(9) // noise
write_byte( 0 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte( 245 ) // r, g, b
write_byte(220) // brightness
write_byte(140) // speed
message_end()
}
bullets[id] = clip
}
}
public zp_extra_item_selected(player, itemid)
{
if ( itemid == g_itemid )
{
if ( user_has_weapon(player, CSW_AK47) )
{
drop_prim(player)
}
give_item(player, "weapon_ak47")
client_print(player, print_chat, "[ZP] You bought Blaze Ak 47")
g_HasAk[player] = true;
}
}
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)
}
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
first add this
#include <Gold>
It should look like this for now !
#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <cstrike>
#include <Gold>
#include <zombieplague>
#define is_valid_player(%1) (1 <= %1 <= 32)
new AK_V_MODEL[64] = "models/zombie_plague/v_fire47v1.mdl"
new AK_P_MODEL[64] = "models/zombie_plague/p_fire47v1.mdl"
new AK_W_MODEL[64] = "models/zombie_plague/w_fire47v1.mdl"
/* Pcvars */
new cvar_dmgmultiplier, cvar_goldbullets, cvar_custommodel, cvar_uclip
// Item ID
new g_itemid
new bool:g_HasAk[33]
new g_hasZoom[ 33 ]
new bullets[ 33 ]
// Sprite
new m_spriteTexture
const Wep_ak47 = ((1<<CSW_AK47))
public plugin_init()
{
/* CVARS */
cvar_dmgmultiplier = register_cvar("zp_blazeak_dmg_multiplier", "2.3")
cvar_custommodel = register_cvar("zp_blazeak_custom_model", "1")
cvar_goldbullets = register_cvar("zp_blazeak_gold_bullets", "1")
cvar_uclip = register_cvar("zp_blazeak_unlimited_clip", "1")
// Register The Plugin
register_plugin("[ZP] Extra: Blaze Ak 47", "1.1", "$h@DoW")
// Register Zombie Plague extra item
g_itemid = zp_register_extra_item("Blaze Ak 47", 30, ZP_TEAM_HUMAN)
// 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)
}
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 zp_user_infected_post(id)
{
if (zp_get_user_zombie(id))
{
g_HasAk[id] = false
}
}
public checkModel(id)
{
if ( zp_get_user_zombie(id) )
return PLUGIN_HANDLED
new szWeapID = read_data(2)
if ( szWeapID == CSW_AK47 && 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_AK47 && 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_AK47 && 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_AK47 && 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_AK47 && 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_AK47) && 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(15) // width
write_byte(3) // noise
write_byte( 245 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte(220) // brightness
write_byte(140) // speed
message_end()
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(20) // width
write_byte(6) // noise
write_byte( 0 ) // r, g, b
write_byte( 245 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte(220) // brightness
write_byte(140) // speed
message_end()
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(25) // width
write_byte(9) // noise
write_byte( 0 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte( 245 ) // r, g, b
write_byte(220) // brightness
write_byte(140) // speed
message_end()
}
bullets[id] = clip
}
}
public zp_extra_item_selected(player, itemid)
{
if ( itemid == g_itemid )
{
if ( user_has_weapon(player, CSW_AK47) )
{
drop_prim(player)
}
give_item(player, "weapon_ak47")
client_print(player, print_chat, "[ZP] You bought Blaze Ak 47")
g_HasAk[player] = true;
}
}
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)
}
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Step 2:-
find this code in your extra item
I will find this line in that blaze ak 47
so u find this line in your extra items because every extra item has different code
Go find public plugin_init()
and find this line
g_itemid = zp_register_extra_item("Blaze Ak 47", 30, ZP_TEAM_HUMAN)
Change this zp_register_extra_item -> zp_register_golden_item
Code should look like this
g_itemid = zp_register_golden_item("Blaze Ak 47", 30, ZP_TEAM_HUMAN)
Simple enough ?
just change this single line zp_register_extra_item -> zp_register_golden_item
Ok now these two things are optional
1- If u want to add limit in this Item u will do it like this
g_itemid = zp_register_golden_item("Blaze Ak 47", 30, ZP_TEAM_HUMAN, 0, 3)
Notice here that this 3 thing is the limit
it means the limit of buying this item is 3
ok if u wan't to change limit from 3 to 1 ?
g_itemid = zp_register_golden_item("Blaze Ak 47", 30, ZP_TEAM_HUMAN, 0, 1)
See just change the amount by yourselves?
instead of 3 it is 1
if u want limit 5 ,6 ,7 ,8 or any value just change that last value
2- U want the item only for V.I.P?
Notice this highlighted line
g_itemid = zp_register_golden_item("Blaze Ak 47", 30, ZP_TEAM_HUMAN, 0, 1)
u can see here i have highlighted 0 ?
i have written 0 here because i don't want this item for VIP
0= NOT FOR V.I.P BUT FOR ALL PLAYERS
1= FOR V.I.P ONLY
if u want this Item for V.I.P
write it like this
g_itemid = zp_register_golden_item("Blaze Ak 47", 30, ZP_TEAM_HUMAN, 1, 5)
Limit is 5
and this number 1 is added to define item for V.I.P only
I Hope now u know
1- Add item for All Players
2- Add Item with limit for All Players
3- Add item for V.I.P Only
Let's move on to last and final step 3
Step 3 :-
Find this code in your extra item
public zp_extra_item_selected(player, itemid)
I am going to find it in blaze ak 47
Code in blaze ak 47 looks like this
public zp_extra_item_selected(player, itemid)
{
if ( itemid == g_itemid )
{
if ( user_has_weapon(player, CSW_AK47) )
{
drop_prim(player)
}
give_item(player, "weapon_ak47")
client_print(player, print_chat, "[ZP] You bought Blaze Ak 47")
g_HasAk[player] = true;
}
}
change this zp_extra_item_selected -> zp_golden_item_selected
so it should look like this
public zp_golden_item_selected (player, itemid)
{
if ( itemid == g_itemid )
{
if ( user_has_weapon(player, CSW_AK47) )
{
drop_prim(player)
}
give_item(player, "weapon_ak47")
client_print(player, print_chat, "[ZP] You bought Blaze Ak 47")
g_HasAk[player] = true;
}
}
Final Code will look like this
#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <cstrike>
#include <Gold>
#include <zombieplague>
#define is_valid_player(%1) (1 <= %1 <= 32)
new AK_V_MODEL[64] = "models/zombie_plague/v_fire47v1.mdl"
new AK_P_MODEL[64] = "models/zombie_plague/p_fire47v1.mdl"
new AK_W_MODEL[64] = "models/zombie_plague/w_fire47v1.mdl"
/* Pcvars */
new cvar_dmgmultiplier, cvar_goldbullets, cvar_custommodel, cvar_uclip
// Item ID
new g_itemid
new bool:g_HasAk[33]
new g_hasZoom[ 33 ]
new bullets[ 33 ]
// Sprite
new m_spriteTexture
const Wep_ak47 = ((1<<CSW_AK47))
public plugin_init()
{
/* CVARS */
cvar_dmgmultiplier = register_cvar("zp_blazeak_dmg_multiplier", "2.3")
cvar_custommodel = register_cvar("zp_blazeak_custom_model", "1")
cvar_goldbullets = register_cvar("zp_blazeak_gold_bullets", "1")
cvar_uclip = register_cvar("zp_blazeak_unlimited_clip", "1")
// Register The Plugin
register_plugin("[ZP] Extra: Blaze Ak 47", "1.1", "$h@DoW")
// Register Zombie Plague extra item
g_itemid = zp_register_golden_item("Blaze Ak 47", 30, ZP_TEAM_HUMAN)
// 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)
}
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 zp_user_infected_post(id)
{
if (zp_get_user_zombie(id))
{
g_HasAk[id] = false
}
}
public checkModel(id)
{
if ( zp_get_user_zombie(id) )
return PLUGIN_HANDLED
new szWeapID = read_data(2)
if ( szWeapID == CSW_AK47 && 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_AK47 && 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_AK47 && 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_AK47 && 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_AK47 && 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_AK47) && 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(15) // width
write_byte(3) // noise
write_byte( 245 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte(220) // brightness
write_byte(140) // speed
message_end()
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(20) // width
write_byte(6) // noise
write_byte( 0 ) // r, g, b
write_byte( 245 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte(220) // brightness
write_byte(140) // speed
message_end()
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(25) // width
write_byte(9) // noise
write_byte( 0 ) // r, g, b
write_byte( 0 ) // r, g, b
write_byte( 245 ) // r, g, b
write_byte(220) // brightness
write_byte(140) // speed
message_end()
}
bullets[id] = clip
}
}
public zp_golden_item_selected(player, itemid)
{
if ( itemid == g_itemid )
{
if ( user_has_weapon(player, CSW_AK47) )
{
drop_prim(player)
}
give_item(player, "weapon_ak47")
client_print(player, print_chat, "[ZP] You bought Blaze Ak 47")
g_HasAk[player] = true;
}
}
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)
}
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Done and Now compile the sma !
If all steps were done correctly
then u should not get any error !
I hope u all find this tutorial helpful
--------------------------------------------------------------------------------------------------------------------------------------
How to add Gold in Hud Info ?
Step 1 : -
Open zombieplague40.sma
and write this
#include <Gold>
Step 2 : -
Find this line in the sma
// Spectating someone else?
if (id != ID_SHOWHUD)
{
// Show name, health, class, and ammo packs
set_dhudmessage(255, 255, 255, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0)
show_dhudmessage(ID_SHOWHUD, "%L %s^nHP: %d - %L %s - %L %d", ID_SHOWHUD, "SPECTATING", g_playername[id], pev(id, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[id])
}
else
{
// Show health, class and ammo packs
set_dhudmessage(red, green, blue, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0)
show_dhudmessage(ID_SHOWHUD, "%L: %d - %L %s - %L %d", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD])
}
}
Change it to --->
// Spectating someone else?
if (id != ID_SHOWHUD)
{
// Show name, health, class, and ammo packs
set_dhudmessage(255, 255, 255, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0)
show_dhudmessage(ID_SHOWHUD, "%L %s^nHP: %d - %L %s - %L %d - Gold: %i", ID_SHOWHUD, "SPECTATING", g_playername[id], pev(id, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[id], zp_get_user_gold(id))
}
else
{
// Show health, class and ammo packs
set_dhudmessage(red, green, blue, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0)
show_dhudmessage(ID_SHOWHUD, "%L: %d - %L %s - %L %d - Gold: %i", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], zp_get_user_gold(id))
}
}
Done and Now compile the sma !
If all steps were done correctly
then u should not get any error !
I hope u all find this tutorial helpful
Any Questions?
Ask in the comment section below!