Русское сообщество по скриптингу

[Req] For re-write Rank Plugin

Scripting help for english speaking users. While not very active, you still have a chance to get help here.
Правила форума
We cannot maintain english version version of our forum rules, but shortly (it's simple) - Don't be a dick. If you really want to know our rules you should check appropriate thread.

[Req] For re-write Rank Plugin

Сообщение VenomIvanof » 11 июн 2016, 20:59

here is the base code

Код: Выделить всё
#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < engine >
#include < colorchat >
#include < hamsandwich >
#include < fun >
#include < nvault >

#define MAXRANKS 32

#define PLUGIN "BP Admin prefix with ranks"
#define VERSION "1.0"
#define AUTHOR "V e n { } m"

//ПРОМЕНЛИВИ
new PlayerRank[33], message[192]
new 
sayTextteamInfomaxPlayersg_AdminListen,  g_AdminListenFlag,g_MsgHudgVault
new strName[191], strText[191], alive[11], temp_cvar[2], g_name[32]
new 
gPlayerPoints[33], give[33],iTarget[33]

new const 
g_szTag[][] = {
       
"",
       
"MC Owner",
       
"Server Admin",
       
"Beauty One",
       
"V.I.P",
       
"Super V.I.P",
       
"Dpmator",
       
"Test Admin",
       
"SMS Admin",
       
"BOOSTER"
}

new const 
rankNames[MAXRANKS][] =
{
"•^3Maina User^4•"
"•^3Noob^4•"
"•^3Bot^4•"
"•^3BEginner^4•"
"•^3Learning^4•"
"•^3Medium^4•"
"•^3Pro^4•"
"•^3Ultra Killer^4•"
"•^3Mega Killer^4•"
"•^3Super Killer^4•"
"•^3Unique Killer^4•"
"•^3Ultimate Killer^4•"
"•^3Silver Player^4•"
"•^3Bronze Player^4•"
"•^3Gold Player^4•"
"•^3Terminator^4•",
"•^3Unstippable^4•"
"•^3Night Killer^4•"
"•^3Assassin^4•"
"•^3Ninja^4•",
"•^3Black Ninja^4•"
"•^3White Ninja^4•",
"•^3Sensei^4•"
"•^3Freak^4•"
"•^3Demonic^4•"
"•^3Super Duper^4•"
"•^3Untouchable^4•"
"•^3I got ballzz^4•"
"•^3Fantastic^4•"
"•^3Bombastic^4•",
"•^3One and Only^4•"
"•GOD•"
};

new const 
rankXP[MAXRANKS] =
{
    
025501001502003505007008501100140018002400300035004300520058006500730080009600105001200013800150001720020000215002400026000
};
public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
g_AdminListen register_cvar("amx_listen""1")
    
g_AdminListenFlag register_cvar("amx_listen_flag""c")

    
register_clcmd("say""hook_say")
    
register_clcmd("say_team""hook_teamsay")
    
register_clcmd("say /myrank""cmdJumpRank")
    
register_clcmd("say_team /myrank""cmdJumpRank")
    
register_clcmd("say /xp""cmdCheckLevel")
    
register_clcmd("say_team /checkrank""cmdCheckLevel")
    
register_clcmd("say /givexp""cmdRankMenu"ADMIN_RCON)
    
register_clcmd("say_team /givexp""cmdRankMenu"ADMIN_RCON)

    
register_concmd("Points_Amount""cmdTyped"ADMIN_RCON);

    
sayText get_user_msgid("SayText")
    
teamInfo get_user_msgid("TeamInfo")
    
maxPlayers get_maxplayers()
    
g_MsgHud CreateHudSyncObj()
    
    
register_message(sayText"avoid_duplicated")
    
register_event("DeathMsg""Hook_Deathmessage""a");
    
RegisterHam(Ham_Spawn"player""player_spawn"1);
    
    
set_task(1.0"taskHud"0__"b")
    
    
gVault nvault_open"PlayerRanks" );
}

public 
player_spawn(id)
{
    if(!
is_user_alive(id) ) return;
    new 
bonus = (PlayerRankid ] > 30) ? 30 + (PlayerRankid ] - 30) * PlayerRankid ]; 
    
set_user_healthidget_user_healthid ) + bonus );
    switch( 
PlayerRankid ] )
    {
        
        case 
1set_user_health(idget_user_healthid ) + );
        case 
2set_user_healthidget_user_healthid ) + );
        case 
3set_user_healthidget_user_healthid ) + );
        case 
4set_user_healthidget_user_healthid ) + );
        case 
5set_user_healthidget_user_healthid ) + );
        case 
6set_user_healthidget_user_healthid ) + );
        case 
7set_user_healthidget_user_healthid ) + );
        case 
8set_user_healthidget_user_healthid ) + );
        case 
9set_user_healthidget_user_healthid ) + );
        case 
10set_user_healthidget_user_healthid ) + 10 );
        case 
11set_user_healthidget_user_healthid ) + 11 );
        case 
12set_user_healthidget_user_healthid ) + 12 );
        case 
13set_user_healthidget_user_healthid ) + 13 );
        case 
14set_user_healthidget_user_healthid ) + 14 );
        case 
15set_user_healthidget_user_healthid ) + 15 );
        case 
