Error: Symbol already defined: "amx_gas_maskcost" on line 52
to znacza, ze zmiena o takiej nazwie jest juz zadeklarowana
patrz na to:
new amx_maskcost
new amx_gasnades, amx_gasdmg, amx_gascheck, amx_gasradius, amx_smokegasp, amx_gasobeyFF, amx_gas_restore, amx_gas_maskcost, amx_gas_maskon
Ten kod powinien dzialac
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#define VERSION "1.6"
#if AMXX_VERSION_NUM < 180
#define charsmax(%1) sizeof(%1) - 1
#endif
#define OFFSET_CSDEATHS 444
#define OFFSET_TEAM 114
#define GASP_SOUND1 "player/gasp1.wav"
#define GASP_SOUND2 "player/gasp2.wav"
#define SMOKEGRENADE_SOUND "weapons/sg_explode.wav"
#define GAS_CLASSNAME "gasgrenade"
#define GASNADE_LIFE 25.0
new amx_gasnades, amx_gasdmg, amx_gascheck, amx_gasradius, amx_smokegasp, amx_gasobeyFF, amx_gas_restore, amx_gas_maskcost, amx_gas_maskon
new mp_friendlyfire
new gmsgDamage, gmsgDeathMsg, gmsgScoreInfo
new Float:player_affected_time[33]
new Float:player_restored_time[33]
new Float:damage_took[33]
new bool:has_mask[33]
public plugin_precache()
{
engfunc(EngFunc_PrecacheSound, GASP_SOUND1)
engfunc(EngFunc_PrecacheSound, GASP_SOUND2)
}
public plugin_init()
{
register_plugin("Gas Grenades", VERSION, "ConnorMcLeod") // RichoDemus/AssKicR/T(+)rget for previous versions
register_event("HLTV", "eNewRound", "a", "1=0", "2=0")
register_forward(FM_EmitSound, "fwdEmitSound")
register_forward(FM_Touch, "fwdTouch")
register_forward(FM_Think, "fwdThink")
register_forward(FM_PlayerPreThink, "fwdPlayerPreThink")
register_event("DeathMsg", "player_death", "a")
register_clcmd("say /maska", "mask")
register_cvar("gasnade", VERSION, FCVAR_SERVER)
amx_gasnades = register_cvar("amx_gasnades", "1") // 0/1 Disable/Enable the whole plugin
amx_gasdmg = register_cvar("amx_gasdmg", "2") // How much damage the player takes every check cycle, 0 to disable damage (see amx_gascheck)
amx_gascheck = register_cvar("amx_gascheck", "2") // Check period in seconds
amx_gasradius = register_cvar("amx_gasradius", "180") // Smoke Radius (best is 170 - 230)
amx_smokegasp = register_cvar("amx_smokegasp", "1") // 0/1 Makes players gasp/cough in smoke
amx_gasobeyFF = register_cvar("amx_gasobeyFF", "0") // 0/1 Makes plugin act or not as cvar mp_friendlyfire
amx_gas_restore = register_cvar("amx_gas_restore", "1") // 0/1 Restore or not HP (if amx_gasdmg > 0)
amx_gas_maskon = register_cvar("amx_gas_maskon", "1")
amx_gas_maskcost = register_cvar("amx_gas_maskcost", "500")
}
public plugin_cfg()
{
mp_friendlyfire = get_cvar_pointer("mp_friendlyfire")
gmsgDamage = get_user_msgid("Damage")
gmsgDeathMsg = get_user_msgid("DeathMsg")
gmsgScoreInfo = get_user_msgid("ScoreInfo")
}
public mask(id)
{
if(!is_user_alive(id) && get_pcvar_num(amx_gas_maskon))
{
client_print(id, print_chat, "nie zyjesz")
}
if(has_mask[id])
{
client_print(id, print_chat, "masz maske")
}
if(cs_get_user_money(id) < get_pcvar_num(amx_gas_maskcost) && get_pcvar_num(amx_gas_maskon) && !has_mask[id])
{
client_print(id, print_chat, "nie masz kasy")
}
if(is_user_alive(id) && get_pcvar_num(amx_gas_maskon) && cs_get_user_money(id) >= get_pcvar_num(amx_gas_maskcost) && !has_mask[id])
{
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(amx_gas_maskcost))
client_print(id, print_chat, "kupiles maske")
has_mask[id] = true
}
}
public player_death()
{
new id = read_data(2)
has_mask[id] = false
}
public client_connect(id) {
new Float:global_Time
global_get(glb_time, global_Time)
player_affected_time[id] = global_Time
player_restored_time[id] = global_Time
damage_took[id] = 0.0
}
public eNewRound() {
new ent = -1
while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", GAS_CLASSNAME)) > 0) {
engfunc(EngFunc_RemoveEntity, ent)
}
new Float:global_Time
global_get(glb_time, global_Time)
new players[32], inum, player
get_players(players, inum)
for(new i; i<inum; i++) {
player = players[i]
player_affected_time[player] = global_Time
player_restored_time[player] = global_Time
damage_took[player] = 0.0
}
}
public fwdPlayerPreThink(id) {
if(!get_pcvar_num(amx_gasnades))
return FMRES_IGNORED
static Float:gasdmg
gasdmg = get_pcvar_float(amx_gasdmg)
if( !gasdmg && !get_pcvar_num(amx_gas_restore) )
return FMRES_IGNORED
if( !is_user_alive(id) || !is_user_connected(id))
return FMRES_IGNORED
// check if player has HPs to be set back
static Float:damage_to_restore
damage_to_restore = damage_took[id]
if( damage_to_restore < 1.0 )
return FMRES_IGNORED
static Float:global_Time
global_get(glb_time, global_Time)
static Float:cycle
cycle = get_pcvar_float(amx_gascheck)
// should tell if player is still in smoke
if( global_Time - player_affected_time[id] < cycle + 0.1 )
return FMRES_IGNORED
if( global_Time - player_restored_time[id] < cycle )
return FMRES_IGNORED
static Float:userHealth
pev(id, pev_health, userHealth)
if( damage_to_restore >= gasdmg) {
set_pev(id, pev_health, userHealth + gasdmg)
damage_took[id] -= gasdmg
}
else if( damage_to_restore > 0.0 ) { //shouldn't happen unless an admin change some cvars during a round
set_pev(id, pev_health, userHealth + damage_to_restore)
damage_took[id] -= damage_to_restore
}
player_restored_time[id] = global_Time
return FMRES_HANDLED
}
public fwdEmitSound(entity,channel,const sample[],Float:volume,Float:attenuation,fFlags,pitch)
{
if(!get_pcvar_num(amx_gasnades))
return FMRES_IGNORED
if(!equali(sample, SMOKEGRENADE_SOUND))
return FMRES_IGNORED
static owner
owner = pev(entity, pev_owner)
static Float:origin[3]
pev(entity, pev_origin, origin)
static ent
ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
set_pev(ent, pev_classname, GAS_CLASSNAME)
set_pev(ent,pev_solid,SOLID_TRIGGER)
static Float:radius, Float:min_rad[3], Float:max_rad[3]
radius = get_pcvar_float(amx_gasradius)
min_rad[0] = -radius
min_rad[1] = -radius
min_rad[2] = -radius
max_rad[0] = radius
max_rad[1] = radius
max_rad[2] = radius
engfunc(EngFunc_SetSize, ent, min_rad, max_rad)
set_pev(ent, pev_owner, owner) // cvar amx_gasobeyFF
engfunc(EngFunc_SetOrigin,ent,origin)
new Float:global_Time
global_get(glb_time, global_Time)
set_pev(ent, pev_nextthink, global_Time + GASNADE_LIFE)
return FMRES_HANDLED
}
public fwdThink(ent) {
if(!pev_valid(ent))
return FMRES_IGNORED
static classname[33]
pev(ent, pev_classname, classname, charsmax(classname))
if(!equal(classname,GAS_CLASSNAME))
return FMRES_IGNORED
engfunc(EngFunc_RemoveEntity, ent)
return FMRES_HANDLED
}
public fwdTouch(ent, id) {
if(!is_user_alive(id) || !is_user_connected(id))
return FMRES_IGNORED
if(!pev_valid(ent)) {
return FMRES_IGNORED
}
static classname[33]
pev(ent, pev_classname, classname, charsmax(classname))
if(!equal(classname, GAS_CLASSNAME))
return FMRES_IGNORED
new Float:global_Time
global_get(glb_time, global_Time)
if( global_Time - player_affected_time[id] < get_pcvar_float(amx_gascheck) )
return FMRES_IGNORED
static owner
owner = pev(ent, pev_owner)
if( !get_pcvar_num(mp_friendlyfire) && get_pcvar_num(amx_gasobeyFF) && get_pdata_int(id, OFFSET_TEAM) == get_pdata_int(owner, OFFSET_TEAM) )
return FMRES_IGNORED
player_affected_time[id] = global_Time
msg_damage(id, ent)
if(get_pcvar_num(amx_smokegasp) && !has_mask[id])
{
switch (random_num(1, 2))
{
case 1: emit_sound(id, CHAN_VOICE, GASP_SOUND1, 1.0, ATTN_NORM, 0, PITCH_NORM)
case 2: emit_sound(id, CHAN_VOICE, GASP_SOUND2, 1.0, ATTN_NORM, 0, PITCH_NORM)
}
}
static Float:damage
damage = get_pcvar_float(amx_gasdmg)
if(damage > 0.0) {
ExtraDamage(id, owner, damage, GAS_CLASSNAME)
if(get_pcvar_num(amx_gas_restore)&&!has_mask[id])
{
damage_took[id] += damage
}
}
return FMRES_HANDLED
}
ExtraDamage(id, attacker, Float:damage, weaponDescription[])
{
if(is_user_alive(id))
{
static Float:userHealth
pev(id, pev_health, userHealth)
if(userHealth - damage < 1.0 && !has_mask[id])
{
if(!is_user_connected(attacker))
attacker = 0
add_frags(id, 1.0)
new msgblock = get_msg_block(gmsgDeathMsg)
if(msgblock != BLOCK_SET)
{
set_msg_block(gmsgDeathMsg, BLOCK_ONCE)
make_deathmsg ( attacker, id, 0, weaponDescription )
dllfunc(DLLFunc_ClientKill, id)
set_msg_block(gmsgDeathMsg, msgblock)
}
else
dllfunc(DLLFunc_ClientKill, id)
if(attacker && attacker != id)
{
if( get_pdata_int(id, OFFSET_TEAM) != get_pdata_int(attacker, OFFSET_TEAM) )
add_frags(attacker, 1.0)
else if( get_pcvar_num(mp_friendlyfire) )
add_frags(attacker, -1.0)
}
}
else
{
if(!has_mask[id])
set_pev(id, pev_health, userHealth - damage)
}
}
}
add_frags(id, Float:amount) {
static Float:frags, Float:newfrags
pev(id, pev_frags, frags)
newfrags = amount + frags
set_pev(id, pev_frags, newfrags)
message_begin( MSG_ALL , gmsgScoreInfo )
write_byte( id )
write_short( floatround( newfrags ) )
write_short( get_pdata_int(id, OFFSET_CSDEATHS) )
write_short( 0 )
write_short( get_pdata_int(id, OFFSET_TEAM) )
message_end()
}
msg_damage(id, entity) {
static Float:origin[3]
pev(entity, pev_origin, origin)
if(!has_mask[id])
{
message_begin(MSG_ONE, gmsgDamage, _, id)
write_byte(30) // dmg_save
write_byte(30) // dmg_take
write_long(DMG_SLOWFREEZE) // visibleDamageBits //DMG_ACID , //
engfunc(EngFunc_WriteCoord, origin[0]) //arkshine
engfunc(EngFunc_WriteCoord, origin[1])
engfunc(EngFunc_WriteCoord, origin[2])
message_end()
}
}
[/code]