Raised This Month: $ Target: $400
 0% 

REQ:Level in front of name(edit old plugin)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
morrow
Member
Join Date: Dec 2008
Old 10-20-2013 , 04:03   REQ:Level in front of name(edit old plugin)
Reply With Quote #1

Hey , i have one old plugin, can somebody edit this a little ?
I want to insert level, in front of name in chat...when player name is: kulo , and he have level : Major , when he write something, people see like this: green[Major] kulo : text blablabla





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[] = "STON3D RANK";

/* Change this to add more levels. 6 = 6 Levels. */
#define TOTALLEVELS 21

/* Edit here to add more levels. */
new const RANK[TOTALLEVELS] = 
{
    
50,
    
100
    
180
    
280
    
390,
    
520,
    
670,
    
810,
    
1000,
    
1300,
    
1620,
    
2000,
    
2600,
    
3000,
    
3600,
    
4200,
    
5000,
    
5900,
    
6900,
    
10000,
    
20000
}

/* Name if player is unranked */
new const Level0[] = "Learning";

/* Edit here to add more levels. */
new const RANKNAMES[TOTALLEVELS][] =
{
    
"Private",
    
"Efreitor",
    
"Junior Sergeant",
    
"Sergeant",
    
"Senior Sergeant",
    
"Master-Sergeant",
    
"Warrant Officer",
    
"Senior Warrant Officer",
    
"Junior Lieutenant",
    
"Lieutenant",
    
"Senior Lieutenant",
    
"Captain",
    
"Major",
    
"Lieutenant Colonel",
    
"Colonel",
    
"Major General",
    
"Lieutenant General",
    
"Colonel General",
    
"General of the Army",
    
"Marshal of the Army",
    
"GENERALISSIMUS"
}


new 
gXP[33], gLevel[33], iPrintXP[33];
new 
XP_KillXP_Hsg_vaultg_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""1");
    
XP_Hs register_cvar("XP_hs_bonus","2");
    
    
/* 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("STON3D RANK");
}

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
(gPrintMSGcharsmax(gPrintMSG), "You gained %d XP!"gXPKill);
                    }
                    else if( 
read_data(3) )
                    {
                        
gXP[killer] += (gXPKill gXPHs);
                        
formatex(gPrintMSGcharsmax(gPrintMSG), "You gained %d XP!^x01 (Headshot)", (gXPHs gXPKill));
                    }
    
                    Print(
killergPrintMSG);
                    
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] > )
    {
        
formatex(iLevelNamecharsmax(iLevelName), "%s"RANKNAMES[gLevel[id]]);
    }
    else 
    {
        
formatex(iLevelNamecharsmax(iLevelName), "%s"Level0);
    }
    
    if( 
iPrintXP[id] < PrintTimes )
    {
        new 
szName[33];
        
get_user_name(idszNamecharsmax(szName));
        Print(
0"^x01%s^x03 has:^x01 %d/%d XP^x03! Title:^x01 %s^x03!"szNamegXP[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(vaultdata255"#"" ");

    new 
playerxp[32], playerlevel[32];

    
parse(vaultdataplayerxp31playerlevel31);

    
gXP[id] = str_to_num(playerxp);
    
gLevel[id] = str_to_num(playerlevel);

    return 
PLUGIN_CONTINUE;

}

Print(
id, const sMsg[], any:...)
{
    static 
iid id get_Player();
    if ( !
) return;
    
    new 
sMessage[256];
    new 
len formatex(sMessagesizeof(sMessage) - 1"^x04[%s]^x03 "ChatPrefix);
    
vformat(sMessage[len], sizeof(sMessage) - lensMsg3);
    
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(iidteam_Names[0]);
        
    
message_begin(id MSG_ONE_UNRELIABLE MSG_BROADCASTmsgid_SayText_id);
    
write_byte(i);
    
write_string(sMessage);
    
message_end();
        
    
team_Info(iidteam_Names[sTeam]);
}

team_Info(receiversendersTeam[])
{
    static 
msgid_TeamInfo;
    if ( !
msgid_TeamInfo msgid_TeamInfo get_user_msgid("TeamInfo");
    
    
message_begin(sender MSG_ONE_UNRELIABLE MSG_BROADCASTmsgid_TeamInfo_sender);
    
write_byte(receiver);
    
write_string(sTeam);
    
message_end();
}

get_Player()
{
    for ( new 
id 1id <= get_maxplayers(); id++ )
    {
        return 
id;
    }
    
    return 
0;
}  
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1061\\ f0\\ fs16 \n\\ par }
*/ 
morrow is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode