k guys i have been workin on this script for more than a month and i'm just to lazy to realese/finish it so i need some idea what should i add or w\e, and my buy zone and buy time don't work if someone could help and one more thing is the flash it only appreas for users who the bought the nade so any know how tell me
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <engine>
#include <fakemeta>
#define KeysNades (1<<0)|(1<<1)|(1<<2)|(1<<3)
#define TE_BEAMFOLLOW 22
new g_nMsgScreenFade
public plugin_init()
{
register_plugin( "Grenades mod" ,"1.0", "K007")
register_menucmd(register_menuid("Nades"), KeysNades, "PressedNades")
register_event("CurWeapon","event_curweapon","b")
register_event("ResetHUD","startround","be")
register_event("ScreenFade","FlashedEvent","be","4=255","5=255","6=255","7>199")
register_event("StatusIcon","Buy_Icon","be","2=buyzone")
g_nMsgScreenFade = get_user_msgid("ScreenFade")
register_concmd("say /nadesprices", "funcwepprice")
register_concmd("say /nadesmenu", "ShowNades")
register_cvar("amx_grenades", "1")
register_cvar("amx_smoke_cost", "1000")
register_cvar("amx_he_cost", "1000")
register_cvar("amx_flash_cost", "1000")
register_cvar("amx_he_fuse", "5")
register_cvar("amx_he_nadespeed", "900")
register_cvar("amx_he_launchtime", "1")
register_cvar("amx_flash_mode", "1")
register_cvar("amx_flash_r", "255")
register_cvar("amx_flash_g", "25")
register_cvar("amx_flash_b", "25")
register_cvar("amx_nades_glow", "1");
register_cvar("amx_nades_trail", "2");
}
new bool:hasGLOW[33]
new bool:hasTRAIL[33]
new bool:hasSMOKENADE[33]
new bool:hasHENADE[33]
new bool:hasFLASHNADE[33]
new bool:hasSEEK[33]
new pause_entity[999]
new sprite
new bool:g_buyzone[33] = false
new bool:g_buytime
public plugin_precache()
{
precache_model("models/nades/v_smokegrenade.mdl")
precache_model("models/nades/v_flashbang.mdl")
precache_model("models/nades/v_hegrenade.mdl")
precache_model("models/nades/p_smokegrenade.mdl")
precache_model("models/nades/p_hegrenade.mdl")
precache_model("models/nades/p_flashbang.mdl")
sprite = precache_model("sprites/smoke.spr")
}
public funcbuysmokenade(id)
{
if(get_cvar_num("amx_grenades") == 0)
{
client_print(id,print_chat,"This mod is disabled")
return PLUGIN_HANDLED
}
else
{
new Float:BuyTimeFloat = (get_cvar_float("mp_buytime") * 60)
new BuyTime = floatround(BuyTimeFloat, floatround_floor)
if(!g_buyzone[id]){
client_print(id, print_chat, "[AMXX] Need to be in the buyzone to buy a Smoke Grenade")
return PLUGIN_HANDLED
}
if(!g_buytime){
client_print(id, print_chat, "[AMXX] %d seconds have passed. You can't buy a Smoke Grenade now", BuyTime)
return PLUGIN_HANDLED
}
new price = get_cvar_num("amx_smoke_cost")
hasSMOKENADE[id] = true
hasTRAIL[id] = true
hasGLOW[id] = true
cs_set_user_money(id,cs_get_user_money(id)-get_cvar_num("amx_smoke_cost"))
give_item(id,"weapon_smokegrenade")
cs_set_user_bpammo(id, CSW_SMOKEGRENADE, 1)
client_print(id,print_chat,"You have bought the smoke grenade for %i doallars",price)
set_hudmessage(id, 255, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 4)
show_hudmessage(id, "Your have bought the smoke grenade.")
}
return PLUGIN_HANDLED
}
public funcbuyhenade(id)
{
if(get_cvar_num("amx_grenades") == 0)
{
client_print(id,print_chat,"This mod is disabled")
return PLUGIN_HANDLED
}
else
{
new Float:BuyTimeFloat = (get_cvar_float("mp_buytime") * 60)
new BuyTime = floatround(BuyTimeFloat, floatround_floor)
if(!g_buyzone[id]){
client_print(id, print_chat, "[AMXX] Need to be in the buyzone to buy a Seeking HE grenade")
return PLUGIN_HANDLED
}
if(!g_buytime){
client_print(id, print_chat, "[AMXX] %d seconds have passed. You can't buy a Seeking HE grenade now", BuyTime)
return PLUGIN_HANDLED
}
new price = get_cvar_num("amx_he_cost")
new ammo, clip
new damage
damage = read_data (2)
hasHENADE[id] = true
hasSEEK[id] = true
hasTRAIL[id] = true
hasGLOW[id] = true
cs_set_user_money(id,cs_get_user_money(id)-get_cvar_num("amx_he_cost"))
give_item(id,"weapon_hegrenade")
cs_set_user_bpammo(id, CSW_HEGRENADE, 1)
client_print(id,print_chat,"You have bought the Seeking HE grenade for %i dollars",price)
set_hudmessage(id, 255, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 4)
show_hudmessage(id,"You have bought the Seeking HE grenade.")
if(get_user_weapon(id,ammo,clip) == CSW_HEGRENADE)
{
damage = damage*4/3
}
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public funcbuyflash(id)
{
if(get_cvar_num("amx_grenades") == 0)
{
client_print(id,print_chat,"This mod is disabled")
return PLUGIN_HANDLED
}
else
{
new Float:BuyTimeFloat = (get_cvar_float("mp_buytime") * 60)
new BuyTime = floatround(BuyTimeFloat, floatround_floor)
if(!g_buyzone[id]){
client_print(id, print_chat, "[AMXX] Need to be in the buyzone to buy a Colored Flash Nade")
return PLUGIN_HANDLED
}
if(!g_buytime){
client_print(id, print_chat, "[AMXX] %d seconds have passed. You can't buy a Colored flash Nade now", BuyTime)
return PLUGIN_HANDLED
}
new price = get_cvar_num("amx_flash_cost")
hasFLASHNADE[id] = true
hasTRAIL[id] = true
hasGLOW[id] = true
cs_set_user_money(id,cs_get_user_money(id)-get_cvar_num("amx_flash_cost"))
give_item(id,"weapon_flashbang")
cs_set_user_bpammo(id, CSW_FLASHBANG, 1)
client_print(id,print_chat,"You have bought the Colored Flash nade for %i dollars",price)
set_hudmessage(id, 255, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 4)
show_hudmessage(id, "Your have bought the Colored Flash grenade.")
}
return PLUGIN_HANDLED
}
public END_MENU(id)
{
return PLUGIN_HANDLED
}
public client_PreThink(id)
{
new ammo, clip
if(hasSMOKENADE[id] == true && get_user_weapon(id,ammo,clip) == CSW_SMOKEGRENADE)
{
if(get_user_button(id) & IN_ATTACK)
{
entity_set_vector(id, EV_VEC_punchangle, Float:{0.0, 0.0, 0.0})
}
return PLUGIN_HANDLED
}
if(hasHENADE[id] == true && get_user_weapon(id,ammo,clip) == CSW_HEGRENADE)
{
if(get_user_button(id) & IN_ATTACK)
{
entity_set_vector(id, EV_VEC_punchangle, Float:{0.0, 0.0, 0.0})
}
return PLUGIN_HANDLED
}
if(hasFLASHNADE[id] == true && get_user_weapon(id,ammo,clip) == CSW_FLASHBANG)
{
if(get_user_button(id) & IN_ATTACK)
{
entity_set_vector(id, EV_VEC_punchangle, Float:{0.0, 0.0, 0.0})
}
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public event_curweapon(id)
{
new ammo, clip
if(hasSMOKENADE[id] == true && get_user_weapon(id,ammo,clip) == CSW_SMOKEGRENADE)
{
entity_set_string(id,EV_SZ_viewmodel,"models/nades/v_smokegrenade.mdl")
entity_set_string(id,EV_SZ_weaponmodel,"models/nades/p_smokegrenade.mdl")
}
if(hasHENADE[id] == true && get_user_weapon(id,ammo,clip) == CSW_HEGRENADE)
{
entity_set_string(id,EV_SZ_viewmodel,"models/nades/v_hegrenade.mdl")
entity_set_string(id,EV_SZ_weaponmodel,"models/nades/p_hegrenade.mdl")
}
if(hasFLASHNADE[id] == true && get_user_weapon(id,ammo,clip) == CSW_FLASHBANG)
{
entity_set_string(id,EV_SZ_viewmodel,"models/nades/v_flashbang.mdl")
entity_set_string(id,EV_SZ_weaponmodel,"models/nades/p_flashbang.mdl")
}
}
public funcwepprice(id)
{
new priceSmokenade = get_cvar_num("amx_smoke_cost")
new priceHenade = get_cvar_num("amx_he_cost")
new priceFlash = get_cvar_num("amx_flash_cost")
client_print(id,print_chat,"The smoke nade %i dollars, type /nadesmenu to buy one",priceSmokenade)
client_print(id,print_chat,"The he nade cost %i dollars, type /nadesmenu to buy one",priceHenade)
client_print(id,print_chat,"The flash nade cost %i dollars, type /nadesmenu to buy one",priceFlash)
return PLUGIN_HANDLED
}
public ShowNades(id)
{
if(get_cvar_num("amx_grenades") == 0)
{
client_print(id,print_chat,"This mod is disabled")
return PLUGIN_HANDLED
}
else
{
show_menu(id, KeysNades, "Nades^n^n1. Buy Smoke nade^n2. Buy He nade^n3. Buy Flash nade^n4. Exit^n", -1, "Nades")
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public PressedNades(id, key)
{
switch (key)
{
case 0:
{
funcbuysmokenade(id)
}
case 1:
{
funcbuyhenade(id)
}
case 2:
{
funcbuyflash(id)
}
case 3:
{
END_MENU(id)
}
}
}
public grenade_throw(index, greindex, wId)
{
if(get_cvar_num("amx_grenades") == 1)
{
new id = index
new grenade = greindex
if(hasSEEK[id] == true)
{
if(wId == CSW_HEGRENADE)
{
entity_set_edict(grenade, EV_ENT_owner, id)
new param[1]
param[0] = grenade
new Float:lauchtime = get_cvar_float("amx_he_launchtime")
set_task(lauchtime, "seek_n_destroy", 0, param, 1)
}
new Float:fusetime = get_cvar_float("amx_he_fuse")
pause_entity[greindex] = 1
set_task(fusetime, "nade_explode", grenade)
hasSEEK[id] = false
}
}
new iGrenID = greindex;
new id = index
if(!is_valid_ent(iGrenID)) return PLUGIN_CONTINUE;
if(get_cvar_num("amx_nades_glow") && (hasGLOW[id])) {
switch(wId) {
case CSW_HEGRENADE: set_rendering(iGrenID, kRenderFxGlowShell, 255, 0, 0);
case CSW_FLASHBANG: set_rendering(iGrenID, kRenderFxGlowShell, 0, 255, 0);
case CSW_SMOKEGRENADE: set_rendering(iGrenID, kRenderFxGlowShell, 0, 0, 255);
}
}
new iTrail = get_cvar_num("amx_nades_trail");
if(iTrail == 0 || (iTrail != 1 && iTrail != 2))
return PLUGIN_CONTINUE;
new iTeam = get_user_team(index);
new r=0,g=0,b=0;
switch( iTrail ) {
case 1: {
switch( iTeam ) {
case 1: r=0, b=255, g=0;
case 2: r=255, b=0, g=0;
}
}
case 2: {
switch( wId ) {
case CSW_HEGRENADE: r=255, b=0, g=0;
case CSW_FLASHBANG: r=0, b=0, g=255;
case CSW_SMOKEGRENADE: r=255, b=255, g=255;
}
}
}
if(hasTRAIL[id] == true)
{
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_BEAMFOLLOW );
write_short( iGrenID );
write_short( sprite );
write_byte( 10 );
write_byte( 5 );
write_byte( r );
write_byte( g );
write_byte( b );
write_byte( 150 );
message_end();
return PLUGIN_CONTINUE;
}
return PLUGIN_CONTINUE
}
public seek_n_destroy(param[])
{
new grenade = param[0]
new Float:ShortestDistance = 9999.9
new NearestPlayer = 0
if(is_valid_ent(grenade))
{
new grenade_owner = entity_get_edict(grenade, EV_ENT_owner)
new players[32], count
get_players(players, count)
for(new i = 1; i < count; i++)
{
new vteam = get_user_team(players[i])
new ateam = get_user_team(grenade_owner)
if(vteam != 3)
{
if(is_user_alive(players[i]))
{
if(grenade_owner != (players[i]))
{
if(vteam != ateam)
{
new Float:PlayerOrigin[3], Float:GrenadeOrigin[3]
entity_get_vector(players[i], EV_VEC_origin, PlayerOrigin)
entity_get_vector(grenade, EV_VEC_origin, GrenadeOrigin)
new Float:Distance = vector_distance(PlayerOrigin, GrenadeOrigin)
if(Distance <= ShortestDistance)
{
ShortestDistance = Distance
NearestPlayer = players[i]
}
}
}
}
}
}
}
if(NearestPlayer > 0)
{
new param2[2]
param2[0] = grenade
param2[1] = NearestPlayer
set_task(0.1, "fire_in_the_hole", grenade, param2, 2, "b")
}
}
public fire_in_the_hole(param[])
{
new grenade = param[0]
new target = param[1]
if(is_user_alive(target) && is_valid_ent(grenade))
{
new Float:nadespeed = get_cvar_float("amx_he_nadespeed")
entity_set_follow(grenade, target, nadespeed)
new Float:Velocity[3]
new Float:NewAngle[3]
entity_get_vector(grenade, EV_VEC_velocity, Velocity)
vector_to_angle(Velocity, NewAngle)
entity_set_vector(grenade, EV_VEC_angles, NewAngle)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(22)
write_short(grenade)
write_short(sprite)
write_byte(10)
write_byte(5)
write_byte(255)
write_byte(0)
write_byte(0)
switch(random_num(0,2))
{
case 0:write_byte(64)
case 1:write_byte(128)
case 2:write_byte(192)
}
message_end()
}
else
{
remove_task(grenade)
new param3[1]
param3[0] = grenade
set_task(0.1, "seek_n_destroy", 0, param3, 1)
}
}
public pfn_touch(ptr, ptd)
{
if(is_valid_ent(ptd) && is_valid_ent(ptr) && is_user_connected(ptd) && is_user_alive(ptd))
{
new Classname[32]
entity_get_string(ptr, EV_SZ_classname, Classname, 31)
if(equal(Classname, "grenade"))
{
nade_explode(ptr)
}
}
}
public nade_explode(ent)
{
if(!is_valid_ent(ent)) {
pause_entity[ent] = 0
return
}
if(get_cvar_num("amx_grenades") == 0) {
return
}
pause_entity[ent] = 0
return
}
public fw_entity_think(ent)
{
if(ent < 0 || ent > sizeof(pause_entity)-1 || get_cvar_num("amx_grenades") == 0)
{
return FMRES_IGNORED
}
if(pause_entity[ent] == 1)
{
new Float:nextthink = entity_get_float(ent, EV_FL_nextthink)
set_pev(ent, pev_nextthink, nextthink + 0.1)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
stock entity_set_follow(entity, target, Float:speed)
{
if(!is_valid_ent(entity) || !is_valid_ent(target)) return 0
new Float:entity_origin[3], Float:target_origin[3]
entity_get_vector(entity, EV_VEC_origin, entity_origin)
entity_get_vector(target, EV_VEC_origin, target_origin)
new Float:diff[3]
diff[0] = target_origin[0] - entity_origin[0]
diff[1] = target_origin[1] - entity_origin[1]
diff[2] = target_origin[2] - entity_origin[2]
new Float:length = floatsqroot(floatpower(diff[0], 2.0) + floatpower(diff[1], 2.0) + floatpower(diff[2], 2.0))
new Float:Velocity[3]
Velocity[0] = diff[0] * (speed / length)
Velocity[1] = diff[1] * (speed / length)
Velocity[2] = diff[2] * (speed / length)
entity_set_vector(entity, EV_VEC_velocity, Velocity)
return 1
}
public buy_time() g_buytime = false
public Buy_Icon(id)
{
if(read_data(1))
g_buyzone[id] = true
else
g_buyzone[id] = false
}
public startround(id)
{
hasSMOKENADE[id] = false
hasHENADE[id] = false
hasFLASHNADE[id] = false
hasSEEK[id] = false
hasTRAIL[id] = false
hasGLOW[id] = false
client_print(id,print_chat,"This server is using Super nades mod type /nadesprices in chat to see the nades prices")
set_hudmessage(id, 255, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 4)
show_hudmessage(id, "This server is using Super Nade Mod, type /nadesprices in chat to see the nades prices.")
{
g_buytime = true
set_task(get_cvar_float("mp_buytime"), "buy_time", 0)
}
}
public client_connect(id)
{
hasSMOKENADE[id] = false
hasHENADE[id] = false
hasFLASHNADE[id] = false
hasSEEK[id] = false
hasTRAIL[id] = false
hasGLOW[id] = false
}
public client_disconnect(id)
{
hasSMOKENADE[id] = false
hasHENADE[id] = false
hasFLASHNADE[id] = false
hasSEEK[id] = false
hasTRAIL[id] = false
hasGLOW[id] = false
}
public FlashedEvent(id, wId )
{
new iMode = get_cvar_num("amx_flash_mode")
if ( !iMode ) return PLUGIN_CONTINUE
new iRed,iGreen,iBlue
switch( iMode )
{
case 1:
{
iRed = get_cvar_num("amx_flash_r")
iGreen = get_cvar_num("amx_flash_g")
iBlue = get_cvar_num("amx_flash_b")
}
case 2:
{
iRed = random_num(0,255)
iGreen = random_num(0,255)
iBlue = random_num(0,255)
}
}
if ( !( iRed ) || !( iGreen ) || !( iBlue ) )
{
iRed = 100
iGreen = 100
iBlue = 100
}
if(hasFLASHNADE[id])
{
message_begin( MSG_ONE,g_nMsgScreenFade,{0,0,0}, id)
write_short( read_data( 1 ) ) // Duration
write_short( read_data( 2 ) ) // Hold time
write_short( read_data( 3 ) ) // Fade type
write_byte ( iRed ) // Red
write_byte ( iGreen ) // Green
write_byte ( iBlue ) // Blue
write_byte ( read_data( 7 ) ) // Alpha
message_end()
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}