Se alguem tiver um rank de ammopacks q carrega por NICK e nao por STEAM
Isto é uma pré-visualização de um tema em Hitskin.com
Instalar o tema • Voltar para a ficha do tema
Isto é uma pré-visualização de um tema em Hitskin.com
Instalar o tema • Voltar para a ficha do tema
Nenhum usuário |
....
Os nossos membros postaram um total de 38140 mensagens em 6680 assuntos
Temos 2796 usuários registrados
O último membro registrado é zmplugins - Henrique
/*
*Credits*
(70%) hleV - http://forums.alliedmods.net/showthread.php?p=1092490
(20%) PomanoB - http://forums.alliedmods.net/showthread.php?t=109286
(5%) silver- (request) - https://forums.alliedmods.net/showthread.php?t=99794
(5%) me - add 1 or 2 lines.
*Description*
This simple plugin will display rank and top15 of players ammo packs in the server.
Create APrank.ini file in datadir (default datadir: addons/amxmodx/data/)
*Say command*
/ammorank - show your current ammopacks rank in the server.
/ammotop15 - show a MOTD of top15 players that has highest ammopacks in the server.
*/
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <zombieplague>
#define SAVE_RANKS_AFTER_SORT
#define SORT_INTERVAL 30.0
enum RankData
{
Data_SteamID[32],
Data_Name[32],
Data_AmmoPacks
}
new g_File[64];
new Array:g_SteamID;
new Trie:g_Name, Trie:g_AmmoPacks;
new g_Top15[2048];
new bool:g_Sort = true;
new g_Data[33][RankData], bool:g_Authorized[33];
new cvar_dmg_reward, cvar_inf_reward, cvar_surv_ignore, cvar_nem_ignore;
new g_damagedealt[33]
public plugin_init()
{
register_plugin("[ZP] Addon: AmmoPacks rank", "1.0", "")
register_clcmd("say /ammorank", "SayAmmoPacksRank");
register_clcmd("say /ammotop15", "SayAmmoPacksTop15");
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage", 1)
register_event("HLTV", "round_restarted", "a", "1=0", "2=0");
register_event("DeathMsg", "fw_DeathMsg", "a");
cvar_dmg_reward = get_cvar_pointer("zp_human_damage_reward");
cvar_inf_reward = get_cvar_pointer("zp_zombie_infect_reward");
cvar_surv_ignore = get_cvar_pointer("zp_surv_ignore_rewards");
cvar_nem_ignore = get_cvar_pointer("zp_nem_ignore_rewards");
get_datadir(g_File, 63);
add(g_File, 63, "/APrank.ini");
g_SteamID = ArrayCreate(32, 1);
g_Name = TrieCreate();
g_AmmoPacks = TrieCreate();
LoadRanks();
ArraySort(g_SteamID, "SortRanks");
WriteTop15();
set_task(SORT_INTERVAL, "SortTask", _, _, _, "b");
}
public plugin_end()
{
ArraySort(g_SteamID, "SortRanks");
SaveRanks();
ArrayDestroy(g_SteamID);
}
public client_putinserver(Client)
{
get_user_authid(Client, g_Data[Client][Data_SteamID], 31);
if (!str_to_num(g_Data[Client][Data_SteamID][10]))
return;
get_user_name(Client, g_Data[Client][Data_Name], 31);
if (!TrieKeyExists(g_Name, g_Data[Client][Data_SteamID]))
AddRank(Client);
else
LoadData(Client);
UpdateRank(Client, true);
g_Authorized[Client] = true;
g_damagedealt[Client] = 0;
}
public client_disconnect(Client)
g_Authorized[Client] = false;
public client_infochanged(Client)
{
if (!g_Authorized[Client])
return;
static Name[32];
get_user_info(Client, "name", Name, 31);
if (equal(Name, g_Data[Client][Data_Name]))
return;
copy(g_Data[Client][Data_Name], 31, Name);
UpdateRank(Client, true);
}
public SayAmmoPacksRank(Client)
{
new Position = GetPosition(Client);
if (!g_Authorized[Client] || !Position)
{
client_print(Client, print_chat, "* You are not ranked yet.");
return;
}
client_print(Client, print_chat, "* Your rank is %d of %d with %d ammo packs.", Position, ArraySize(g_SteamID), g_Data[Client][Data_AmmoPacks]);
}
public SayAmmoPacksTop15(Client)
show_motd(Client, g_Top15, "Top 15");
public fw_DeathMsg()
{
new Killer = read_data(1)
new Victim = read_data(2)
static ammokill;
ammokill = get_pcvar_num(cvar_inf_reward)
if (g_Authorized[Killer] && Killer != Victim && Killer != 0 && ((!zp_get_user_zombie(Victim) && zp_get_user_nemesis(Killer) && !get_pcvar_num(cvar_nem_ignore)) || (zp_get_user_zombie(Killer))))
{
g_Data[Killer][Data_AmmoPacks] += ammokill;
g_Sort = true;
UpdateRank(Killer, false);
}
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
if(zp_get_user_zombie(victim) || (zp_get_user_zombie(victim) && zp_get_user_survivor(attacker) && !get_pcvar_num(cvar_surv_ignore)))
{
g_damagedealt[attacker] += floatround(damage)
}
}
public round_restarted()
{
for(new iPlayers=1; iPlayers<33; iPlayers++)
{
static ammodamage;
ammodamage = get_pcvar_num(cvar_dmg_reward);
new g_FinalAP[33];
g_FinalAP[iPlayers] = g_damagedealt[iPlayers] / ammodamage;
g_Data[iPlayers][Data_AmmoPacks] += g_FinalAP[iPlayers];
g_Sort = true;
UpdateRank(iPlayers, false);
g_damagedealt[iPlayers] = 0
}
}
public zp_user_infected_post(Victim, Killer)
{
static ammoinfect;
ammoinfect = get_pcvar_num(cvar_inf_reward)
if (g_Authorized[Killer] && Killer != Victim)
{
g_Data[Killer][Data_AmmoPacks] += ammoinfect;
g_Sort = true;
UpdateRank(Killer, false);
}
}
public SortTask()
{
if (!g_Sort)
return;
ArraySort(g_SteamID, "SortRanks");
WriteTop15();
#if defined SAVE_RANKS_AFTER_SORT
SaveRanks();
#endif
}
public SortRanks(Array:SteamID, Position1, Position2)
{
static SteamID1[32];
ArrayGetString(SteamID, Position1, SteamID1, 31);
static SteamID2[32];
ArrayGetString(SteamID, Position2, SteamID2, 31);
static AmmoPacks1;
TrieGetCell(g_AmmoPacks, SteamID1, AmmoPacks1);
static AmmoPacks2;
TrieGetCell(g_AmmoPacks, SteamID2, AmmoPacks2);
if (AmmoPacks1 < AmmoPacks2)
return 1;
else if (AmmoPacks1 > AmmoPacks2)
return -1;
return 0;
}
LoadRanks()
{
new File = fopen(g_File, "r");
if (!File)
return;
new Data[96], SteamID[32], Name[32], AmmoPacks[16];
while (!feof(File))
{
fgets(File, Data, 96);
if (!strlen(Data))
continue;
parse(Data, SteamID, 31, Name, 31, AmmoPacks, 15);
ArrayPushString(g_SteamID, SteamID);
TrieSetString(g_Name, SteamID, Name);
TrieSetCell(g_AmmoPacks, SteamID, str_to_num(AmmoPacks));
}
fclose(File);
}
SaveRanks()
{
new File = fopen(g_File, "w+");
if (!File)
return;
for (new Position, Size = ArraySize(g_SteamID), SteamID[32], Name[32], AmmoPacks; Position < Size; Position++)
{
ArrayGetString(g_SteamID, Position, SteamID, 31);
TrieGetString(g_Name, SteamID, Name, 31);
TrieGetCell(g_AmmoPacks, SteamID, AmmoPacks);
fprintf(File, "%s ^"%s^" %d^n", SteamID, Name, AmmoPacks);
}
fclose(File);
}
AddRank(Client)
{
g_Data[Client][Data_AmmoPacks] = 0;
ArrayPushString(g_SteamID, g_Data[Client][Data_SteamID]);
TrieSetString(g_Name, g_Data[Client][Data_SteamID], g_Data[Client][Data_Name]);
}
LoadData(Client)
TrieGetCell(g_AmmoPacks, g_Data[Client][Data_SteamID], g_Data[Client][Data_AmmoPacks]);
UpdateRank(Client, bool:Name)
{
if (Name)
TrieSetString(g_Name, g_Data[Client][Data_SteamID], g_Data[Client][Data_Name]);
TrieSetCell(g_AmmoPacks, g_Data[Client][Data_SteamID], g_Data[Client][Data_AmmoPacks]);
}
GetPosition(Client)
{
static Position, Size, SteamID[32];
for (Position = 0, Size = ArraySize(g_SteamID); Position < Size; Position++)
{
ArrayGetString(g_SteamID, Position, SteamID, 31);
if (equal(SteamID, g_Data[Client][Data_SteamID]))
return Position + 1;
}
return 0;
}
WriteTop15()
{
static const Header[] = "<body bgcolor=#121212><font color=#ff4200 size=6><center><u>TOP 15 PLAYERS</u></center><br><font color=#FFB000 size=3 face=Verdana><pre>%4s %22.21s %9s^n^n";
static const Buffer[] = "<font color=#bbbbbb>%4d %22.21s %9d^n";
static Length, Position, Size, SteamID[32], Name[32], AmmoPacks;
Length = formatex(g_Top15[Length], 2047 - Length, Header, "Rank", "Nick", "AmmoPacks");
for (Position = 0, Size = min(ArraySize(g_SteamID), 15); Position < Size; Position++)
{
ArrayGetString(g_SteamID, Position, SteamID, 31);
TrieGetString(g_Name, SteamID, Name, 31);
TrieGetCell(g_AmmoPacks, SteamID, AmmoPacks);
Length += formatex(g_Top15[Length], 2047 - Length, Buffer, Position + 1, Name, AmmoPacks);
}
}
tá, estou gripado quando estiver disposto eu vejo oque da pra fazer.devil-square escreveu:Ta ai :
- Código:
/*
*Credits*
(70%) hleV - http://forums.alliedmods.net/showthread.php?p=1092490
(20%) PomanoB - http://forums.alliedmods.net/showthread.php?t=109286
(5%) silver- (request) - https://forums.alliedmods.net/showthread.php?t=99794
(5%) me - add 1 or 2 lines.
*Description*
This simple plugin will display rank and top15 of players ammo packs in the server.
Create APrank.ini file in datadir (default datadir: addons/amxmodx/data/)
*Say command*
/ammorank - show your current ammopacks rank in the server.
/ammotop15 - show a MOTD of top15 players that has highest ammopacks in the server.
*/
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <zombieplague>
#define SAVE_RANKS_AFTER_SORT
#define SORT_INTERVAL 30.0
enum RankData
{
Data_SteamID[32],
Data_Name[32],
Data_AmmoPacks
}
new g_File[64];
new Array:g_SteamID;
new Trie:g_Name, Trie:g_AmmoPacks;
new g_Top15[2048];
new bool:g_Sort = true;
new g_Data[33][RankData], bool:g_Authorized[33];
new cvar_dmg_reward, cvar_inf_reward, cvar_surv_ignore, cvar_nem_ignore;
new g_damagedealt[33]
public plugin_init()
{
register_plugin("[ZP] Addon: AmmoPacks rank", "1.0", "")
register_clcmd("say /ammorank", "SayAmmoPacksRank");
register_clcmd("say /ammotop15", "SayAmmoPacksTop15");
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage", 1)
register_event("HLTV", "round_restarted", "a", "1=0", "2=0");
register_event("DeathMsg", "fw_DeathMsg", "a");
cvar_dmg_reward = get_cvar_pointer("zp_human_damage_reward");
cvar_inf_reward = get_cvar_pointer("zp_zombie_infect_reward");
cvar_surv_ignore = get_cvar_pointer("zp_surv_ignore_rewards");
cvar_nem_ignore = get_cvar_pointer("zp_nem_ignore_rewards");
get_datadir(g_File, 63);
add(g_File, 63, "/APrank.ini");
g_SteamID = ArrayCreate(32, 1);
g_Name = TrieCreate();
g_AmmoPacks = TrieCreate();
LoadRanks();
ArraySort(g_SteamID, "SortRanks");
WriteTop15();
set_task(SORT_INTERVAL, "SortTask", _, _, _, "b");
}
public plugin_end()
{
ArraySort(g_SteamID, "SortRanks");
SaveRanks();
ArrayDestroy(g_SteamID);
}
public client_putinserver(Client)
{
get_user_authid(Client, g_Data[Client][Data_SteamID], 31);
if (!str_to_num(g_Data[Client][Data_SteamID][10]))
return;
get_user_name(Client, g_Data[Client][Data_Name], 31);
if (!TrieKeyExists(g_Name, g_Data[Client][Data_SteamID]))
AddRank(Client);
else
LoadData(Client);
UpdateRank(Client, true);
g_Authorized[Client] = true;
g_damagedealt[Client] = 0;
}
public client_disconnect(Client)
g_Authorized[Client] = false;
public client_infochanged(Client)
{
if (!g_Authorized[Client])
return;
static Name[32];
get_user_info(Client, "name", Name, 31);
if (equal(Name, g_Data[Client][Data_Name]))
return;
copy(g_Data[Client][Data_Name], 31, Name);
UpdateRank(Client, true);
}
public SayAmmoPacksRank(Client)
{
new Position = GetPosition(Client);
if (!g_Authorized[Client] || !Position)
{
client_print(Client, print_chat, "* You are not ranked yet.");
return;
}
client_print(Client, print_chat, "* Your rank is %d of %d with %d ammo packs.", Position, ArraySize(g_SteamID), g_Data[Client][Data_AmmoPacks]);
}
public SayAmmoPacksTop15(Client)
show_motd(Client, g_Top15, "Top 15");
public fw_DeathMsg()
{
new Killer = read_data(1)
new Victim = read_data(2)
static ammokill;
ammokill = get_pcvar_num(cvar_inf_reward)
if (g_Authorized[Killer] && Killer != Victim && Killer != 0 && ((!zp_get_user_zombie(Victim) && zp_get_user_nemesis(Killer) && !get_pcvar_num(cvar_nem_ignore)) || (zp_get_user_zombie(Killer))))
{
g_Data[Killer][Data_AmmoPacks] += ammokill;
g_Sort = true;
UpdateRank(Killer, false);
}
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
if(zp_get_user_zombie(victim) || (zp_get_user_zombie(victim) && zp_get_user_survivor(attacker) && !get_pcvar_num(cvar_surv_ignore)))
{
g_damagedealt[attacker] += floatround(damage)
}
}
public round_restarted()
{
for(new iPlayers=1; iPlayers<33; iPlayers++)
{
static ammodamage;
ammodamage = get_pcvar_num(cvar_dmg_reward);
new g_FinalAP[33];
g_FinalAP[iPlayers] = g_damagedealt[iPlayers] / ammodamage;
g_Data[iPlayers][Data_AmmoPacks] += g_FinalAP[iPlayers];
g_Sort = true;
UpdateRank(iPlayers, false);
g_damagedealt[iPlayers] = 0
}
}
public zp_user_infected_post(Victim, Killer)
{
static ammoinfect;
ammoinfect = get_pcvar_num(cvar_inf_reward)
if (g_Authorized[Killer] && Killer != Victim)
{
g_Data[Killer][Data_AmmoPacks] += ammoinfect;
g_Sort = true;
UpdateRank(Killer, false);
}
}
public SortTask()
{
if (!g_Sort)
return;
ArraySort(g_SteamID, "SortRanks");
WriteTop15();
#if defined SAVE_RANKS_AFTER_SORT
SaveRanks();
#endif
}
public SortRanks(Array:SteamID, Position1, Position2)
{
static SteamID1[32];
ArrayGetString(SteamID, Position1, SteamID1, 31);
static SteamID2[32];
ArrayGetString(SteamID, Position2, SteamID2, 31);
static AmmoPacks1;
TrieGetCell(g_AmmoPacks, SteamID1, AmmoPacks1);
static AmmoPacks2;
TrieGetCell(g_AmmoPacks, SteamID2, AmmoPacks2);
if (AmmoPacks1 < AmmoPacks2)
return 1;
else if (AmmoPacks1 > AmmoPacks2)
return -1;
return 0;
}
LoadRanks()
{
new File = fopen(g_File, "r");
if (!File)
return;
new Data[96], SteamID[32], Name[32], AmmoPacks[16];
while (!feof(File))
{
fgets(File, Data, 96);
if (!strlen(Data))
continue;
parse(Data, SteamID, 31, Name, 31, AmmoPacks, 15);
ArrayPushString(g_SteamID, SteamID);
TrieSetString(g_Name, SteamID, Name);
TrieSetCell(g_AmmoPacks, SteamID, str_to_num(AmmoPacks));
}
fclose(File);
}
SaveRanks()
{
new File = fopen(g_File, "w+");
if (!File)
return;
for (new Position, Size = ArraySize(g_SteamID), SteamID[32], Name[32], AmmoPacks; Position < Size; Position++)
{
ArrayGetString(g_SteamID, Position, SteamID, 31);
TrieGetString(g_Name, SteamID, Name, 31);
TrieGetCell(g_AmmoPacks, SteamID, AmmoPacks);
fprintf(File, "%s ^"%s^" %d^n", SteamID, Name, AmmoPacks);
}
fclose(File);
}
AddRank(Client)
{
g_Data[Client][Data_AmmoPacks] = 0;
ArrayPushString(g_SteamID, g_Data[Client][Data_SteamID]);
TrieSetString(g_Name, g_Data[Client][Data_SteamID], g_Data[Client][Data_Name]);
}
LoadData(Client)
TrieGetCell(g_AmmoPacks, g_Data[Client][Data_SteamID], g_Data[Client][Data_AmmoPacks]);
UpdateRank(Client, bool:Name)
{
if (Name)
TrieSetString(g_Name, g_Data[Client][Data_SteamID], g_Data[Client][Data_Name]);
TrieSetCell(g_AmmoPacks, g_Data[Client][Data_SteamID], g_Data[Client][Data_AmmoPacks]);
}
GetPosition(Client)
{
static Position, Size, SteamID[32];
for (Position = 0, Size = ArraySize(g_SteamID); Position < Size; Position++)
{
ArrayGetString(g_SteamID, Position, SteamID, 31);
if (equal(SteamID, g_Data[Client][Data_SteamID]))
return Position + 1;
}
return 0;
}
WriteTop15()
{
static const Header[] = "<body bgcolor=#121212><font color=#ff4200 size=6><center><u>TOP 15 PLAYERS</u></center><br><font color=#FFB000 size=3 face=Verdana><pre>%4s %22.21s %9s^n^n";
static const Buffer[] = "<font color=#bbbbbb>%4d %22.21s %9d^n";
static Length, Position, Size, SteamID[32], Name[32], AmmoPacks;
Length = formatex(g_Top15[Length], 2047 - Length, Header, "Rank", "Nick", "AmmoPacks");
for (Position = 0, Size = min(ArraySize(g_SteamID), 15); Position < Size; Position++)
{
ArrayGetString(g_SteamID, Position, SteamID, 31);
TrieGetString(g_Name, SteamID, Name, 31);
TrieGetCell(g_AmmoPacks, SteamID, AmmoPacks);
Length += formatex(g_Top15[Length], 2047 - Length, Buffer, Position + 1, Name, AmmoPacks);
}
}