I Dont Want A menu, I want To If a player is T He Get Class X and if Ct He Get class Y
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <nvault>
/* Check if player is a player:D */
#define IsPlayer(%1) (1 <= %1 <= g_players)
/* Times a player can write /xp ( To avoid spam! )*/
#define PrintTimes 3
/* Chat Prefix */
new const ChatPrefix[] = "HNS Ranks";
/* Change this to add more levels. 6 = 6 Levels. */
#define TOTALLEVELS 6
/* Edit here to add more levels. */
new const RANK[TOTALLEVELS] =
{
50,
250,
500,
1000,
1500,
2000
}
/* Name if player is unranked */
new const Level0[] = "Loser";
/* Edit here to add more levels. */
new const RANKNAMES[TOTALLEVELS][] =
{
"Noob",
"Beginner",
"Learning",
"Better",
"Soon pro",
"Pro"
}
new gXP[33], gLevel[33], iPrintXP[33];
new XP_Kill, XP_Hs, g_vault, g_players;
public plugin_init()
{
register_plugin("XP-Ranking", "1.0", "nnajko");
/* This is when a player die or kill someone */
register_event("DeathMsg", "eDeath", "a");
/* When a player spawn FwdPlayerSpawn will be called */
RegisterHam(Ham_Spawn, "player", "FwdPlayerSpawn", 1);
/* pCvars */
XP_Kill = register_cvar("XP_per_kill", "20");
XP_Hs = register_cvar("XP_hs_bonus","10");
/* Get Maxplayers */
g_players = get_maxplayers();
/* Chat Commands */
register_clcmd("say /xp", "HideChat");
register_clcmd("say_team /xp", "HideChat");
/* Save File Name */
g_vault = nvault_open("HNSRANK");
}
public plugin_end()
{
nvault_close(g_vault);
}
public HideChat(id)
{
if( IsPlayer(id) && is_user_alive(id) )
{
ShowHud(id);
}
return PLUGIN_HANDLED;
}
public eDeath()
{
new killer = read_data(1);
new victim = read_data(2);
new gPrintMSG[100];
new gXPKill = get_pcvar_num(XP_Kill);
new gXPHs = get_pcvar_num(XP_Hs);
if( IsPlayer(killer) && is_user_connected(killer) )
{
if( victim != killer )
{
if( cs_get_user_team(victim) != cs_get_user_team(killer) )
{
if( is_user_alive(killer) )
{
if( !read_data(3) )
{
gXP[killer] += gXPKill
formatex(gPrintMSG, charsmax(gPrintMSG), "You gained %d XP!", gXPKill);
}
else if( read_data(3) )
{
gXP[killer] += (gXPKill + gXPHs);
formatex(gPrintMSG, charsmax(gPrintMSG), "You gained %d XP!^x01 (Headshot)", (gXPHs + gXPKill));
}
Print(killer, gPrintMSG);
CheckLevel(killer);
SaveData(killer);
}
}
}
}
return PLUGIN_HANDLED;
}
public FwdPlayerSpawn(id)
{
iPrintXP[id] = 0;
}
public CheckLevel(id)
{
if(gXP[id] >= RANK[gLevel[id]])
{
gLevel[id]++;
Print(id, "^x01Congratulations!^x03 You are now a:^x01 %s^x03!", RANKNAMES[gLevel[id]]);
}
}
public ShowHud(id)
{
new iLevelName[100];
if( gLevel[id] > 0 )
{
formatex(iLevelName, charsmax(iLevelName), "%s", RANKNAMES[gLevel[id]]);
}
else
{
formatex(iLevelName, charsmax(iLevelName), "%s", Level0);
}
if( iPrintXP[id] < PrintTimes )
{
new szName[33];
get_user_name(id, szName, charsmax(szName));
Print(0, "^x01%s^x03 has:^x01 %d/%d XP^x03! Title:^x01 %s^x03!", szName, gXP[id], RANK[gLevel[id]], iLevelName);
iPrintXP[id]++;
}
else if( iPrintXP[id] >= PrintTimes )
{
Print(id, "You have printed your level maximum times this round!^x01 (%d)", PrintTimes);
}
}
public client_connect(id)
{
LoadData(id);
}
public client_disconnect(id)
{
SaveData(id);
gXP[id] = 0;
gLevel[id] = 0;
}
public SaveData(id)
{
new AuthID[35];
get_user_authid(id,AuthID,34);
new vaultkey[64],vaultdata[256];
format(vaultkey,63,"%s-Mod", AuthID);
format(vaultdata,255,"%i#%i#",gXP[id],gLevel[id]);
nvault_set(g_vault,vaultkey,vaultdata);
return PLUGIN_CONTINUE;
}
LoadData(id)
{
new AuthID[35];
get_user_authid(id,AuthID,34);
new vaultkey[64],vaultdata[256];
format(vaultkey,63,"%s-Mod",AuthID);
format(vaultdata,255,"%i#%i#",gXP[id],gLevel[id]);
nvault_get(g_vault,vaultkey,vaultdata,255);
replace_all(vaultdata, 255, "#", " ");
new playerxp[32], playerlevel[32];
parse(vaultdata, playerxp, 31, playerlevel, 31);
gXP[id] = str_to_num(playerxp);
gLevel[id] = str_to_num(playerlevel);
return PLUGIN_CONTINUE;
}
Print(id, const sMsg[], any:...)
{
static i; i = id ? id : get_Player();
if ( !i ) return;
new sMessage[256];
new len = formatex(sMessage, sizeof(sMessage) - 1, "^x04[%s]^x03 ", ChatPrefix);
vformat(sMessage[len], sizeof(sMessage) - 1 - len, sMsg, 3);
sMessage[192] = '^0';
static msgid_SayText;
if ( !msgid_SayText ) msgid_SayText = get_user_msgid("SayText");
new const team_Names[][] =
{
"",
"TERRORIST",
"CT",
"SPECTATOR"
};
new sTeam = get_user_team(i);
team_Info(i, id, team_Names[0]);
message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgid_SayText, _, id);
write_byte(i);
write_string(sMessage);
message_end();
team_Info(i, id, team_Names[sTeam]);
}
team_Info(receiver, sender, sTeam[])
{
static msgid_TeamInfo;
if ( !msgid_TeamInfo ) msgid_TeamInfo = get_user_msgid("TeamInfo");
message_begin(sender ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgid_TeamInfo, _, sender);
write_byte(receiver);
write_string(sTeam);
message_end();
}
get_Player()
{
for ( new id = 1; id <= get_maxplayers(); id++ )
{
return id;
}
return 0;
}