16set_user_healthidget_user_healthid ) + 16 );
        case 
17set_user_healthidget_user_healthid ) + 17 );
        case 
18set_user_healthidget_user_healthid ) + 18 );
        case 
19set_user_healthidget_user_healthid ) + 19 );
        case 
20set_user_healthidget_user_healthid ) + 20 );
        case 
21set_user_healthidget_user_healthid ) + 21 );
        case 
22set_user_healthidget_user_healthid ) + 22 );
        case 
23set_user_healthidget_user_healthid ) + 23 );
        case 
24set_user_healthidget_user_healthid ) + 24 );
        case 
25set_user_healthidget_user_healthid ) + 25 );
        case 
26set_user_healthidget_user_healthid ) + 26 );
        case 
27set_user_healthidget_user_healthid ) + 27 );
        case 
28set_user_healthidget_user_healthid ) + 28 );
        case 
29set_user_healthidget_user_healthid ) + 29 );
        case 
30set_user_healthidget_user_healthid ) + 30 );
        case 
31set_user_healthidget_user_healthid ) + 35 );
        case 
32set_user_healthidget_user_healthid ) + 40 );
    }
}

public 
cmdCheckLevel(id)
{
    new 
iMenu menu_create("\rMaina City \d- \wChoose Player\r:""checklevel_menu_handler")
    
    new 
iPlayers[32], iNumiTarget;
    new 
UserName[34], szTempID[10];
    
get_players(iPlayersiNum);
    for(new 
iiNumi++)
    {
        
iTarget iPlayers[i];
        if(!
is_user_connected(iTarget))
            continue;
        
get_user_name(iTargetUserNamesizeof UserName 1);
        
num_to_str(iTargetszTempIDcharsmax(szTempID));
        
menu_additem(iMenuUserNameszTempID);
    }
    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL);
    
menu_display(idiMenu0);
}

