He defined "RANKS" twice. Here is the fixed version :
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <nvault>
#include <colorchat>
new const VERSION[] = "2.0"
new const AUTHOR[] = "Bob"
new const PLUGIN[] = "Military Rank System"
new const RANKS[][]=
{
"[0/18] Private",
"[1/18] Private 1st Class",
"[2/18] Corporal",
"[3/18] Sergeant",
"[4/18] Staff Sergeant",
"[5/18] Sergeant 1st Class",
"[6/18] Master Sergeant",
"[7/18] Sergeant Major",
"[8/18] 2nd Lieutenant",
"[9/18] 1st Lieutenant",
"[10/18] Captain",
"[11/18] Major",
"[12/18] Lieutenant Colonel",
"[13/18] Colonel",
"[14/18] Brigadier General",
"[15/18] Major General",
"[16/18] Lieutenant General",
"[17/18] General",
"[18/18] General of the Army",
"Just to prevent Bug."
}
new const KILLS[] =
{
0,
25,
50,
100,
250,
400,
525,
650,
800,
1000,
1250,
1600,
2000,
2500,
3100,
3700,
4100,
4500,
5000,
99999
}
#define HUD_INTERVAL 1.0
new cvar_kills, cvar_hskills
new cached_kills, cached_hskills
new g_vault, g_status_sync
new iKills[33], iRANKS[33]
new iKilled[33][33]
new name[33][32], iSteamID[33][32]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("mr_on", "1")
register_clcmd("say /rank", "show_stats")
register_clcmd("say_team /rank", "show_stats")
cvar_kills = register_cvar("mr_rank_kills", "1")
cvar_hskills = register_cvar("mr_rank_hskills", "1")
register_event("StatusValue", "showStatus", "be", "1=2", "2!0")
register_event("StatusValue", "hideStatus", "be", "1=1", "2=0")
register_event("DeathMsg", "event_DeathMsg", "a", "1>0")
set_task(HUD_INTERVAL, "ShowHud", 0)
g_vault = nvault_open("vault_rank")
g_status_sync = CreateHudSyncObj();
if(g_vault == INVALID_HANDLE)
{
set_fail_state("Error")
}
}
public plugin_end()
{
new iPlayers[32], iNum
get_players(iPlayers, iNum)
new iPlayer
for(new i = 0; i < iNum; i++)
{
iPlayer = iPlayers[i]
SaveData(iPlayer)
}
nvault_close(g_vault)
}
public client_connect(id)
{
LoadData(id)
}
public client_putinserver(id)
{
get_user_authid(id, iSteamID[id], 31)
set_task(HUD_INTERVAL, "ShowHud", id)
LoadData(id)
}
public client_disconnect(id)
{
SaveData(id)
}
public showStatus(id)
{
if(!is_user_bot(id) && is_user_connected(id))
{
new name[32]
new pid = read_data(2)
get_user_name(pid, name, 31)
new color1 = 0
new color2 = 0
new team1 = get_user_team(id), team2 = get_user_team(pid)
if (team2 == 1)
{
color1 = 200
}
else
{
color2 = 200
}
if(team1 == team2)
{
set_hudmessage(color1, 50, color2, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01, -1)
ShowSyncHudMsg(id, g_status_sync, "Name: %s^nHealth: %d^nRank: %s | Kills: %d", name, get_user_health(pid), iRANKS[iRANKS[pid]], iKills[pid])
}
else
{
set_hudmessage(color1, 50, color2, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01, -1)
ShowSyncHudMsg(id, g_status_sync, "Name: %s^nHealth: %d^nRank: %s | Kills: %d", name, get_user_health(pid), iRANKS[iRANKS[pid]], iKills[pid])
}
}
}
public hideStatus(id)
{
ClearSyncHud(id, g_status_sync)
}
public ShowHud(id)
{
if(!is_user_connected(id))
return 0
if(is_user_alive(id))
{
client_print(id, print_center, "Rank: %s | Kills: %d / %d", iRANKS[iRANKS[id]], iKills[id], KILLS[iRANKS[id] + 1])
}
set_task(HUD_INTERVAL,"ShowHud", id)
return PLUGIN_CONTINUE
}
public show_stats(id)
{
if(is_user_connected(id))
{
get_user_name(id, name[id], 31)
ColorChat(0, GREEN, "^x04[T.D] ^x03%s's ^x01Rank: ^x04%s ^x01 | with: ^x04%d ^x01kill(s) | Next rank: ^x04%d ^x01kill(s)!", name[id], iRANKS[iRANKS[id]], iKills[id], KILLS[iRANKS[id] + 1] - iKills[id])
}
}
public event_DeathMsg()
{
static iKiller; iKiller = read_data(1)
static iVictim; iVictim = read_data(2)
static iIsHeadshot; iIsHeadshot = read_data(3)
cached_kills = get_pcvar_num(cvar_kills)
cached_hskills = get_pcvar_num(cvar_hskills)
if(iVictim == iKiller)
return PLUGIN_CONTINUE
if(iIsHeadshot)
{
iKilled[iKiller][iVictim] = true
iKills[iKiller] += cached_hskills
ColorChat(iKiller, GREEN, "^x04[T.D] ^x01You got^x04 1 ^x01Kill Point for killing an enemy!")
}
else
{
iKilled[iKiller][iVictim] = true
iKills[iKiller] += cached_kills
ColorChat(iKiller, GREEN, "^x04[T.D] ^x01You got^x04 1 ^x01Kill Point for killing an enemy!")
}
while((iKills[iKiller] >= KILLS[iRANKS[iKiller] + 1] && iRANKS[iKiller] < 18))
{
iRANKS[iKiller] += 1
new szName[32]
get_user_name(iKiller, szName, charsmax(szName))
ColorChat(0, GREEN, "^x04[T.D] %s's ^x01Rank is now: ^x04%s^x01!", szName, iRANKS[iRANKS[iKiller]])
}
SaveData(iKiller)
set_task(HUD_INTERVAL,"ShowHud", iKiller)
return PLUGIN_CONTINUE
}
public SaveData(id)
{
new authid[32]
get_user_authid(id, authid, 31)
new vaultkey[64], vaultdata[64]
format(vaultkey, 63, "MILITARYv2-%s-rank", authid)
format(vaultdata, 63, "%d", RANKS[id])
set_vaultdata(vaultkey, vaultdata)
format(vaultkey, 63, "MILITARYv2-%s-kills", authid)
format(vaultdata, 63, "%d", iKills[id])
set_vaultdata(vaultkey, vaultdata)
}
public LoadData(id)
{
new authid[32]
get_user_authid(id, authid, 31)
new vaultkey[64], vaultdata[64]
format(vaultkey, 63, "MILITARYv2-%s-rank", authid)
get_vaultdata(vaultkey, vaultdata, 63)
iRANKS[id] = str_to_num(vaultdata)
format(vaultkey, 63, "MILITARYv2-%s-kills", authid)
get_vaultdata(vaultkey, vaultdata, 63)
iKills[id] = str_to_num(vaultdata)
}