Raised This Month: $ Target: $400
 0% 

[Help] Xp Rank


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
2reason2kill
Senior Member
Join Date: Feb 2011
Old 05-09-2011 , 16:33   [Help] Xp Rank
Reply With Quote #1

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_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""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
(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;

how do i do like 1 for cts and 1 for ts and they can see there rank in the left lower conor? plz help +K

Credits 2 nnajko for making the tut!

Last edited by 2reason2kill; 05-09-2011 at 16:36. Reason: forgot 2 give credits 2 nnajko
2reason2kill is offline
lis_16
Senior Member
Join Date: Feb 2008
Old 05-09-2011 , 16:45   Re: [Help] Xp Rank
Reply With Quote #2

Plugin show current hp:

PHP Code:
#include <amxmodx>
#include <fakemeta>


#define PLUGIN "Zycie"
#define VERSION "1.0"
#define AUTHOR "Mochi"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
}
public 
client_PreThink(id) {
    if(
is_user_alive(id) && is_user_connected(id)) {    
       new 
zycie pev(id,pev_health)
            
set_hudmessage(25521200.020.1806.012.0)
            
show_hudmessage(id"Zycie: %d",zycie)
        }
    } 
lis_16 is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 05-09-2011 , 21:39   Re: [Help] Xp Rank
Reply With Quote #3

How does that have ANYTHING to do with what he wanted?

Second, pev_health returns a float, not an integer....

Third, read the first post before posting.

Fourth, prethink is not the correct place to show a hud message.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-09-2011 , 23:43   Re: [Help] Xp Rank
Reply With Quote #4

2reason2kill
Post in Suggestions / Requests if you don't want to learn how to script.
__________________

SonicSonedit is offline
2reason2kill
Senior Member
Join Date: Feb 2011
Old 05-10-2011 , 06:41   Re: [Help] Xp Rank
Reply With Quote #5

i want to learn script thats why i posted this
2reason2kill is offline
lis_16
Senior Member
Join Date: Feb 2008
Old 05-10-2011 , 08:10   Re: [Help] Xp Rank
Reply With Quote #7

But it works fine, he just need to set good variables not a health.
lis_16 is offline
2reason2kill
Senior Member
Join Date: Feb 2011
Old 05-10-2011 , 09:04   Re: [Help] Xp Rank
Reply With Quote #8

thnx i gonna take a look at it ^.^

but i want it 2 show in the left coner like
i want 1 "rank" for cts and a diffrent 1 For ts how do i do it is it get_user_team or what plz help.
+k

Last edited by 2reason2kill; 05-10-2011 at 09:42.
2reason2kill is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-10-2011 , 14:40   Re: [Help] Xp Rank
Reply With Quote #9

2reason2kill
Quote:
but i want it 2 show in the left coner like
Never do things like this.
1) It's ugly client hack, and client hacking is forbidden.
2) Some people (including me) really like to have target player name centered, not some lvl/rank/exp info.
3) It looks ugly.

Quote:
i want 1 "rank" for cts and a diffrent 1 For ts how do i do it is it get_user_team or what plz help.
Show a hudmessage (see links I gave you) in a corner with info you want to show.

Quote:
+k
If you didn't notice yet, my karma is disabled long ago. I just help people to learn scripting. But I'm not goint to script for you.
__________________

SonicSonedit is offline
2reason2kill
Senior Member
Join Date: Feb 2011
Old 05-10-2011 , 15:48   Re: [Help] Xp Rank
Reply With Quote #10

Quote:
Originally Posted by SonicSonedit View Post
2reason2kill
1) It's ugly client hack, and client hacking is forbidden.
can u explain what client hack is ?? i am srry....
2reason2kill 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 04:28.


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