public 
checklevel_menu_handler(idiMenuItem)
{
    if(
Item == MENU_EXIT)
    {
        
menu_destroy(iMenu);
        return 
PLUGIN_HANDLED;
    }
    new 
iData[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(iMenuItemaccessiDatacharsmax(iData), iNamecharsmax(iName), callback);
    new 
target str_to_num(iData);
    if(!
is_user_connected(target))
    {
        
ColorChat(idGREEN"^4[^3Maina City^4]^3 The player you chose is not in the server.")
        
menu_destroy(iMenu);
        
cmdCheckLevel(id);
        return 
PLUGIN_HANDLED;
    }
    
menu_destroy(iMenu);
    new 
szText[256], player_name[32];
    
get_user_name(targetplayer_name31);
    if(
MAXRANKS == PlayerRank[target]+1)
        
formatex(szTextcharsmax(szText), "<html><head></head><body><br/>Name: %s<br/>Kills: %d<br/>Level: %d/%d<br/>Rank: %s<br/></body></html>"player_namegPlayerPoints[target], PlayerRank[target]+1MAXRANKSrankNames[PlayerRank[target]]);
    else
        
formatex(szTextcharsmax(szText), "<html><head></head><body><br/>Name: %s<br/>Kills: %d/%d<br/>Level: %d/%d<br/>Rank: %s<br/>Next Rank: %s</body></html>"player_namegPlayerPoints[target], rankXP[PlayerRank[target]+1], PlayerRank[target]+1MAXRANKSrankNames[PlayerRank[target]], rankNames[PlayerRank[target]+1]);
    
show_motd(idszText"Maina City Rank System");
    
cmdCheckLevel(id);
    return 
PLUGIN_HANDLED;
}

public 
taskHud()
{
    new 
iPlayers[32], iNumiTarget;
    
get_players(iPlayersiNum);
    for(new 
iiNumi++)
    {
        
iTarget iPlayers[i];
        if(!
is_user_connected(iTarget))
            continue;
    
        
set_hudmessage(255000.700.9416.012.0)
        if(
MAXRANKS == PlayerRank[iTarget]+1)
            
ShowSyncHudMsg(iTargetg_MsgHud"LvL: %d of %d Rank : %s Kills : %d ^n",PlayerRank[iTarget]+1MAXRANKSrankNames[PlayerRank[iTarget]], gPlayerPoints[iTarget])
        else
            
ShowSyncHudMsg(iTargetg_MsgHud"LvL: %d of %d Rank : %s Kills : %d of %d",PlayerRank[iTarget]+1MAXRANKSrankNames[PlayerRank[iTarget]], gPlayerPoints[iTarget], rankXP[PlayerRank[iTarget]+1])
    }
}

public 
cmdJumpRank(id)
{
    if(
MAXRANKS == PlayerRank[id]+1)
        
ColorChat(idRED"^4[^3Maina City^4]^3  Your level is ^x04#%d ^x01| Rank ^x04%s ^x01| Kills:^x03 %d"PlayerRank[id]+1rankNames[PlayerRank[id]], gPlayerPoints[id])
    else
        
ColorChat(idRED"^4[^3Maina City^4]^3  Your level is ^x04#%d ^x01| Rank ^x04%s ^x01| Kills:^x03 %d^x01 /^x04 %d^x01 to become^x04 %s^x01."PlayerRank[id]+1rankNames[PlayerRank[id]], gPlayerPoints[id], rankXP[PlayerRank[id]+1], rankNames[PlayerRank[id]+1])
}

public 
cmdRankMenu(idlevelcid)
{
    if(!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED;
    new 
iMenu menu_create("Rank Menu""rankmenu_menu_handler")
    
menu_additem(iMenu"Give Points""1");
    
menu_additem(iMenu"Take Points""2");
    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL);
    
menu_display(idiMenu0);
    return 
PLUGIN_CONTINUE;
}

public 
rankmenu_menu_handler(idiMenuItem)
{
    if(
Item == MENU_EXIT)
    {
        
menu_destroy(iMenu);
        return 
PLUGIN_HANDLED;
    }
    new 
iData[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(iMenuItemaccessiDatacharsmax(iData), iNamecharsmax(iName), callback);
    
give[id] = str_to_num(iData);
    
GiveTakeMenu(id);
    return 
PLUGIN_HANDLED;
}

public 
GiveTakeMenu(id)
{
    static 
szText[64]
    
formatex(szText63"%s Points"give[id] == "Give" "Take")
    new 
iMenu menu_create(szText"givetake_menu_handler")

    new 
iPlayers[32], iNumiTarget;
    new 
UserName[34], szTempID[10];
    
get_players(iPlayersiNum);
    for(new 
iiNumi++)
    {
        
iTarget iPlayers[i];
        if(!
is_user_connected(iTarget))
            continue;
        
get_user_name(iTargetUserNamesizeof UserName 1);
        
num_to_str(iTargetszTempIDcharsmax(szTempID));
        
menu_additem(iMenuUserNameszTempID);
    }
    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL);
    
menu_display(idiMenu0);
}

public 
givetake_menu_handler(idiMenuItem)
{
    if(
Item == MENU_EXIT)
    {
        
menu_destroy(iMenu);
        return 
PLUGIN_HANDLED;
    }

    new 
iData[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(iMenuItemaccessiDatacharsmax(iData), iNamecharsmax(iName), callback);
    
iTarget[id] = str_to_num(iData);
    if(!
is_user_connected(iTarget[id]))
    {
        
iTarget[id] = 0
        ColorChat
(idGREEN"^4[^3Maina City^4]^3  The player you chose is not in the server.")
        return 
PLUGIN_HANDLED;
    }
    
menu_destroy(iMenu);
    
client_cmd(id"messagemode Points_Amount");
    return 
PLUGIN_HANDLED;
}

public 
cmdTyped(idlevelcid)
{
    if(!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED;

    if(!
iTarget[id] || give[id] <= 0)
        return 
PLUGIN_HANDLED;
    if(!
is_user_connected(iTarget[id]))
    {
        
ColorChat(idRED"^4[^3Maina City^4]^3  The player you chose is not in the server.")
        return 
PLUGIN_HANDLED;
    }

    new 
iTyped[12];
    
read_argv(1iTypedsizeof iTyped 1);
    new 
g_points str_to_num(iTyped)
    new 
AdminName[32], PlayerName[32];
    
get_user_name(idAdminName31)
    
get_user_name(iTarget[id], PlayerName31)
    if(
give[id] == 1)
    {
        
gPlayerPoints[iTarget[id]] += g_points
        ColorChat
(0GREEN,"^4[^3Maina City^4]^3  %s^x01 gave^x04 %d^x01 rank points to^x03 %s^x01."AdminNameg_pointsPlayerName)
    }
    else
    {
        if(
g_points gPlayerPoints[iTarget[id]])
            
gPlayerPoints[iTarget[id]] = 0
        
else
            
gPlayerPoints[iTarget[id]] -= g_points;
        
ColorChat(0GREEN,"^4[^3Maina City^4]^3  took^x04 %d^x01 rank points from^x03 %s^x01."AdminNameg_pointsPlayerName)
    }
    new 
currentPlayerRank 0;
    while(
currentPlayerRank < (MAXRANKS 1))
    {       
        if(
gPlayerPoints[iTarget[id]] >= rankXP[currentPlayerRank 1])
            ++
currentPlayerRank;     
        else         
            break;
    }
    
PlayerRank[iTarget[id]] = currentPlayerRank;
    
iTarget[id] = 0;
    
GiveTakeMenu(id);
    
Saveid );
    return 
PLUGIN_HANDLED;
}

public 
client_authorizedid )
{
    
Loadid );
}

public 
client_disconnectid )
{
    
Saveid );
}

public 
client_putinserver(id)
{
    new 
currentPlayerRank 0;
    while(
currentPlayerRank < (MAXRANKS 1))
    {       
        if(
gPlayerPoints[id] >= rankXP[currentPlayerRank 1])
            ++
currentPlayerRank;     
        else         
            break;
    }
    
PlayerRank[id] = currentPlayerRank;
}

public 
Loadid )
{
    if( !
is_user_botid ) && !is_user_hltvid ) )
    {
        new 
vaultkey64 ], vaultdata256 ], points33 ], UserName33 ];
        
get_user_nameidUserNamecharsmaxUserName ) );
        
        
formatvaultkeycharsmaxvaultkey ), "%s"UserName );
        
formatvaultdatacharsmaxvaultdata ), "%i#"gPlayerPointsid ] );
        
        
nvault_getgVaultvaultkeyvaultdata255 );
        
