Благодаря предварително!
Код за потвърждение: Избери целия код
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <fakemeta>
#include <amxmisc>
#include <hamsandwich>
#include <Goldanite>
#include <fun>
#include <cstrike>
#include <colorchat>
#include <xs>
/* ToDo List:
* da se naporawi cvar koito pri kill d ane ti gi vzima
* da moje da se blokira dadeno orujie za daden chovek
* /rgoldenak smir - request goldenak from SmirnoffBG
* kat nqkoi ubie goldadjiq da mu dava 200 pari otgore
* naprawi gold da moje da se kopiva po poveche ot vednuj i da ima otstupka ot +10% na broika i da stiga do 50%
*
*/
#define PLUGIN "Goldanite"
#define VERSION "4.4"
#define AUTHOR "SmirnoffBG"
#define SPAMA 111
#define SPAMA2 222
#define SPAWNGOLD 333
#define COSTA2 444
#define VIPA 555
#define FREEGOLDA 666
#define WORLDA 777
//#define COLOR
// This native gets the colorfull name form colornames plugin and return its team color
#if defined COLOR
native colornames_name(id, name[191])
#endif
new bool:gHas_Golden[33][33], texta[33][191], user_name[33][50]
new beama, gold_menu, costa, VIPflaga = ADMIN_LEVEL_A, FreeGold = ADMIN_RCON
new wepid2[33], bool:GoldBackup[33], bool:AllowedWeps[33], gold_vip_menu
new pcvar_no_spam
new TeamNames[][]=
{
"Players",
"Terrorists",
"Counter-Terrorinss",
"Spectators"
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
pcvar_no_spam = register_cvar("golden_nospam", "0")
register_clcmd("say gold", "ShowMenu")
register_clcmd("say goldmenu", "ShowMenu")
register_clcmd("say /gold", "ShowMenu")
register_clcmd("say /goldmenu", "ShowMenu")
register_clcmd("say_team /goldmenu", "ShowMenu")
register_clcmd("say_team /gold", "ShowMenu")
register_clcmd("say /goldme", "GoldMe")
RegisterHam(Ham_Spawn, "player", "fw_Spawned", 1)
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
RegisterHam(Ham_Killed, "player", "fw_Killed")
RegisterHam(Ham_TraceAttack, "player", "fwTraceAttack")
RegisterHam(Ham_TraceAttack, "worldspawn", "fwTraceAttack")
RegisterHam(Ham_TraceAttack, "func_breakable", "fwTraceAttack")
for(new i=0;i<sizeof Wep_Names; i++)
RegisterHam(Ham_Item_Deploy, Wep_Names[i], "ModelChange", 1)
get_cvar_string("hostname",user_name[0], 49)
register_clcmd("say", "Golden_Handle")
AllowedWeps[2] = true
}
public plugin_natives()
{
register_native("gold_give", "_gold_give")
register_native("gold_has", "_gold_has")
}
// native gold_give(id, tid, const weapons[] = {0}, numofwpns = 0)
public _gold_give()
{
new id = get_param(1)
new tid = get_param(2)
new numWpns = get_param(4)
if(numWpns>0)
{
new pWeapons[31]
get_array(3, pWeapons, numWpns)
for ( new x; x < numWpns; x++ )
{
if(pWeapons[x] == 2) continue
give_gold(id, tid, pWeapons[x])
}
} else {
for(new wepID=CSW_P228;wepID<=CSW_P90;wepID++)
{
if(wepID == 2) continue
give_gold(id, tid, wepID)
}
}
}
// native gold_has(id, WeaponID)
public _gold_has()
{
new id = get_param(1)
new wepID = get_param(2)
if(gHas_Golden[wepID][id]) return 1
return 0
}
public plugin_precache()
{
new gConfigFile[50], iFileP, FullCmd[50], the_cmd[50], Float:price;
new callbacka, var[50], chara = 6, wepid, ItemName[50];
get_configsdir(gConfigFile, sizeof gConfigFile - 1);
add(gConfigFile, sizeof gConfigFile - 1, "/multi-golden.cfg");
gold_menu = menu_create("\yGold \wMenu^n\yFor \rV\w.\rI\w.\rP\w. there is \r50% OFF!", "GoldMenuto")
gold_vip_menu = menu_create("\yGold \rV\w.\rI\w.\rP\w. Menu^n", "GoldMenuto")
callbacka = menu_makecallback("GoldCallBack")
iFileP = fopen(gConfigFile, "rt")
while(!feof(iFileP))
{
fgets(iFileP, FullCmd, charsmax(FullCmd))
remove_quotes(FullCmd)
if( !FullCmd[0] || FullCmd[0] == ';' || FullCmd[0] == '/' && FullCmd[1] == '/' || FullCmd[0] != 'g')
continue;
parse(FullCmd, the_cmd, charsmax(the_cmd), var, charsmax(var))
if(var[0] == '0') continue
switch(wepid = Get_WepID(the_cmd, chara))
{
case COSTA2: costa = str_to_num(var)
case VIPA: VIPflaga = read_flags(var)
case FREEGOLDA: FreeGold = read_flags(var)
//case WORLDA: World_Models_On = bool:str_to_num(var)
default: Precache_modela(wepid)
}
if(wepid < 31)
if(AllowedWeps[wepid] == true)
{
if((price = str_to_float(var)) > 1.0)
{
PriceBalance[wepid] = price/(costa*1.0)
}
register_concmd(cmds[wepid], "Golden_Handle")
formatex(ItemName, 29, "\yGolden %s \r[%d cost]",cmds[wepid][10], floatround(costa*PriceBalance[wepid]))
menu_additem(gold_menu, ItemName, cmds[wepid], 0, callbacka)
formatex(ItemName, 29, "\yGolden %s \r[%d cost]",cmds[wepid][10], floatround(costa*PriceBalance[wepid]/2.0))
menu_additem(gold_vip_menu, ItemName, cmds[wepid], 0, callbacka)
}
}
fclose(iFileP)
beama = precache_model("sprites/dot.spr")
}
Precache_modela(CSW)
{
if(CSW > 30) return
if(file_exists(Modelite[CSW][0]))
{
precache_model(Modelite[CSW][0])
AllowedWeps[CSW] = true
} else AllowedWeps[CSW] = false
}
public ShowMenu(id)
{
menu_display(id, (get_user_flags(id)&VIPflaga)?gold_vip_menu:gold_menu)
return
}
public GoldMe(id) give_gold(id, id, get_user_weapon(id))
public fw_Spawned(id)
if(GoldBackup[id])
set_task(1.0, "GiveGoldSpawn", id+SPAWNGOLD, _,_,"a", 3)
public GiveGoldSpawn(id)
if(is_user_alive(id -= SPAWNGOLD))
for(new wepID=CSW_P228;wepID<=CSW_P90;wepID++)
if(gHas_Golden[wepID][id] && wepID != 2)
give_gold(-1, id, wepID)
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damagebits)
{
if(!is_user_connected(attacker)
|| damagebits & (1<<24)) return HAM_IGNORED
if(gHas_Golden[get_user_weapon(attacker)][attacker])
{
SetHamParamFloat(4, damage * 3.0)
GoldBackup[attacker] = false
return HAM_HANDLED
}
return HAM_IGNORED
}
public fw_Killed(id)
{
if(!gHas_Golden[0][id] || GoldBackup[id]) return
for(new wepID=CSW_P228;wepID<=CSW_P90;wepID++)
{
if(wepID == 2) continue
gHas_Golden[wepID][id] = false
}
gHas_Golden[0][id] = false
}
public fwTraceAttack( iVictim, iAttacker, Float:flDamage, Float:flDirection[ 3 ], iTr, iDamageBits )
{
if( !is_user_connected(iAttacker) || iDamageBits & (1<<24)) return;
if(!gHas_Golden[get_user_weapon(iAttacker)][iAttacker]) return;
new Float:flEndOrigin[ 3 ];
get_tr2( iTr, TR_vecEndPos, flEndOrigin );
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(TE_BEAMENTPOINT);
write_short(iAttacker | 0x1000); // start entity
engfunc(EngFunc_WriteCoord, flEndOrigin[0]); // endposition.x
engfunc(EngFunc_WriteCoord, flEndOrigin[1]); // endposition.y
engfunc(EngFunc_WriteCoord, flEndOrigin[2]); // endposition.z
write_short(beama); // sprite index
write_byte(1); // starting frame
write_byte(5); // frame rate in 0.1's
write_byte(1); // life in 0.1's
write_byte(10); // line wdith in 0.1's
write_byte(0); // noise amplitude in 0.01's
write_byte(255); // red
write_byte(215); // green
write_byte(0); // blue
write_byte(200); // brightness
write_byte(1); // scroll speed in 0.1's
message_end();
}
public ModelChange(ent)
{
static id, wid
id = get_pdata_cbase(ent, 41, 4), wid = get_pdata_int(ent, 43, 4)
wepid2[id] = ent
if(!is_user_alive(id)) return
if(gHas_Golden[wid][id])
switch(wid)
{
case CSW_AK47: set_pev( id, pev_viewmodel2, V_AK)
case CSW_AUG: set_pev( id, pev_viewmodel2, V_AUG)
case CSW_AWP: set_pev( id, pev_viewmodel2, V_AWP)
case CSW_DEAGLE: set_pev( id, pev_viewmodel2, V_DEAGLE)
case CSW_ELITE: set_pev( id, pev_viewmodel2, V_ELITE)
case CSW_FAMAS: set_pev( id, pev_viewmodel2, V_FAMAS)
case CSW_FIVESEVEN: set_pev( id, pev_viewmodel2, V_FIVESEVEN)
case CSW_G3SG1: set_pev( id, pev_viewmodel2, V_G3SG1)
case CSW_GALIL: set_pev( id, pev_viewmodel2, V_GALIL)
case CSW_GLOCK18: set_pev( id, pev_viewmodel2, V_GLOCK)
case CSW_KNIFE: set_pev( id, pev_viewmodel2, V_KNIFE)
case CSW_M249: set_pev( id, pev_viewmodel2, V_M249)
case CSW_M3: set_pev( id, pev_viewmodel2, V_M3)
case CSW_M4A1: set_pev( id, pev_viewmodel2, V_M4)
case CSW_MAC10: set_pev( id, pev_viewmodel2, V_MAC10)
case CSW_MP5NAVY: set_pev( id, pev_viewmodel2, V_MP5)
case CSW_P228: set_pev( id, pev_viewmodel2, V_P228)
case CSW_P90: set_pev( id, pev_viewmodel2, V_P90)
case CSW_SCOUT: set_pev( id, pev_viewmodel2, V_SCOUT)
case CSW_SG550: set_pev( id, pev_viewmodel2, V_SG550)
case CSW_SG552: set_pev( id, pev_viewmodel2, V_SG552)
case CSW_TMP: set_pev( id, pev_viewmodel2, V_TMP)
case CSW_UMP45: set_pev( id, pev_viewmodel2, V_UMP45)
case CSW_USP: set_pev( id, pev_viewmodel2, V_USP)
case CSW_XM1014: set_pev( id, pev_viewmodel2, V_XM1014)
}
//set_pev( id, pev_viewmodel2, Modelite[wid][0])// SURVARA CRUSHI OT TWA(sqkash nqkoi modeli prosto gi nqma)
}
public GoldCallBack(id, menu, item)
{
new acc, info[50], call;
menu_item_getinfo(menu, item, acc, info, sizeof info-1, {0}, 0, call)
new flags = get_user_flags(id)
if(~flags & FreeGold)
{
new cost2, wepid, money = cs_get_user_money(id)
wepid = Get_WepID(info, 10)
if(flags & VIPflaga) cost2 = floatround( (costa * 0.5) * PriceBalance[wepid]) // 50% lower price
else cost2 = floatround( costa * PriceBalance[wepid] )
if((money < cost2) && !gHas_Golden[wepid][id]) return ITEM_DISABLED
}
return ITEM_ENABLED
}
public Golden_Handle(id, the_cmd[50])
{
if(!is_user_connected(id) && id != 0) return PLUGIN_CONTINUE
new chara, szName[50], tid = -1, wepid
if(!equal(the_cmd, "amx_golden",10))
{
read_argv(0, the_cmd, 49)
if(equal(the_cmd, "say"))
{
chara = 7
read_argv(1, the_cmd, 49)
if(the_cmd[0] != '/') return PLUGIN_CONTINUE
strtolower(the_cmd)
if(!equal(the_cmd[1], "golden",6)) return PLUGIN_CONTINUE
strtok(the_cmd, the_cmd, 49, szName, 49, ' ')
wepid = Get_WepID(the_cmd, chara)
if(szName[0] != EOS)
{
new pl[32], num
get_players_by_name(id, pl, szName, num)
if(szName[0] == '@')
{
if(!num) return PLUGIN_HANDLED
for(new i; i<num; i++)
{
tid= pl[i]
give_gold(-1, tid, wepid)
}
new weaponName[16]
get_weaponname(wepid, weaponName, 15)
ColorChat(0, Color:GREY, "^x04[^x01Goldens^x04] ^x03%s^x01 gave all ^x03%s^x01 a golden ^x04%s", user_name[id], TeamNames[(szName[1]-97)%6], weaponName[7])
return PLUGIN_HANDLED
} else switch(num)
{
case 1: tid = pl[0]
default:
{
if(id > 0) MakePlayersMenu(id, pl, num, wepid, szName)
return PLUGIN_HANDLED
}
}
}
} else if(equal(the_cmd, "amx_golden",10))
{
chara = 10
wepid = Get_WepID(the_cmd, chara)
if(read_argc() == 2)
{
read_argv(1, szName, 49)
if(szName[0] == '#')
{
if((tid = find_player("k", str_to_num(szName[1]))))
if(!is_user_connected(tid) && id != 0)
client_print(id, print_console, "[Goldens] No player found! Please a valid userid.")
} else {
new pl[32], num
get_players_by_name(id, pl, szName, num)
if(szName[0] == '@')
{
if(num == -1) return PLUGIN_CONTINUE
for(new i; i<num; i++)
{
tid= pl[i]
give_gold(-1, tid, wepid)
}
new weaponName[50]
if(wepid == 2)
copy(weaponName, charsmax(weaponName), "^x04all goldens")
else {
get_weaponname(wepid, weaponName, 15)
format(weaponName, charsmax(weaponName), "^x01a golden ^x04%s", weaponName[7])
}
ColorChat(0, Color:GREY, "^x04[^x01Goldens^x04] ^x03%s^x01 gave all ^x03%s %s", user_name[id], TeamNames[(szName[1]-97)%6], weaponName)
return PLUGIN_HANDLED
} else switch(num)
{
case 1: tid = pl[0]
default:
{
if(id == 0) return PLUGIN_HANDLED
client_print(id, print_console, "^n[Goldens] Please look at the menu just displayed.^n")
MakePlayersMenu(id, pl, num, wepid, szName)
return PLUGIN_HANDLED
}
}
}
}
} else return PLUGIN_CONTINUE
} else chara = 10
give_gold(id, tid, wepid == 0?Get_WepID(the_cmd, chara):wepid)
the_cmd = ""
return PLUGIN_HANDLED
}
get_players_by_name(id, pl[32], idto[50], &num)
{
switch(idto[0]) {
case '@':if(~get_user_flags(id) & FreeGold)
num = -1, ColorChat(id, RED, "^x04[Golden^x04] You need the flag for free gold!")
else for(new i=1; i<33; i++)
{
if(is_user_connected(i))
{
if(get_user_team(i) != (idto[1]-97)%6 && idto[1] != 'a') continue
pl[num] = i, num++
}
}
default : for(new i=1; i<33; i++)if(is_user_connected(i)) if(containi(user_name[i], idto) !=-1)
pl[num] = i, num++
} }
give_gold(id, tid, wepID)
{
if(!AllowedWeps[wepID]) return
if(tid < 1 ) if(is_user_alive(id)) tid = id
else if(is_user_alive(pev(id, pev_iuser2))) tid = pev(id, pev_iuser2)
else return
if(wepID == 2)
{
give_allgold(id, tid)
return
}
new weaponName[30]
get_weaponname(wepID, weaponName, charsmax(weaponName))
if(id > -1)
{
new cost2, flags = get_user_flags(id), money
if(gHas_Golden[wepID][tid])
{
if(id != 0) ColorChat(id, RED, "^x04[^x01Goldens^x04] ^x03Sorry, ^x04%s ^x03already have this ^x01Golden^x03!", tid==id?"you":(is_user_bot(tid)?"this bot":"this player"))
//set_user_rendering(tid, kRenderFxGlowShell, 255, 215, 0, kRenderNormal, 25)
if(pev_valid(wepid2[tid]) && get_user_weapon(tid) == wepID)
{
ModelChange(wepid2[tid])
}
cs_set_user_bpammo(tid, wepID, gMaxBPAmmo[wepID])
//if(wepID == 29) return
give_item(tid, weaponName)
return
}
if(~flags & FreeGold)
{
money = cs_get_user_money(id)
if(flags & VIPflaga) cost2 = floatround( (costa * 0.5) * PriceBalance[wepID]) // 50% lower price
else cost2 = floatround( costa * PriceBalance[wepID] )
if(money < cost2){
ColorChat(id, RED, "^x04[^x01Goldens^x04] ^x03Sorry, not enough ^x04money^x01(cost ^x04%d^x03$^x01)",cost2)
return
}
cs_set_user_money(id, money-cost2)
}
new bool:DontBackup, wepID23
for(wepID23=CSW_P228; wepID23<=CSW_P90; wepID23++) if(gHas_Golden[wepID23][id]) DontBackup = true;
if(!DontBackup) GoldBackup[tid] = true
if(texta[tid][0] != '^0') add(texta[tid], 99, ", ");
add(texta[tid], 99, weaponName[7])
if(tid == id)
{
engclient_cmd(tid, weaponName)
if(!task_exists(tid+SPAMA)) set_task(2.0, "Less_Spam", tid+SPAMA)
else change_task(tid+SPAMA, 2.0)
}
else if(!task_exists(tid+SPAMA2))
{
new param[1];param[0] = id
set_task(0.1, "Less_Spam2", tid+SPAMA2, param, 1)
}
}
gHas_Golden[0][tid] = true, gHas_Golden[wepID][tid] = true
give_item(tid, weaponName)
if(wepID != CSW_KNIFE)
{
cs_set_user_bpammo(tid, wepID, gMaxBPAmmo[wepID])
if(pev_valid(wepid2[tid]) && get_user_weapon(tid) == wepID)
{
ModelChange(wepid2[tid]);
if(pev_valid(wepid2[tid]))
cs_set_weapon_ammo(wepid2[tid], gMaxClipAmmo[wepID])
}
}
//set_user_rendering(tid, kRenderFxGlowShell, 255, 215, 0, kRenderNormal, 25)
return
}
give_allgold(id ,tid)
{
for(new wepID=CSW_P228;wepID<=CSW_P90;wepID++)
{
if(wepID == 2) continue
give_gold(id, tid, wepID)
}
}
public Less_Spam(id)
{
if(get_pcvar_num(pcvar_no_spam) > 0) return
id -= SPAMA
#if !defined COLOR
ColorChat(0, Color:GREY, "^x04[^x01Goldens^x04] ^x03%s^x01 got a Golden ^x04%s", user_name[id], texta[id])
#else
new name22[191]
ColorChat(0, Color:colornames_name(id, name22), "^x04[^x01Goldens^x04] %s^x01 got a Golden ^x04%s", name22, texta[id])
#endif
texta[id] = ""
}
public Less_Spam2(param[1], id)
{
if(get_pcvar_num(pcvar_no_spam) > 0) return
id -= SPAMA2
#if !defined COLOR
ColorChat(0, Color:GREY, "^x04[^x01Goldens^x04] ^x03%s^x01 gave ^x03%s^x01 a golden ^x04%s", user_name[param[0]], user_name[id], texta[id])
#else
new name22[191], GiverName[191]
colornames_name(id, name22)
ColorChat(0, Color:colornames_name(param[0], GiverName), "^x04[^x01Goldens^x04] %s^x01 gave %s^x01 a golden %s", GiverName, name22, texta[id])
#endif
texta[id] = ""
}
MakePlayersMenu(id, pl[32], num, wepid, szName[50])
{
new MenuTitle[50]
formatex(MenuTitle, 49, "Select a Player: ^"%s^"", szName)
new info[2], tid, menuto = menu_create(MenuTitle, "RazdaiMalkoGold")
num_to_str(wepid, info, 2)
if(num == 0) get_players(pl, num)
for(new i; i< num; i++)
{
tid = pl[i]
menu_additem(menuto, user_name[tid], info)
}
menu_display(id, menuto)
}
public RazdaiMalkoGold(id, menu, item)
{
new info[2], name[32]
menu_item_getinfo(menu, item, info[0], info, 2, name, 31, item)
give_gold(id, get_user_index(name), str_to_num(info))
menu_destroy(menu)
}
public GoldMenuto(id, menu, item)
{
if(item == MENU_EXIT) return
new acc, info[50], call
menu_item_getinfo(menu, item, acc, info, sizeof info-1, {0}, 0, call)
Golden_Handle(id, info)
}
Get_WepID(the_cmd[50], chara)
{
switch(the_cmd[chara])
{
case 'a': switch(the_cmd[chara+1])
{
case 'l':return 2
case 'k':return CSW_AK47
case 'u':return CSW_AUG
case 'w':return CSW_AWP
}
case 'd':return CSW_DEAGLE
case 'e':return CSW_ELITE
case 'f':if(the_cmd[chara+1] == 'a') return CSW_FAMAS;else return CSW_FIVESEVEN
case 'g': switch(the_cmd[chara+1])
{
case '3':return CSW_G3SG1
case 'a':return CSW_GALIL
case 'l':return CSW_GLOCK18
}
case 'k': return CSW_KNIFE
case 'm':switch(the_cmd[chara+1])
{
case '2':return CSW_M249
case '3':return CSW_M3
case '4':return CSW_M4A1
case 'a':return CSW_MAC10
case 'p':return CSW_MP5NAVY
}
case 'p':if(the_cmd[chara+1] == '2') return CSW_P228;else return CSW_P90
case 's':switch(the_cmd[chara+4])
{
case 't':return CSW_SCOUT
case '0':return CSW_SG550
case '2':return CSW_SG552
case 's':return COSTA2
case 'p':return VIPA
case 'e':return FREEGOLDA
case 'a':return WORLDA
}
case 't': return CSW_TMP
case 'u':if(the_cmd[chara+1] == 'm') return CSW_UMP45;else return CSW_USP
case 'x':return CSW_XM1014
}
return 0
}
public client_connect(id) get_user_name(id, user_name[id], 49)
public client_infochanged(id)
{
if(!is_user_connected(id)) return
new g_old_name[50], g_name[50];
get_user_name(id, g_old_name, charsmax(g_old_name))
get_user_info(id, "name", g_name, charsmax(g_name))
if(!equal(g_name, g_old_name)) copy(user_name[id], 49, g_name)
}