Raised This Month: $32 Target: $400
 8% 

Natives


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Groven
AlliedModders Donor
Join Date: Apr 2011
Location: Sweden
Old 04-28-2011 , 18:53   Natives
Reply With Quote #1

Hello,

I tried to change my plugin with cashmod natives instead of Xp Mod.

When you get 25 kills you will be leveld up and get 50 Cash.

But when i leveled up my cash resetted to 0.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <nvault>

#define IsPlayer(%1)  (1 <= %1 <= g_players) 
#define TOTALLEVELS 12

//Cash Natives
native cm_get_user_cash(id);

native cm_set_user_cash(idcm);

//Cash Natives end

new const RANK[TOTALLEVELS] = 
{
 
25,
 
50
 
100,
 
200,
 
300,
 
500,
 
750,
 
1000,
 
1250,
 
1500,
 
1750,
 
2000,
}

new const 
CM[TOTALLEVELS] = 
{
 
50
 
100,
 
150,
 
200,
 
300,
 
1000,
 
1200,
 
1300,
 
1400,
 
1500,
 
2500,
 
20000
}

new const 
RANKNAMES[TOTALLEVELS][] =
{
 
"New player",
 
"Beginner",
 
"Learning",
 
"Knifer",
 
"Rambo with knife",
 
"Butcher",
 
"Matrix",
 
"Diiiirrrge",
 
"Freak with Knife",
 
"Chuck Norris",
 
"Kill Bill",
 
"Respected Player"
}

new 
gCM[33], gLevel[33];
new 
points_killpoints_hs;
new 
g_vaultg_players;

public 
plugin_init()
{
    
register_plugin("HideNSeek Rank""1.2""ETTAN");
 
    
register_event("DeathMsg""eDeath""a");
 
    
points_kill register_cvar("hnsrank_kill""1");
    
points_hs register_cvar("hnsrank_hs","1");
    
g_vault nvault_open("HNSRANK");
    
g_players get_maxplayers();
    
    
register_clcmd("say /rank""ShowHud");
    
register_clcmd("say_team /rank""ShowHud");
}

public 
plugin_end()
{
    
nvault_close(g_vault);
}

public 
eDeath() 
{
    new 
killer read_data(1);
    new 
victim read_data(2);
    new 
gpoints_kill get_pcvar_num(points_kill);
    new 
gpoints_hs get_pcvar_num(points_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))
                    {
                        
gCM[killer] += gpoints_kill
                        
Print(killer"You gained %d Points!"gpoints_kill );
                    }
                    else if(
read_data(3))
                    {
                        
gCM[killer] += (gpoints_kill gpoints_hs);
                        Print(
killer"You gained %d Points!^x01 (Headshot)", (gpoints_hs gpoints_kill ) );
                    }
    
                    
CheckLevel(killer);
                    
SaveData(killer);
                }
            }
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
CheckLevel(id)
{
    if( 
gCM[id] >= RANK[gLevel[id]] )
    {
        
gLevel[id]++;
        new 
szName[33];
        
get_user_name(idszNamecharsmax(szName));
        Print(
0"Congratulations to^3 %s^1! Person is now [Lvl:^3 %i^1/%i] with title^3 %s^1!"szNamegLevel[id], TOTALLEVELSRANKNAMES[gLevel[id]-1]);
        Print(
0"^3%s^1 was rewarded^3 %i^1 Money for leveling up!"szNameCM[gLevel[id]]);
        
cm_set_user_cashidCM[gLevel[id]-1] );
    }
}

public 
ShowHud(id)
{
    new 
iLevelName[100];
    if( 
gLevel[id] > )
    {
        
formatex(iLevelNamecharsmax(iLevelName), "%s"RANKNAMES[gLevel[id]]);
    }
    else 
    {
        
formatex(iLevelNamecharsmax(iLevelName), "Unranked");
    }
    
    new 
szName[33];
    
get_user_name(idszNamecharsmax(szName));
    Print(
0"^3%s^1 has:^3 %d/%d Points^1! Title:^3 %s^1!"szNamegCM[id], RANK[gLevel[id]], iLevelName);
}

public 
client_connect(id)
{
    
LoadData(id);
}

public 
client_disconnect(id)
{
    
SaveData(id);
    
gCM[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-EG"AuthID);
    
format(vaultdata,255,"%i#%i#",gCM[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-EG",AuthID);
    
format(vaultdata,255,"%i#%i#",gCM[id],gLevel[id]);
    
nvault_get(g_vault,vaultkey,vaultdata,255);

    
replace_all(vaultdata255"#"" ");

    new 
playercm[32], playerlevel[32];

    
parse(vaultdataplayercm31playerlevel31);

    
gCM[id] = str_to_num(playercm);
    
gLevel[id] = str_to_num(playerlevel);

    return 
PLUGIN_CONTINUE;

}

Print(
iPlayer, const sMsg[], any:...)
{
    static 
iiPlayer iPlayer get_Player();
    if ( !
) return;
    
    new 
sMessage[256];
    new 
len formatex(sMessagesizeof(sMessage) - 1"^x04[Cool-Gaming] HideNSeek Rank:^x03 ");
    
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(iiPlayerteam_Names[0]);
        
    
message_begin(iPlayer MSG_ONE_UNRELIABLE MSG_BROADCASTmsgid_SayText_iPlayer);
    
write_byte(i);
    
write_string(sMessage);
    
message_end();
        
    
team_Info(iiPlayerteam_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 
iPlayer 1iPlayer <= get_maxplayers(); iPlayer++ )
    {
        return 
iPlayer;
    }
    
    return 
0;

Groven 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:06.


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