replace_allvaultdata255"#"" " );
        
        
parsevaultdatapoints32 );
        
gPlayerPointsid ] = str_to_numpoints );
    }
}

public 
Saveid )
{
    if( !
is_user_botid ) && !is_user_hltvid ) )
    {
        new 
vaultkey64 ], vaultdata256 ], UserName33 ];
        
get_user_nameidUserNamecharsmaxUserName ) );
        
        
formatvaultkeycharsmaxvaultkey ), "%s"UserName );
        
formatvaultdatacharsmaxvaultdata ), "%i#"gPlayerPointsid ] );
        
        
nvault_setgVaultvaultkeyvaultdata );
    }
}

public 
avoid_duplicated(msgIdmsgDestreceiver)
    return 
PLUGIN_HANDLED;

public 
hook_say(id)
{
    
read_args(message191)
    
remove_quotes(message)

    if(
message[0] == '@' || message[0] == '/' || message[0] == '!' || message[0] == '#' || message[0] == '$' || equal(message""))
        return 
PLUGIN_CONTINUE

    get_user_name
(idg_namecharsmax(g_name))

    new 
isAlive    
    
new admin 0iFlags get_user_flags(id)
    if(
iFlags ADMIN_LEVEL_Badmin 1  //owner
    
else if(iFlags ADMIN_LEVEL_Cadmin 2   //administrator
     
else if(iFlags ADMIN_LEVEL_Dadmin 3  //global
    
else if(iFlags&  ADMIN_LEVEL_Gadmin=//otgowornik
    
else if(iFlagsADMIN_LEVEL_Hadmin=5  //ekip banove
    
else if(iFlags ADMIN_BANadmin 6  //admin
    
else if(iFlags ADMIN_LEVEL_Fadmin 7  //test
    
else if(iFlags ADMIN_LEVEL_Eadmin 8  //vip
    
else if(iFlags ADMIN_CHATadmin 9  //sms admin
    

    
if(is_user_alive(id))
    {
        
isAlive 1
        alive 
"^x01"
    
}
    else
    {
        
isAlive 0
        alive 
"^x01*DEAD* "
    
}

    static  
color[10]
    if(
admin)
    {
        
get_user_team(idcolor9)
        
format(strName191"%s^x01[^x04%s^x01] ^x03%s "aliveg_szTag[admin], g_name)
        
format(strText191"^x01%s"message)
    }
    else
    {
        
get_user_name(idg_name32)
        
get_user_team(idcolor9)
        
format(strName191"%s^x04%s ^x03%s"aliverankNames[PlayerRank[id]], g_name)
        
format(strText191"%s"message)
    }

    
format(message191"%s ^x01: %s"strNamestrText)

    
sendMessage(colorisAlive)// Sends the colored message
    
return PLUGIN_CONTINUE;
}

public 
hook_teamsay(id)
{
    
read_args(message191)
    
remove_quotes(message)

    if(
message[0] == '@' || message[0] == '/' || message[0] == '!' || message[0] == '#' || message[0] == '$' || equal(message"")) // Ignores Admin Hud Messages, Admin Slash commands
        
return PLUGIN_CONTINUE

    
new playerTeam get_user_team(id)
    new 
playerTeamName[19]

    switch(
playerTeam// Team names which appear on team-only messages
    
{
        case 
1copy(playerTeamName11"Terrorists")
        case 
2copy(playerTeamName18"Counter-Terrorists")
        default: 
copy(playerTeamName9"Spectator")
    }

    
get_user_name(idg_namecharsmax(g_name))
    new 
isAlive    
    
new admin 0iFlags get_user_flags(id)
    if(
iFlags ADMIN_LEVEL_Badmin 1  //owner
    
else if(iFlags ADMIN_LEVEL_Cadmin 2   //administrator
     
else if(iFlags ADMIN_LEVEL_Dadmin 3  //global
    
else if(iFlags&  ADMIN_LEVEL_Gadmin=//otgowornik
    
else if(iFlagsADMIN_LEVEL_Hadmin=5  //ekip banove
    
else if(iFlags ADMIN_BANadmin 6  //admin
    
else if(iFlags ADMIN_LEVEL_Fadmin 7  //test
    
else if(iFlags ADMIN_LEVEL_Eadmin 8  //vip
    
else if(iFlags ADMIN_CHATadmin 9  //sms admin

    
if(is_user_alive(id))
    {
        
isAlive 1
        alive 
"^x01"
    
}
    else
    {
        
isAlive 0
        alive 
"^x01*DEAD* "
    
}

    static  
color[10]
    if(
admin)
    {
        
get_user_team(idcolor9)
        
format(strName191"%s(%s) ^x01[^x04%s^x01] ^x03%s "aliveplayerTeamName,  g_szTag[admin], g_name)
        
format(strText191"^x01%s"message)
    }
    else
    {
        
get_user_name(idg_name32)
        
get_user_team(idcolor9);
        
format(strName191"%s(%s) ^x04%s ^x03%s"aliveplayerTeamNamerankNames[PlayerRank[id]], g_name)
        
format(strText191"%s"message)
    }

    
format(message191"%s ^x01: %s"strNamestrText)
    
sendTeamMessage(colorisAliveplayerTeam)
    return 
PLUGIN_CONTINUE
}

public 
sendMessage(color[], alive)
{
    new 
teamName[10]
   
    for(new 
player 1player maxPlayersplayer++)
    {
        if(!
is_user_connected(player))
            continue

        
get_pcvar_string(g_AdminListenFlagtemp_cvarcharsmax(temp_cvar))
        if(
alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & read_flags(temp_cvar))
        {
            
get_user_team(playerteamName9)// Stores user's team name to change back after sending the message
            
changeTeamInfo(playercolor)// Changes user's team according to color choosen
            
writeMessage(playermessage)// Writes the message on player's chat
            
changeTeamInfo(playerteamName)// Changes user's team back to original
        
}
    }
}

public 
sendTeamMessage(color[], aliveplayerTeam)
{
    new 
teamName[10]

    for(new 
player 1player maxPlayersplayer++)
    {
        if(!
is_user_connected(player))
            continue

        
get_pcvar_string(g_AdminListenFlagtemp_cvarcharsmax(temp_cvar))
        if(
get_user_team(player) == playerTeam || get_pcvar_num(g_AdminListen) && get_user_flags(player) & read_flags(temp_cvar))
        {
            if(
alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & read_flags(temp_cvar))
            {
                
get_user_team(playerteamName9)// Stores user's team name to change back after sending the message
                
changeTeamInfo(playercolor)// Changes user's team according to color choosen
                
writeMessage(playermessage)// Writes the message on player's chat
                
changeTeamInfo(playerteamName)// Changes user's team back to original
            
}
        }
    }
}


public 
changeTeamInfo(playerteam[])
{
    
message_begin(MSG_ONEteamInfo_player)// Tells to to modify teamInfo(Which is responsable for which time player is)
    
write_byte(player)// Write byte needed
    
write_string(team)// Changes player's team
    
message_end()// Also Needed
}


public 
writeMessage(playermessage[])
{
    
message_begin(MSG_ONEsayText, {000}, player)// Tells to modify sayText(Which is responsable for writing colored messages)
    
write_byte(player)// Write byte needed
    
write_string(message)// Effectively write the message, finally, afterall
    
message_end()// Needed as always
}

public 
Hook_Deathmessage()
{
    new 
killer read_data(1);
    new 
victim read_data(2);

    if(
killer == victim)
        return 
PLUGIN_CONTINUE;
    if(!
killer || killer maxPlayers)
        return 
PLUGIN_CONTINUE;

    
gPlayerPoints[killer]++
    new 
currentPlayerRank 0;
    while(
currentPlayerRank < (MAXRANKS 1))
    {       
        if(
gPlayerPoints[killer] >= rankXP[currentPlayerRank 1])
            ++
currentPlayerRank;     
        else         
            break;
    }
    new 
OldRank PlayerRank[killer]
    
PlayerRank[killer] = currentPlayerRank
    Save
killer );
    if(
OldRank currentPlayerRank)
    {
        new 
g_name[32]
        
get_user_name(killerg_name31)
        
ColorChat(0GREEN"^4[^3Maina City^4]^3 Congratulations! ^x03%s^x01 got a new rank ^x04%s"g_namerankNames[PlayerRank[killer]])
    }
    return 
PLUGIN_CONTINUE;
}
 


i want to add more XP when you make normal kill and headshot and to be only for VIP Users. like > normal kill 2 XP, headshot 3XP

here is the second code that have this feature
Код: Выделить всё
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fvault>
#include <fun>
#include <colorchat>

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

new const g_vault_name[] = "levels_by_name"//kak se kazva faila, koito e kato localno db (zapazva prefixite)

new const g_team_names[CsTeams][] = 

    
"(Spectator) "
    
"(Terrorist) "
    
"(Counter-Terrorist) "
    
"(Spectator) " 
}; 

new 
xp
new cvar_hp
new cvar_hp2

new const Levels[TOTALLEVELS] = 
{
0,
50
100,
200,
300,
500,
750,
1000,
1250,
1500,
1750,
2000,
3500,
4500,
6500,
7500,
11000,
18000
}
new const 
LevelNames[TOTALLEVELS][] =
{
"[NEW]",
"[NewBie]",
"[Advanced]",
"[Learning]",
"[Kniffer]",
"[Killer]",
"[Danger Killer]",
"[Multi Killer]",
"[Super Killer]",
"[Pro Killer]",
"[SuperNova]",
"[Ultimate]",
"[OneAndOnly]",
"[Terminator]",
"[CrushFactor]",
"[GENESIS]",
"[Amazing Shooting]",
"[The Best Killer]"
}

// admin prefixes

new const g_szTag[][] = {
""//NEEEE IZTRIVAI!
"[Owner]",
"[SuperAdmin]",
"[Admin]",
"[Vip]"
}
     
new const 
g_iTagFlag[sizeof(g_szTag)] = {
ADMIN_ALL//NEEEE IZTRIVAI!
ADMIN_RCON,
ADMIN_IMMUNITY,
ADMIN_BAN,
ADMIN_LEVEL_H
}

//end 

new gXP[33], gLevel[33];
new 
points_killpoints_hs;
new  
g_players;

new 
g_msgid_SayText
new 
g_msgsync

public plugin_init()
{
register_plugin("Ranks with XP""Dedihost/val4o0o0""2.3");

register_event("DeathMsg""eDeath""a");

register_clcmd("say /xpmenu","setmenu1");

points_kill register_cvar("dr_rank_kill""1"); //kolko xp da dava pri kill (normalen)
points_hs register_cvar("dr_rank_hs","2"); //kolko xp da dava pri hs
cvar_hp register_cvar("dr_rank_hp_enable","1"); //da dava li hp pri ubiistvo
cvar_hp2 register_cvar("dr_rank_hp_value","25"); //kolko hp da dava pri ubiistvo

fvault_load(g_vault_name);
g_players get_maxplayers();


g_msgid_SayText get_user_msgid("SayText"); 

register_clcmd ("say""hook_say")
register_clcmd ("say_team""hook_teamsay")
register_clcmd ("amx_give_xp""addpts"ADMIN_BAN"<user> <xp>")
g_msgsync CreateHudSyncObj();
}



public 
eDeath(id
{
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(
get_pcvar_num(cvar_hp) == 1) {
     
set_user_health(killer,get_user_health(killer)+get_pcvar_num(cvar_hp2));
     }     
     if(!
read_data(3))
     {
      
gXP[killer] += gpoints_kill
      
//ColorChat(killer, GREY,"*^x4[^3Ranks^4]^3 You Gained %d XP!", gpoints_kill);
     
}
     else if(
read_data(3))
     {
      
gXP[killer] += (gpoints_hs);
     
// ColorChat(killer, GREY,"*^x4[^3Ranks^4]^3 You Gained %d XP!", gpoints_hs);
     
}

     
CheckLevel(killer);
     
SaveData(killer);
    }
   }
  }
}

return 
PLUGIN_HANDLED;
}




public 
CheckLevel(id)
{
if( 
gXP[id] >= Levels[gLevel[id]] )
{
gLevel[id]++;
new 
szName[33];
get_user_name(idszNamecharsmax(szName));
ColorChat(idGREY,"*^x4[^3Ranks^4]^3 Congratulations You are [Level: %i/%i] with Title %s!"gLevel[id], TOTALLEVELSLevelNames[gLevel[id]-1]);
}
}


public 
CmdShowHud (id)
{
if (
is_user_connected(id) && gXP[id]>=0) {
set_hudmessage(random_num(70,255), random_num(70,255), 00.340.0306.0,4.00.10.22)
ShowSyncHudMsg(idg_msgsync"*[Ranks]Level: %i/%i | RankName: %s | XP: %i"gLevel[id], TOTALLEVELS LevelNames[gLevel[id]-1], gXP[id] )
}
}


public 
client_connect(id)
{
LoadData(id);

if(
gXP[id] == && gLevel[id] == 0) {
gLevel[id] = 1;
gXP[id] = 0
}
if( 
gXP[id] > && gLevel[id] == 0){
gLevel[id] = 1;


}


public 
client_disconnect(id)
{
SaveData(id);
gXP[id] = 0;
gLevel[id] = 0;
}

public 
client_putinserver(idset_task(1.0,"CmdShowHud",id,_,_,"b")

public 
SaveData(id)
{
new 
name[32];
get_user_name(id,name,31);
new 
vaultkey[64],vaultdata[256];
format(vaultkey,63,"%s"name);
format(vaultdata,255,"%i#%i#",gXP[id],gLevel[id]);
fvault_set_data(g_vault_name,vaultkey,vaultdata);
return 
PLUGIN_CONTINUE;
}
public 
LoadData(id)
{
new 
name[32];
get_user_name(id,name,31);
new 
vaultkey[64],vaultdata[256];
format(vaultkey,63,"%s",name);
format(vaultdata,255,"%i#%i#",gXP[id],gLevel[id]);
fvault_get_data(g_vault_name,vaultkey,vaultdata,charsmax(vaultdata));
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;
}



public 
addpts(idlevelcid) {
if (!
cmd_access(idlevelcid2))
return 
PLUGIN_HANDLED

new arg11[32],arg22[32],name[32]
read_argv(1arg1131)
read_argv(2arg2231)

new 
arg23 str_to_num(arg22)

new 
player cmd_target(idarg11CMDTARGET_OBEY_IMMUNITY CMDTARGET_ALLOW_SELF)
get_user_name(playername31)

if (!
player || is_user_bot(player))
return 
PLUGIN_HANDLED

new vaultkey[64],vaultdata[256];
format(vaultkey,63,"%s",name);
format(vaultdata,255,"%i",gXP[player]);
fvault_get_data(g_vault_namevaultkey,vaultdata,charsmax(vaultdata))

new 
data[255]; 
formatex(datacharsmax(data), "%i"str_to_num(vaultdata) + arg23); 

fvault_set_data(g_vault_namenamedata)
gXP[player] = str_to_num(data)
client_print(idprint_console"Successfuly added xp to %s",name)
return 
PLUGIN_HANDLED
}


public 
hook_say(client

    new 
said[192]; 
    
read_args(saidsizeof(said) - 1); 
    
remove_quotes(said); 
     
     
    new 
name[32]; 
    
get_user_name(clientnamesizeof(name) - 1); 
     
    new 
alive is_user_alive(client); 
     
    new 
tag[9]; 
    if( 
cs_get_user_team(client) == CS_TEAM_SPECTATOR 
    { 
        
copy(tagsizeof(tag) - 1"*SPEC* "); 
    } 
    else if( !
alive 
    { 
        
copy(tagsizeof(tag) - 1"*DEAD* "); 
    } 
     

    if(
gXP[client]>=0) {
    new 
admin get_tag_index(client)
    new 
message[192]; 
    
formatex(messagesizeof(message) - 1"^x01%s^x04%s^x04 %s^x03 %s^x01 :  %s",  tagg_szTag[admin], LevelNames[gLevel[client]-1], namesaid); 
    if (
contain(message"@") != -1) {
    return 
PLUGIN_HANDLED
    
}

    for( new 
1<= g_playersi++ ) 
    { 
        if(!
is_user_connected(i) || is_user_alive(i) != alive ) continue 
        
message_begin(MSG_ONE_UNRELIABLEg_msgid_SayText_i); 
        
write_byte(client); 
        
write_string(message); 
        
message_end(); 
    } 
     
   
    }
 
    return 
PLUGIN_HANDLED_MAIN


public 
hook_teamsay(client

    new 
said[192]; 
    
read_args(saidsizeof(said) - 1); 
    
remove_quotes(said); 
     
    new 
name[32]; 
    
get_user_name(clientnamesizeof(name) - 1); 
     
    new 
alive is_user_alive(client); 
     
    new 
CsTeams:team cs_get_user_team(client); 
     

    if(
gXP[client]>=0) {
    new 
admin get_tag_index(client)
    new 
message[192]; 
    
formatex(messagesizeof(message) - 1"^x01%s^x04%s^x04 %s^x03 %s^x01 :  %s"g_team_names[team],g_szTag[admin], LevelNames[gLevel[client]-1],namesaid); 
    if (
contain(message"@") != -1) {
    return 
PLUGIN_HANDLED
    
}

    for( new 
1<= g_playersi++ ) 
    { 
        if(!
is_user_connected(i) || is_user_alive(i) != alive || get_user_team(i) != get_user_team(client)) continue 
        
message_begin(MSG_ONE_UNRELIABLEg_msgid_SayText_i); 
        
write_byte(client); 
        
write_string(message); 
        
message_end(); 
    } 
    }
     
     
    return 
PLUGIN_HANDLED_MAIN



public 
setmenu1id ) {
if(
get_user_flags(id) & ADMIN_RCON) {
new 
menu menu_create"\rChoose XP to Given!:""menu_handler2" );
menu_additemmenu"\w15 XP""");
menu_additemmenu"\w20 XP""");
menu_additemmenu"\w100 XP""");
menu_additemmenu"\w500 XP""");
menu_additemmenu"\w1000 XP""");
menu_setpropmenuMPROP_EXITMEXIT_ALL );
menu_displayidmenu);
} else {
ColorChat(id,GREEN,"Nqmash nujnite prava za dostup!");
}
}

public 
menu_handler2idmenuitem )
{
if ( 
item == MENU_EXIT )
{
menu_destroymenu );
return 
PLUGIN_HANDLED;
}

new 
szData[6], szName[64];
new 
item_accessitem_callback;
menu_item_getinfomenuitemitem_accessszData,charsmaxszData ), szName,charsmaxszName ), item_callback );
    
switch( 
item )
{
                case 
0:
                {
                  
xp 15;
                }
                case 
1:
                {
                  
xp 20
                
}
                case 
2:
                {
                  
xp 100
                
}
                case 
3:
                {
                  
xp 500
                
}
                case 
4:
                {
                  
xp 1000
                

}    
    
setmenu(id
menu_destroymenu );
return 
PLUGIN_HANDLED;
}

public 
setmenu(id) {

    new 
menu menu_create"\rXP Set Menu \y[PlayerRanks]:""menu_handler" );
    new 
players[32], pnumtempid;
    new 
szName[32], szUserId[32];
    
get_playersplayerspnum"c" );

    for ( new 
ii<pnumi++ )
    {
        
tempid players[i];
        if(!
is_user_connected(tempid))
        break;

        
get_user_nametempidszNamecharsmaxszName ) );
        
formatexszUserIdcharsmaxszUserId ), "%d"get_user_useridtempid ) );

     
        
menu_additemmenuszNameszUserId);
    }
  

    
menu_displayidmenu);

}


public 
menu_handleridmenuitem )
 {
    if ( 
item == MENU_EXIT )
    {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }

    new 
szData[6], szName[64];
    new 
item_accessitem_callback;
    
menu_item_getinfomenuitemitem_accessszData,charsmaxszData ), szName,charsmaxszName ), item_callback );

    new 
userid str_to_numszData );

    new 
player find_player"k"userid );

    
    if ( 
player && is_user_aliveplayer ) )
    {
        new 
szname[32]
        
get_user_name(player,szname,charsmax(szname))
        new 
vaultkey[64],vaultdata[256];
        
format(vaultkey,63,"%s",szname);
        
format(vaultdata,255,"%i",gXP[player]);
        
fvault_get_data(g_vault_namevaultkey,vaultdata,charsmax(vaultdata))

        new 
data[255]; 
        
formatex(datacharsmax(data), "%i"str_to_num(vaultdata) + xp); 

        
fvault_set_data(g_vault_namesznamedata)
        
gXP[player] =  gXP[player] + xp
        SaveData
(player)
        
ColorChat(id,GREEN,"Vie dobavihte %d XP na igrach %s, toi veche e s %d XP",xp,szname,gXP[player]);
        
    }
    
setmenu(id)
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;
 }
 
//some useful to me :) stocks
get_tag_index(id)
{
        new 
flags get_user_flags(id)
       
        for(new 
1sizeof(g_iTagFlag); i++)
        {
            if(
check_admin_flag(flagsg_iTagFlag[i]))
            {
                return 
i
            
}
        }
       
        return 
0
}

check_admin_flag(flagsflag)
{
        if(
flag == ADMIN_ADMIN)
        {
            return ((
flags & ~ADMIN_USER) > 0)
        }
        else if(
flag == ADMIN_ALL)
        {
            return 
1
        
}
       
        return (
flags flag)


i hope someone will help :)
Аватара пользователя
VenomIvanof
 
Сообщения: 62
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6

Re: [Req] For re-write Rank Plugin

Сообщение Mistrick » 11 июн 2016, 21:19

Код: Выделить всё
public Hook_Deathmessage()
{
    new 
killer read_data(1);
    new 
victim read_data(2);

    if(
killer == victim)
        return 
PLUGIN_CONTINUE;
    if(!
killer || killer maxPlayers)
        return 
PLUGIN_CONTINUE;
    
    new 
bHeadShot read_data(3);
    
    if(
get_user_flags(killer) & VIP_FLAG)
    {
        
gPlayerPoints[killer] += <vip_kill_bonus>;
    }
    
    
gPlayerPoints[killer] += (bHeadShot) ? <headshot_kill_bonus> : <normal_kill_bonus>;
    
    new 
currentPlayerRank 0;
    while(
currentPlayerRank < (MAXRANKS 1))
    {       
        if(
gPlayerPoints[killer] >= rankXP[currentPlayerRank 1])
            ++
currentPlayerRank;     
        else         
            break;
    }
    new 
OldRank PlayerRank[killer]
    
PlayerRank[killer] = currentPlayerRank
    Save
killer );
    if(
OldRank currentPlayerRank)
    {
        new 
g_name[32]
        
get_user_name(killerg_name31)
        
ColorChat(0GREEN"^4[^3Maina City^4]^3 Congratulations! ^x03%s^x01 got a new rank ^x04%s"g_namerankNames[PlayerRank[killer]])
    }
    return 
PLUGIN_CONTINUE;
Аватара пользователя
Mistrick
Скриптер
 
Сообщения: 2618
Зарегистрирован: 04 ноя 2012, 18:15
Благодарил (а): 42 раз.
Поблагодарили: 1113 раз.
Языки программирования: PAWN
С/С++(few above zero)

Re: [Req] For re-write Rank Plugin

Сообщение VenomIvanof » 11 июн 2016, 21:22

Mistrick писал(а):
Код: Выделить всё
public Hook_Deathmessage()
{
    new killer = read_data(1);
    new victim = read_data(2);

    if(killer == victim)
        return PLUGIN_CONTINUE;
    if(!killer || killer > maxPlayers)
        return PLUGIN_CONTINUE;
    
    new bHeadShot 
= read_data(3);
    
    if
(get_user_flags(killer) & VIP_FLAG)
    {
        gPlayerPoints[killer] += <vip_kill_bonus>;
    }
    
    gPlayerPoints
[killer] += (bHeadShot) ? <headshot_kill_bonus> : <normal_kill_bonus>;
    
    new currentPlayerRank 
= 0;
    while(currentPlayerRank < (MAXRANKS - 1))
    {       
        if
(gPlayerPoints[killer] >= rankXP[currentPlayerRank + 1])
            ++currentPlayerRank;     
        else         
            break
;
    }
    new OldRank = PlayerRank[killer]
    PlayerRank[killer] = currentPlayerRank
    Save
( killer );
    if(OldRank < currentPlayerRank)
    {
        new g_name[32]
        get_user_name(killer, g_name, 31)
        ColorChat(0, GREEN, "^4[^3Maina City^4]^3 Congratulations! ^x03%s^x01 got a new rank ^x04%s", g_name, rankNames[PlayerRank[killer]])
    }
    return PLUGIN_CONTINUE;
}



Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2013 ITB CompuPhase, AMX Mod X Team

Error: Undefined symbol "VIP_FLAG" on line 593
Error: Invalid expression, assumed zero on line 595
Error: Undefined symbol "vip_kill_bonus" on line 595
Error: Number of arguments does not match definition on line 595
Error: Too many error messages on one line on line 595

Compilation aborted.
5 Errors.
Could not locate output file C:\Users\Venom\Desktop\RankSystem.amx (compile failed).
Аватара пользователя
VenomIvanof
 
Сообщения: 62
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6

Re: [Req] For re-write Rank Plugin

Сообщение Mistrick » 11 июн 2016, 21:49

VenomIvanof, correct code. I only show you how do this. VIP_FLAG and <...> only example
Аватара пользователя
Mistrick
Скриптер
 
Сообщения: 2618
Зарегистрирован: 04 ноя 2012, 18:15
Благодарил (а): 42 раз.
Поблагодарили: 1113 раз.
Языки программирования: PAWN
С/С++(few above zero)


Вернуться в Scripting

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1