Ranks & Prefixes with flags - AMX Mod X Plugin

Всичко свързано с AMX mod (X), плъгини, проблеми с плъгини, заявки и тн.
Потребителски аватар
DoPe ;]]
Newbie
Мнения: 3
Регистриран: съб юли 09, 2016 9:51 pm
Баланс: Locked

нед юли 10, 2016 4:12 pm

[quote="MuHaBaM"][quote="DoPe ;]]"]Има ли някакъв шанс да махнете ранковете и да ми оставите само префиксите?[/quote]

Кажи имената на префиксите и флаговете и направо ще ти направя нов. :) [/quote]

[Head Admin] - Flag - g
[Help Admin] - Flag - m
[Admin] - Flag - o
[SMS Admin] - Flag - r
[V.I.P] - Flag - s

Потребителски аватар
MuHaBaM
Member
Мнения: 56
Регистриран: ср май 25, 2016 12:50 pm
Баланс: Locked

пон юли 11, 2016 11:58 am

[quote="DoPe ;]]"][quote="MuHaBaM"][quote="DoPe ;]]"]Има ли някакъв шанс да махнете ранковете и да ми оставите само префиксите?[/quote]

Кажи имената на префиксите и флаговете и направо ще ти направя нов. :) [/quote]

[Head Admin] - Flag - g
[Help Admin] - Flag - m
[Admin] - Flag - o
[SMS Admin] - Flag - r
[V.I.P] - Flag - s[/quote]

Извинявай, че се забавих! Вчера не ми беше ден, защото контузиха Роналдо.... :shock: :x
admin_prefix.rar
(6.69 KиБ) Свален 142 пъти

Потребителски аватар
DoPe ;]]
Newbie
Мнения: 3
Регистриран: съб юли 09, 2016 9:51 pm
Баланс: Locked

вт юли 12, 2016 9:39 am

Благодаря ![/size]

Потребителски аватар
Irie
Newbie
Мнения: 16
Регистриран: съб юни 25, 2016 11:31 am
Баланс: Locked

ср ное 09, 2016 1:43 pm

Може ли да премахнете префиксите и да останат само ранковете?

Потребителски аватар
xvi
Администратор
Администратор
Мнения: 514
Регистриран: пет яну 15, 2016 6:20 am
Баланс: Locked

чет ное 10, 2016 11:14 pm

[quote="Irie"]Може ли да премахнете префиксите и да останат само ранковете?[/quote]
Трябва да си влязъл в системата, за да можеш да виждаш линковете
Titan

Потребителски аватар
Irie
Newbie
Мнения: 16
Регистриран: съб юни 25, 2016 11:31 am
Баланс: Locked

пет ное 11, 2016 2:29 pm

Искам само левелите/ранковете да останат, БЕЗ АДМИН ПРЕФИКСИТЕ.

Потребителски аватар
xvi
Администратор
Администратор
Мнения: 514
Регистриран: пет яну 15, 2016 6:20 am
Баланс: Locked

вт ное 15, 2016 7:42 pm

[quote="Irie"]Искам само левелите/ранковете да останат, БЕЗ АДМИН ПРЕФИКСИТЕ.[/quote]
Съжалявам за объркването, ето го Трябва да си влязъл в системата, за да можеш да виждаш линковете.
Titan

Потребителски аватар
dekema
Newbie
Мнения: 2
Регистриран: нед дек 25, 2016 12:42 pm
Баланс: Locked

съб яну 21, 2017 5:26 pm

Надявам се тази тема да е все още валидна.
Значи моя проблем е, че когато някой излезе от сървъра не запазва точките и някой път сървъра изобщо не тръгва докато не изтрия нещата в /cstrike/addons/amxmodx/data/vault (PlayerRanks.vault / PlayerRanks.journal) .  :huh:
Промених само някой неща (рангове, килове, префикси).

Благодаря ви за отделеното време!  :)

И понеже не ми дава да прикача файла
(Моля, поправете следните грешки:
  • Типът файл, който прикачате не е разрешен. Моля, премахнете прикаченият файл или изберете друг тип)

Код: Трябва да си влязъл в системата, за да можеш да виждаш линковете

#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < engine >
#include < colorchat >
#include < hamsandwich >
#include < fun >
#include < nvault >

#define MAXRANKS 14

#define PLUGIN "BP Admin prefix with ranks"
#define VERSION "1.3"
#define AUTHOR "BetterPlay"

//ПРОМЕНЛИВИ
new PlayerRank[33], message[192]
new sayText, teamInfo, maxPlayers, g_AdminListen,  g_AdminListenFlag,g_MsgHud, gVault
new strName[191], strText[191], alive[11], temp_cvar[2], g_name[13]
new gPlayerPoints[33], give[33],iTarget[33]

new const g_szTag[][] = {
       "",
       "Server Owner",
       "Administrator",
       "Global Moderator",
       "Supervisor",
       "Team Bans",
       "Server Admin",
       "Test Admin",
       "VIP",
       "SMS Admin"
}

new const rankNames[MAXRANKS][] =
{
"",
"[Private]", 
"[Private 2]", 
"[Private First Class]", 
"[Specialist]", 
"[Corporal]", 
"[Sergeant]", 
"[Staff Sergeant]", 
"[Sergeant First Class]", 
"[Master Sergeant]", 
"[First Sergeant]", 
"[Sergeant Major]", 
"[Command Sergeant Major]", 
"[Sergeant Major of the Army]"
};

new const rankXP[MAXRANKS] =
{
0, 25, 50, 100, 200, 300, 500, 750, 1000, 1250, 1500, 2000, 2500, 3000
};

public plugin_init()
{
 register_plugin(PLUGIN, VERSION, AUTHOR)
 
 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 /checkrank", "cmdCheckLevel")
 register_clcmd("say_team /checkrank", "cmdCheckLevel")
 register_clcmd("say /rankmenu", "cmdRankMenu", ADMIN_RCON)
 register_clcmd("say_team /rankmenu", "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;

 if(MAXRANKS == PlayerRank[id]+1)
 ColorChat(id, RED, "[UplayCS]^x01 Your level is ^x04#%d ^x01with rank ^x04%s ^x01. You have got ^x03 %d points", PlayerRank[id]+1, rankNames[PlayerRank[id]], gPlayerPoints[id])
 else
 ColorChat(id, RED, "[UplayCS]^x01 Your level is ^x04#%d ^x01with rank ^x04%s^x01. You have got ^x03 %d^x01 /^x04 %d^x01 points to become^x04 %s^x01.", PlayerRank[id]+1, rankNames[PlayerRank[id]], gPlayerPoints[id], rankXP[PlayerRank[id]+1], rankNames[PlayerRank[id]+1])
 
 switch( PlayerRank[ id ] )
 {
 case 28: set_user_health( id, get_user_health( id ) + 5 );
 case 29: set_user_health( id, get_user_health( id ) + 10 );
 case 30: set_user_health( id, get_user_health( id ) + 15 );
 case 31: set_user_health( id, get_user_health( id ) + 20 );
 case 32: set_user_health( id, get_user_health( id ) + 30 );
 }
}

public cmdCheckLevel(id)
{
 new iMenu = menu_create("\yUplayCS \d- \wChoose Player\r:", "checklevel_menu_handler")
 
 new iPlayers[32], iNum, iTarget;
 new UserName[34], szTempID[10];
 get_players(iPlayers, iNum);
 for(new i; i < iNum; i++)
 {
 iTarget = iPlayers[i];
 if(!is_user_connected(iTarget))
 continue;
 get_user_name(iTarget, UserName, sizeof UserName - 1);
 num_to_str(iTarget, szTempID, charsmax(szTempID));
 menu_additem(iMenu, UserName, szTempID);
 }
 menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL);
 menu_display(id, iMenu, 0);
}

public checklevel_menu_handler(id, iMenu, Item)
{
 if(Item == MENU_EXIT)
 {
 menu_destroy(iMenu);
 return PLUGIN_HANDLED;
 }
 new iData[6], iName[64];
 new access, callback;
 menu_item_getinfo(iMenu, Item, access, iData, charsmax(iData), iName, charsmax(iName), callback);
 new target = str_to_num(iData);
 if(!is_user_connected(target))
 {
 ColorChat(id, GREEN, "[UplayCS]^x01 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[13];
 get_user_name(target, player_name, 31);
 if(MAXRANKS == PlayerRank[target]+1)
 formatex(szText, charsmax(szText), "<html><head></head><body><br/>Name: %s<br/>Points: %d<br/>Level: %d/%d<br/>Rank: %s<br/></body></html>", player_name, gPlayerPoints[target], PlayerRank[target]+1, MAXRANKS, rankNames[PlayerRank[target]]);
 else
 formatex(szText, charsmax(szText), "<html><head></head><body><br/>Name: %s<br/>Points: %d/%d<br/>Level: %d/%d<br/>Rank: %s<br/>Next Rank: %s</body></html>", player_name, gPlayerPoints[target], rankXP[PlayerRank[target]+1], PlayerRank[target]+1, MAXRANKS, rankNames[PlayerRank[target]], rankNames[PlayerRank[target]+1]);
 show_motd(id, szText, "UplayCS Rank System");
 cmdCheckLevel(id);
 return PLUGIN_HANDLED;
}

public taskHud()
{
 new iPlayers[32], iNum, iTarget;
 get_players(iPlayers, iNum);
 for(new i; i < iNum; i++)
 {
 iTarget = iPlayers[i];
 if(!is_user_connected(iTarget))
 continue;
 
 set_hudmessage(0, 139, 139, 0.02, 0.17, 0, 6.0, 12.0)
 if(MAXRANKS == PlayerRank[iTarget]+1)
 ShowSyncHudMsg(iTarget, g_MsgHud, "Level: %d/%d^nRank : %s^nPoints : %d",PlayerRank[iTarget]+1, MAXRANKS, rankNames[PlayerRank[iTarget]], gPlayerPoints[iTarget])
 else
 ShowSyncHudMsg(iTarget, g_MsgHud, "Level: %d/%d^nRank : %s^nPoints : %d/%d",PlayerRank[iTarget]+1, MAXRANKS, rankNames[PlayerRank[iTarget]], gPlayerPoints[iTarget], rankXP[PlayerRank[iTarget]+1])
 }
}

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

public cmdRankMenu(id, level, cid)
{
 if(!cmd_access(id, level, cid, 1))
 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(iMenu, MPROP_EXIT, MEXIT_ALL);
 menu_display(id, iMenu, 0);
 return PLUGIN_CONTINUE;
}

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

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

 new iPlayers[32], iNum, iTarget;
 new UserName[34], szTempID[10];
 get_players(iPlayers, iNum);
 for(new i; i < iNum; i++)
 {
 iTarget = iPlayers[i];
 if(!is_user_connected(iTarget))
 continue;
 get_user_name(iTarget, UserName, sizeof UserName - 1);
 num_to_str(iTarget, szTempID, charsmax(szTempID));
 menu_additem(iMenu, UserName, szTempID);
 }
 menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL);
 menu_display(id, iMenu, 0);
}

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

 new iData[6], iName[64];
 new access, callback;
 menu_item_getinfo(iMenu, Item, access, iData, charsmax(iData), iName, charsmax(iName), callback);
 iTarget[id] = str_to_num(iData);
 if(!is_user_connected(iTarget[id]))
 {
 iTarget[id] = 0
 ColorChat(id, GREEN, "[UplayCS]^x01 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(id, level, cid)
{
 if(!cmd_access(id, level, cid, 1))
 return PLUGIN_HANDLED;

 if(!iTarget[id] || give[id] <= 0)
 return PLUGIN_HANDLED;
 if(!is_user_connected(iTarget[id]))
 {
 ColorChat(id, RED, "[UplayCS]^x01 The player you chose is not in the server.")
 return PLUGIN_HANDLED;
 }

 new iTyped[12];
 read_argv(1, iTyped, sizeof iTyped - 1);
 new g_points = str_to_num(iTyped)
 new AdminName[32], PlayerName[32];
 get_user_name(id, AdminName, 31)
 get_user_name(iTarget[id], PlayerName, 31)
 if(give[id] == 1)
 {
 gPlayerPoints[iTarget[id]] += g_points
 ColorChat(0, GREEN,"[UplayCS]^x03 %s^x01 gave^x04 %d^x01 rank points to^x03 %s^x01.", AdminName, g_points, PlayerName)
 }
 else
 {
 if(g_points > gPlayerPoints[iTarget[id]])
 gPlayerPoints[iTarget[id]] = 0
 else
 gPlayerPoints[iTarget[id]] -= g_points;
 ColorChat(0, GREEN,"[UplayCS]^x03 %s^x01 took^x04 %d^x01 rank points from^x03 %s^x01.", AdminName, g_points, PlayerName)
 }
 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);
 Save( id );
 return PLUGIN_HANDLED;
}

public client_authorized( id )
{
 Load( id );
}

public client_disconnect( id )
{
 Save( id );
}

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

public Load( id )
{
 if( !is_user_bot( id ) && !is_user_hltv( id ) )
 {
 new vaultkey[ 64 ], vaultdata[ 256 ], points[ 33 ], UserName[ 33 ];
 get_user_name( id, UserName, charsmax( UserName ) );
 
 format( vaultkey, charsmax( vaultkey ), "%s", UserName );
 format( vaultdata, charsmax( vaultdata ), "%i#", gPlayerPoints[ id ] );
 
 nvault_get( gVault, vaultkey, vaultdata, 255 );
 replace_all( vaultdata, 255, "#", " " );
 
 parse( vaultdata, points, 32 );
 gPlayerPoints[ id ] = str_to_num( points );
 }
}

public Save( id )
{
 if( !is_user_bot( id ) && !is_user_hltv( id ) )
 {
 new vaultkey[ 64 ], vaultdata[ 256 ], UserName[ 33 ];
 get_user_name( id, UserName, charsmax( UserName ) );
 
 format( vaultkey, charsmax( vaultkey ), "%s", UserName );
 format( vaultdata, charsmax( vaultdata ), "%i#", gPlayerPoints[ id ] );
 
 nvault_set( gVault, vaultkey, vaultdata );
 }
}

public avoid_duplicated(msgId, msgDest, receiver)
 return PLUGIN_HANDLED;

public hook_say(id)
{
 read_args(message, 191)
 remove_quotes(message)

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

 get_user_name(id, g_name, charsmax(g_name))

 new isAlive 
 new admin = 0, iFlags = get_user_flags(id)
 if(iFlags & ADMIN_LEVEL_B) admin = 1  //owner (n)
 else if(iFlags & ADMIN_LEVEL_C) admin = 2   //administrator (o)
 else if(iFlags & ADMIN_LEVEL_E) admin = 3  //global (q)
 else if(iFlags&  ADMIN_LEVEL_G) admin=4 //otgowornik (s)
 else if(iFlags& ADMIN_LEVEL_H) admin=5  //ekip banove (t)
 else if(iFlags & ADMIN_BAN) admin = 6  //admin (b)
 else if(iFlags & ADMIN_LEVEL_F) admin = 7  //test (r)
 else if(iFlags & ADMIN_LEVEL_D) admin = 8  //vip (p)
 else if(iFlags & ADMIN_CHAT) admin = 9  //sms admin (i)
 

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

 static  color[10]
 if(admin)
 {
 get_user_team(id, color, 9)
 format(strName, 191, "%s^x01[^x04%s^x01] ^x03%s ", alive, g_szTag[admin], g_name)
 format(strText, 191, "^x01%s", message)
 }
 else
 {
 get_user_name(id, g_name, 32)
 get_user_team(id, color, 9)
 format(strName, 191, "%s^x04%s ^x03%s", alive, rankNames[PlayerRank[id]], g_name)
 format(strText, 191, "%s", message)
 }

 format(message, 191, "%s ^x01: %s", strName, strText)

 sendMessage(color, isAlive)// Sends the colored message
 return PLUGIN_CONTINUE;
}

public hook_teamsay(id)
{
 read_args(message, 191)
 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 1: copy(playerTeamName, 11, "Terrorists")
 case 2: copy(playerTeamName, 18, "Counter-Terrorists")
 default: copy(playerTeamName, 9, "Spectator")
 }

 get_user_name(id, g_name, charsmax(g_name))
 new isAlive 
 new admin = 0, iFlags = get_user_flags(id)
 if(iFlags & ADMIN_LEVEL_B) admin = 1  //owner
 else if(iFlags & ADMIN_LEVEL_C) admin = 2   //administrator
 else if(iFlags & ADMIN_LEVEL_D) admin = 3  //global
 else if(iFlags&  ADMIN_LEVEL_G) admin=4 //otgowornik
 else if(iFlags& ADMIN_LEVEL_H) admin=5  //ekip banove
 else if(iFlags & ADMIN_BAN) admin = 6  //admin
 else if(iFlags & ADMIN_LEVEL_F) admin = 7  //test
 else if(iFlags & ADMIN_LEVEL_E) admin = 8  //vip
 else if(iFlags & ADMIN_CHAT) admin = 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(id, color, 9)
 format(strName, 191, "%s(%s) ^x01[^x04%s^x01] ^x03%s ", alive, playerTeamName,  g_szTag[admin], g_name)
 format(strText, 191, "^x01%s", message)
 }
 else
 {
 get_user_name(id, g_name, 32)
 get_user_team(id, color, 9);
 format(strName, 191, "%s(%s) ^x04%s ^x03%s", alive, playerTeamName, rankNames[PlayerRank[id]], g_name)
 format(strText, 191, "%s", message)
 }

 format(message, 191, "%s ^x01: %s", strName, strText)
 sendTeamMessage(color, isAlive, playerTeam)
 return PLUGIN_CONTINUE
}

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

 get_pcvar_string(g_AdminListenFlag, temp_cvar, charsmax(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(player, teamName, 9)// Stores user's team name to change back after sending the message
 changeTeamInfo(player, color)// Changes user's team according to color choosen
 writeMessage(player, message)// Writes the message on player's chat
 changeTeamInfo(player, teamName)// Changes user's team back to original
 }
 }
}

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

 for(new player = 1; player < maxPlayers; player++)
 {
 if(!is_user_connected(player))
 continue

 get_pcvar_string(g_AdminListenFlag, temp_cvar, charsmax(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(player, teamName, 9)// Stores user's team name to change back after sending the message
 changeTeamInfo(player, color)// Changes user's team according to color choosen
 writeMessage(player, message)// Writes the message on player's chat
 changeTeamInfo(player, teamName)// Changes user's team back to original
 }
 }
 }
}


public changeTeamInfo(player, team[])
{
 message_begin(MSG_ONE, teamInfo, _, 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(player, message[])
{
 message_begin(MSG_ONE, sayText, {0, 0, 0}, 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(killer, g_name, 31)
 ColorChat(0, GREEN, "[UplayCS] ^1Congratulations! ^x03%s^x01 got a new rank ^x04%s", g_name, rankNames[PlayerRank[killer]])
 }
 return PLUGIN_CONTINUE;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1026\\ f0\\ fs16 \n\\ par }
*/

Потребителски аватар
xvi
Администратор
Администратор
Мнения: 514
Регистриран: пет яну 15, 2016 6:20 am
Баланс: Locked

съб яну 21, 2017 7:43 pm

dekema написа: Надявам се тази тема да е все още валидна.
Значи моя проблем е, че когато някой излезе от сървъра не запазва точките и някой път сървъра изобщо не тръгва докато не изтрия нещата в /cstrike/addons/amxmodx/data/vault (PlayerRanks.vault / PlayerRanks.journal) .  :huh:
Промених само някой неща (рангове, килове, префикси).

Благодаря ви за отделеното време!  :)

И понеже не ми дава да прикача файла
(Моля, поправете следните грешки:
  • Типът файл, който прикачате не е разрешен. Моля, премахнете прикаченият файл или изберете друг тип)

Код: Трябва да си влязъл в системата, за да можеш да виждаш линковете

#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < engine >
#include < colorchat >
#include < hamsandwich >
#include < fun >
#include < nvault >

#define MAXRANKS 14

#define PLUGIN "BP Admin prefix with ranks"
#define VERSION "1.3"
#define AUTHOR "BetterPlay"

//ПРОМЕНЛИВИ
new PlayerRank[33], message[192]
new sayText, teamInfo, maxPlayers, g_AdminListen,  g_AdminListenFlag,g_MsgHud, gVault
new strName[191], strText[191], alive[11], temp_cvar[2], g_name[13]
new gPlayerPoints[33], give[33],iTarget[33]

new const g_szTag[][] = {
       "",
       "Server Owner",
       "Administrator",
       "Global Moderator",
       "Supervisor",
       "Team Bans",
       "Server Admin",
       "Test Admin",
       "VIP",
       "SMS Admin"
}

new const rankNames[MAXRANKS][] =
{
"",
"[Private]", 
"[Private 2]", 
"[Private First Class]", 
"[Specialist]", 
"[Corporal]", 
"[Sergeant]", 
"[Staff Sergeant]", 
"[Sergeant First Class]", 
"[Master Sergeant]", 
"[First Sergeant]", 
"[Sergeant Major]", 
"[Command Sergeant Major]", 
"[Sergeant Major of the Army]"
};

new const rankXP[MAXRANKS] =
{
0, 25, 50, 100, 200, 300, 500, 750, 1000, 1250, 1500, 2000, 2500, 3000
};

public plugin_init()
{
 register_plugin(PLUGIN, VERSION, AUTHOR)
 
 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 /checkrank", "cmdCheckLevel")
 register_clcmd("say_team /checkrank", "cmdCheckLevel")
 register_clcmd("say /rankmenu", "cmdRankMenu", ADMIN_RCON)
 register_clcmd("say_team /rankmenu", "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;

 if(MAXRANKS == PlayerRank[id]+1)
 ColorChat(id, RED, "[UplayCS]^x01 Your level is ^x04#%d ^x01with rank ^x04%s ^x01. You have got ^x03 %d points", PlayerRank[id]+1, rankNames[PlayerRank[id]], gPlayerPoints[id])
 else
 ColorChat(id, RED, "[UplayCS]^x01 Your level is ^x04#%d ^x01with rank ^x04%s^x01. You have got ^x03 %d^x01 /^x04 %d^x01 points to become^x04 %s^x01.", PlayerRank[id]+1, rankNames[PlayerRank[id]], gPlayerPoints[id], rankXP[PlayerRank[id]+1], rankNames[PlayerRank[id]+1])
 
 switch( PlayerRank[ id ] )
 {
 case 28: set_user_health( id, get_user_health( id ) + 5 );
 case 29: set_user_health( id, get_user_health( id ) + 10 );
 case 30: set_user_health( id, get_user_health( id ) + 15 );
 case 31: set_user_health( id, get_user_health( id ) + 20 );
 case 32: set_user_health( id, get_user_health( id ) + 30 );
 }
}

public cmdCheckLevel(id)
{
 new iMenu = menu_create("\yUplayCS \d- \wChoose Player\r:", "checklevel_menu_handler")
 
 new iPlayers[32], iNum, iTarget;
 new UserName[34], szTempID[10];
 get_players(iPlayers, iNum);
 for(new i; i < iNum; i++)
 {
 iTarget = iPlayers[i];
 if(!is_user_connected(iTarget))
 continue;
 get_user_name(iTarget, UserName, sizeof UserName - 1);
 num_to_str(iTarget, szTempID, charsmax(szTempID));
 menu_additem(iMenu, UserName, szTempID);
 }
 menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL);
 menu_display(id, iMenu, 0);
}

public checklevel_menu_handler(id, iMenu, Item)
{
 if(Item == MENU_EXIT)
 {
 menu_destroy(iMenu);
 return PLUGIN_HANDLED;
 }
 new iData[6], iName[64];
 new access, callback;
 menu_item_getinfo(iMenu, Item, access, iData, charsmax(iData), iName, charsmax(iName), callback);
 new target = str_to_num(iData);
 if(!is_user_connected(target))
 {
 ColorChat(id, GREEN, "[UplayCS]^x01 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[13];
 get_user_name(target, player_name, 31);
 if(MAXRANKS == PlayerRank[target]+1)
 formatex(szText, charsmax(szText), "<html><head></head><body><br/>Name: %s<br/>Points: %d<br/>Level: %d/%d<br/>Rank: %s<br/></body></html>", player_name, gPlayerPoints[target], PlayerRank[target]+1, MAXRANKS, rankNames[PlayerRank[target]]);
 else
 formatex(szText, charsmax(szText), "<html><head></head><body><br/>Name: %s<br/>Points: %d/%d<br/>Level: %d/%d<br/>Rank: %s<br/>Next Rank: %s</body></html>", player_name, gPlayerPoints[target], rankXP[PlayerRank[target]+1], PlayerRank[target]+1, MAXRANKS, rankNames[PlayerRank[target]], rankNames[PlayerRank[target]+1]);
 show_motd(id, szText, "UplayCS Rank System");
 cmdCheckLevel(id);
 return PLUGIN_HANDLED;
}

public taskHud()
{
 new iPlayers[32], iNum, iTarget;
 get_players(iPlayers, iNum);
 for(new i; i < iNum; i++)
 {
 iTarget = iPlayers[i];
 if(!is_user_connected(iTarget))
 continue;
 
 set_hudmessage(0, 139, 139, 0.02, 0.17, 0, 6.0, 12.0)
 if(MAXRANKS == PlayerRank[iTarget]+1)
 ShowSyncHudMsg(iTarget, g_MsgHud, "Level: %d/%d^nRank : %s^nPoints : %d",PlayerRank[iTarget]+1, MAXRANKS, rankNames[PlayerRank[iTarget]], gPlayerPoints[iTarget])
 else
 ShowSyncHudMsg(iTarget, g_MsgHud, "Level: %d/%d^nRank : %s^nPoints : %d/%d",PlayerRank[iTarget]+1, MAXRANKS, rankNames[PlayerRank[iTarget]], gPlayerPoints[iTarget], rankXP[PlayerRank[iTarget]+1])
 }
}

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

public cmdRankMenu(id, level, cid)
{
 if(!cmd_access(id, level, cid, 1))
 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(iMenu, MPROP_EXIT, MEXIT_ALL);
 menu_display(id, iMenu, 0);
 return PLUGIN_CONTINUE;
}

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

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

 new iPlayers[32], iNum, iTarget;
 new UserName[34], szTempID[10];
 get_players(iPlayers, iNum);
 for(new i; i < iNum; i++)
 {
 iTarget = iPlayers[i];
 if(!is_user_connected(iTarget))
 continue;
 get_user_name(iTarget, UserName, sizeof UserName - 1);
 num_to_str(iTarget, szTempID, charsmax(szTempID));
 menu_additem(iMenu, UserName, szTempID);
 }
 menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL);
 menu_display(id, iMenu, 0);
}

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

 new iData[6], iName[64];
 new access, callback;
 menu_item_getinfo(iMenu, Item, access, iData, charsmax(iData), iName, charsmax(iName), callback);
 iTarget[id] = str_to_num(iData);
 if(!is_user_connected(iTarget[id]))
 {
 iTarget[id] = 0
 ColorChat(id, GREEN, "[UplayCS]^x01 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(id, level, cid)
{
 if(!cmd_access(id, level, cid, 1))
 return PLUGIN_HANDLED;

 if(!iTarget[id] || give[id] <= 0)
 return PLUGIN_HANDLED;
 if(!is_user_connected(iTarget[id]))
 {
 ColorChat(id, RED, "[UplayCS]^x01 The player you chose is not in the server.")
 return PLUGIN_HANDLED;
 }

 new iTyped[12];
 read_argv(1, iTyped, sizeof iTyped - 1);
 new g_points = str_to_num(iTyped)
 new AdminName[32], PlayerName[32];
 get_user_name(id, AdminName, 31)
 get_user_name(iTarget[id], PlayerName, 31)
 if(give[id] == 1)
 {
 gPlayerPoints[iTarget[id]] += g_points
 ColorChat(0, GREEN,"[UplayCS]^x03 %s^x01 gave^x04 %d^x01 rank points to^x03 %s^x01.", AdminName, g_points, PlayerName)
 }
 else
 {
 if(g_points > gPlayerPoints[iTarget[id]])
 gPlayerPoints[iTarget[id]] = 0
 else
 gPlayerPoints[iTarget[id]] -= g_points;
 ColorChat(0, GREEN,"[UplayCS]^x03 %s^x01 took^x04 %d^x01 rank points from^x03 %s^x01.", AdminName, g_points, PlayerName)
 }
 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);
 Save( id );
 return PLUGIN_HANDLED;
}

public client_authorized( id )
{
 Load( id );
}

public client_disconnect( id )
{
 Save( id );
}

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

public Load( id )
{
 if( !is_user_bot( id ) && !is_user_hltv( id ) )
 {
 new vaultkey[ 64 ], vaultdata[ 256 ], points[ 33 ], UserName[ 33 ];
 get_user_name( id, UserName, charsmax( UserName ) );
 
 format( vaultkey, charsmax( vaultkey ), "%s", UserName );
 format( vaultdata, charsmax( vaultdata ), "%i#", gPlayerPoints[ id ] );
 
 nvault_get( gVault, vaultkey, vaultdata, 255 );
 replace_all( vaultdata, 255, "#", " " );
 
 parse( vaultdata, points, 32 );
 gPlayerPoints[ id ] = str_to_num( points );
 }
}

public Save( id )
{
 if( !is_user_bot( id ) && !is_user_hltv( id ) )
 {
 new vaultkey[ 64 ], vaultdata[ 256 ], UserName[ 33 ];
 get_user_name( id, UserName, charsmax( UserName ) );
 
 format( vaultkey, charsmax( vaultkey ), "%s", UserName );
 format( vaultdata, charsmax( vaultdata ), "%i#", gPlayerPoints[ id ] );
 
 nvault_set( gVault, vaultkey, vaultdata );
 }
}

public avoid_duplicated(msgId, msgDest, receiver)
 return PLUGIN_HANDLED;

public hook_say(id)
{
 read_args(message, 191)
 remove_quotes(message)

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

 get_user_name(id, g_name, charsmax(g_name))

 new isAlive 
 new admin = 0, iFlags = get_user_flags(id)
 if(iFlags & ADMIN_LEVEL_B) admin = 1  //owner (n)
 else if(iFlags & ADMIN_LEVEL_C) admin = 2   //administrator (o)
 else if(iFlags & ADMIN_LEVEL_E) admin = 3  //global (q)
 else if(iFlags&  ADMIN_LEVEL_G) admin=4 //otgowornik (s)
 else if(iFlags& ADMIN_LEVEL_H) admin=5  //ekip banove (t)
 else if(iFlags & ADMIN_BAN) admin = 6  //admin (b)
 else if(iFlags & ADMIN_LEVEL_F) admin = 7  //test (r)
 else if(iFlags & ADMIN_LEVEL_D) admin = 8  //vip (p)
 else if(iFlags & ADMIN_CHAT) admin = 9  //sms admin (i)
 

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

 static  color[10]
 if(admin)
 {
 get_user_team(id, color, 9)
 format(strName, 191, "%s^x01[^x04%s^x01] ^x03%s ", alive, g_szTag[admin], g_name)
 format(strText, 191, "^x01%s", message)
 }
 else
 {
 get_user_name(id, g_name, 32)
 get_user_team(id, color, 9)
 format(strName, 191, "%s^x04%s ^x03%s", alive, rankNames[PlayerRank[id]], g_name)
 format(strText, 191, "%s", message)
 }

 format(message, 191, "%s ^x01: %s", strName, strText)

 sendMessage(color, isAlive)// Sends the colored message
 return PLUGIN_CONTINUE;
}

public hook_teamsay(id)
{
 read_args(message, 191)
 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 1: copy(playerTeamName, 11, "Terrorists")
 case 2: copy(playerTeamName, 18, "Counter-Terrorists")
 default: copy(playerTeamName, 9, "Spectator")
 }

 get_user_name(id, g_name, charsmax(g_name))
 new isAlive 
 new admin = 0, iFlags = get_user_flags(id)
 if(iFlags & ADMIN_LEVEL_B) admin = 1  //owner
 else if(iFlags & ADMIN_LEVEL_C) admin = 2   //administrator
 else if(iFlags & ADMIN_LEVEL_D) admin = 3  //global
 else if(iFlags&  ADMIN_LEVEL_G) admin=4 //otgowornik
 else if(iFlags& ADMIN_LEVEL_H) admin=5  //ekip banove
 else if(iFlags & ADMIN_BAN) admin = 6  //admin
 else if(iFlags & ADMIN_LEVEL_F) admin = 7  //test
 else if(iFlags & ADMIN_LEVEL_E) admin = 8  //vip
 else if(iFlags & ADMIN_CHAT) admin = 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(id, color, 9)
 format(strName, 191, "%s(%s) ^x01[^x04%s^x01] ^x03%s ", alive, playerTeamName,  g_szTag[admin], g_name)
 format(strText, 191, "^x01%s", message)
 }
 else
 {
 get_user_name(id, g_name, 32)
 get_user_team(id, color, 9);
 format(strName, 191, "%s(%s) ^x04%s ^x03%s", alive, playerTeamName, rankNames[PlayerRank[id]], g_name)
 format(strText, 191, "%s", message)
 }

 format(message, 191, "%s ^x01: %s", strName, strText)
 sendTeamMessage(color, isAlive, playerTeam)
 return PLUGIN_CONTINUE
}

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

 get_pcvar_string(g_AdminListenFlag, temp_cvar, charsmax(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(player, teamName, 9)// Stores user's team name to change back after sending the message
 changeTeamInfo(player, color)// Changes user's team according to color choosen
 writeMessage(player, message)// Writes the message on player's chat
 changeTeamInfo(player, teamName)// Changes user's team back to original
 }
 }
}

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

 for(new player = 1; player < maxPlayers; player++)
 {
 if(!is_user_connected(player))
 continue

 get_pcvar_string(g_AdminListenFlag, temp_cvar, charsmax(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(player, teamName, 9)// Stores user's team name to change back after sending the message
 changeTeamInfo(player, color)// Changes user's team according to color choosen
 writeMessage(player, message)// Writes the message on player's chat
 changeTeamInfo(player, teamName)// Changes user's team back to original
 }
 }
 }
}


public changeTeamInfo(player, team[])
{
 message_begin(MSG_ONE, teamInfo, _, 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(player, message[])
{
 message_begin(MSG_ONE, sayText, {0, 0, 0}, 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(killer, g_name, 31)
 ColorChat(0, GREEN, "[UplayCS] ^1Congratulations! ^x03%s^x01 got a new rank ^x04%s", g_name, rankNames[PlayerRank[killer]])
 }
 return PLUGIN_CONTINUE;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1026\\ f0\\ fs16 \n\\ par }
*/

Заповядай. П.С. .sma и .amxx файловете трябва да са разрешени вече!

Код: Трябва да си влязъл в системата, за да можеш да виждаш линковете

#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < engine >
#include < colorchat >
#include < hamsandwich >
#include < fun >
#include < nvault >

#define MAXRANKS 14

#define PLUGIN "BP Admin prefix with ranks"
#define VERSION "1.3"
#define AUTHOR "BetterPlay"

//ПРОМЕНЛИВИ
new PlayerRank[33], message[192]
new sayText, teamInfo, maxPlayers, g_AdminListen,  g_AdminListenFlag,g_MsgHud, gVault
new strName[191], strText[191], alive[11], temp_cvar[2], g_name[14]
new gPlayerPoints[33], give[33],iTarget[33]

new const g_szTag[][] = {
      "",
      "Server Owner",
      "Administrator",
      "Global Moderator",
      "Supervisor",
      "Team Bans",
      "Server Admin",
      "Test Admin",
      "VIP",
      "SMS Admin"
}

new const rankNames[MAXRANKS][] =
{
"",
"[Private]", 
"[Private 2]", 
"[Private First Class]", 
"[Specialist]", 
"[Corporal]", 
"[Sergeant]", 
"[Staff Sergeant]", 
"[Sergeant First Class]", 
"[Master Sergeant]", 
"[First Sergeant]", 
"[Sergeant Major]", 
"[Command Sergeant Major]", 
"[Sergeant Major of the Army]"
};

new const rankXP[MAXRANKS] =
{
0, 25, 50, 100, 200, 300, 500, 750, 1000, 1250, 1500, 2000, 2500, 3000
};

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

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 /checkrank", "cmdCheckLevel")
register_clcmd("say_team /checkrank", "cmdCheckLevel")
register_clcmd("say /rankmenu", "cmdRankMenu", ADMIN_RCON)
register_clcmd("say_team /rankmenu", "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;

if(MAXRANKS == PlayerRank[id]+1)
ColorChat(id, RED, "[UplayCS]^x01 Your level is ^x04#%d ^x01with rank ^x04%s ^x01. You have got ^x03 %d points", PlayerRank[id]+1, rankNames[PlayerRank[id]], gPlayerPoints[id])
else
ColorChat(id, RED, "[UplayCS]^x01 Your level is ^x04#%d ^x01with rank ^x04%s^x01. You have got ^x03 %d^x01 /^x04 %d^x01 points to become^x04 %s^x01.", PlayerRank[id]+1, rankNames[PlayerRank[id]], gPlayerPoints[id], rankXP[PlayerRank[id]+1], rankNames[PlayerRank[id]+1])

switch( PlayerRank[ id ] )
{
case 28: set_user_health( id, get_user_health( id ) + 5 );
case 29: set_user_health( id, get_user_health( id ) + 10 );
case 30: set_user_health( id, get_user_health( id ) + 15 );
case 31: set_user_health( id, get_user_health( id ) + 20 );
case 32: set_user_health( id, get_user_health( id ) + 30 );
}
}

public cmdCheckLevel(id)
{
new iMenu = menu_create("\yUplayCS \d- \wChoose Player\r:", "checklevel_menu_handler")

new iPlayers[32], iNum, iTarget;
new UserName[34], szTempID[10];
get_players(iPlayers, iNum);
for(new i; i < iNum; i++)
{
iTarget = iPlayers[i];
if(!is_user_connected(iTarget))
continue;
get_user_name(iTarget, UserName, sizeof UserName - 1);
num_to_str(iTarget, szTempID, charsmax(szTempID));
menu_additem(iMenu, UserName, szTempID);
}
menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, iMenu, 0);
}

public checklevel_menu_handler(id, iMenu, Item)
{
if(Item == MENU_EXIT)
{
menu_destroy(iMenu);
return PLUGIN_HANDLED;
}
new iData[6], iName[64];
new access, callback;
menu_item_getinfo(iMenu, Item, access, iData, charsmax(iData), iName, charsmax(iName), callback);
new target = str_to_num(iData);
if(!is_user_connected(target))
{
ColorChat(id, GREEN, "[UplayCS]^x01 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[13];
get_user_name(target, player_name, 31);
if(MAXRANKS == PlayerRank[target]+1)
formatex(szText, charsmax(szText), "<html><head></head><body><br/>Name: %s<br/>Points: %d<br/>Level: %d/%d<br/>Rank: %s<br/></body></html>", player_name, gPlayerPoints[target], PlayerRank[target]+1, MAXRANKS, rankNames[PlayerRank[target]]);
else
formatex(szText, charsmax(szText), "<html><head></head><body><br/>Name: %s<br/>Points: %d/%d<br/>Level: %d/%d<br/>Rank: %s<br/>Next Rank: %s</body></html>", player_name, gPlayerPoints[target], rankXP[PlayerRank[target]+1], PlayerRank[target]+1, MAXRANKS, rankNames[PlayerRank[target]], rankNames[PlayerRank[target]+1]);
show_motd(id, szText, "UplayCS Rank System");
cmdCheckLevel(id);
return PLUGIN_HANDLED;
}

public taskHud()
{
new iPlayers[32], iNum, iTarget;
get_players(iPlayers, iNum);
for(new i; i < iNum; i++)
{
iTarget = iPlayers[i];
if(!is_user_connected(iTarget))
continue;

set_hudmessage(0, 139, 139, 0.02, 0.17, 0, 6.0, 12.0)
if(MAXRANKS == PlayerRank[iTarget]+1)
ShowSyncHudMsg(iTarget, g_MsgHud, "Level: %d/%d^nRank : %s^nPoints : %d",PlayerRank[iTarget]+1, MAXRANKS, rankNames[PlayerRank[iTarget]], gPlayerPoints[iTarget])
else
ShowSyncHudMsg(iTarget, g_MsgHud, "Level: %d/%d^nRank : %s^nPoints : %d/%d",PlayerRank[iTarget]+1, MAXRANKS, rankNames[PlayerRank[iTarget]], gPlayerPoints[iTarget], rankXP[PlayerRank[iTarget]+1])
}
}

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

public cmdRankMenu(id, level, cid)
{
if(!cmd_access(id, level, cid, 1))
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(iMenu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, iMenu, 0);
return PLUGIN_CONTINUE;
}

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

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

new iPlayers[32], iNum, iTarget;
new UserName[34], szTempID[10];
get_players(iPlayers, iNum);
for(new i; i < iNum; i++)
{
iTarget = iPlayers[i];
if(!is_user_connected(iTarget))
continue;
get_user_name(iTarget, UserName, sizeof UserName - 1);
num_to_str(iTarget, szTempID, charsmax(szTempID));
menu_additem(iMenu, UserName, szTempID);
}
menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, iMenu, 0);
}

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

new iData[6], iName[64];
new access, callback;
menu_item_getinfo(iMenu, Item, access, iData, charsmax(iData), iName, charsmax(iName), callback);
iTarget[id] = str_to_num(iData);
if(!is_user_connected(iTarget[id]))
{
iTarget[id] = 0
ColorChat(id, GREEN, "[UplayCS]^x01 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(id, level, cid)
{
if(!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED;

if(!iTarget[id] || give[id] <= 0)
return PLUGIN_HANDLED;
if(!is_user_connected(iTarget[id]))
{
ColorChat(id, RED, "[UplayCS]^x01 The player you chose is not in the server.")
return PLUGIN_HANDLED;
}

new iTyped[12];
read_argv(1, iTyped, sizeof iTyped - 1);
new g_points = str_to_num(iTyped)
new AdminName[32], PlayerName[32];
get_user_name(id, AdminName, 31)
get_user_name(iTarget[id], PlayerName, 31)
if(give[id] == 1)
{
gPlayerPoints[iTarget[id]] += g_points
ColorChat(0, GREEN,"[UplayCS]^x03 %s^x01 gave^x04 %d^x01 rank points to^x03 %s^x01.", AdminName, g_points, PlayerName)
}
else
{
if(g_points > gPlayerPoints[iTarget[id]])
gPlayerPoints[iTarget[id]] = 0
else
gPlayerPoints[iTarget[id]] -= g_points;
ColorChat(0, GREEN,"[UplayCS]^x03 %s^x01 took^x04 %d^x01 rank points from^x03 %s^x01.", AdminName, g_points, PlayerName)
}
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);
Save( id );
return PLUGIN_HANDLED;
}

public client_authorized( id )
{
Load( id );
}

public client_disconnect( id )
{
Save( id );
}

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

public Load( id )
{
if( !is_user_bot( id ) && !is_user_hltv( id ) )
{
new vaultkey[ 64 ], vaultdata[ 256 ], points[ 33 ], UserName[ 33 ];
get_user_name( id, UserName, charsmax( UserName ) );

format( vaultkey, charsmax( vaultkey ), "%s", UserName );
format( vaultdata, charsmax( vaultdata ), "%i#", gPlayerPoints[ id ] );

nvault_get( gVault, vaultkey, vaultdata, 255 );
replace_all( vaultdata, 255, "#", " " );

parse( vaultdata, points, 32 );
gPlayerPoints[ id ] = str_to_num( points );
}
}

public Save( id )
{
if( !is_user_bot( id ) && !is_user_hltv( id ) )
{
new vaultkey[ 64 ], vaultdata[ 256 ], UserName[ 33 ];
get_user_name( id, UserName, charsmax( UserName ) );

format( vaultkey, charsmax( vaultkey ), "%s", UserName );
format( vaultdata, charsmax( vaultdata ), "%i#", gPlayerPoints[ id ] );

nvault_set( gVault, vaultkey, vaultdata );
}
}

public avoid_duplicated(msgId, msgDest, receiver)
return PLUGIN_HANDLED;

public hook_say(id)
{
read_args(message, 191)
remove_quotes(message)

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

get_user_name(id, g_name, charsmax(g_name))

new isAlive 
new admin = 0, iFlags = get_user_flags(id)
if(iFlags & ADMIN_LEVEL_B) admin = 1  //owner (n)
else if(iFlags & ADMIN_LEVEL_C) admin = 2   //administrator (o)
else if(iFlags & ADMIN_LEVEL_E) admin = 3  //global (q)
else if(iFlags&  ADMIN_LEVEL_G) admin=4 //otgowornik (s)
else if(iFlags& ADMIN_LEVEL_H) admin=5  //ekip banove (t)
else if(iFlags & ADMIN_BAN) admin = 6  //admin (b)
else if(iFlags & ADMIN_LEVEL_F) admin = 7  //test (r)
else if(iFlags & ADMIN_LEVEL_D) admin = 8  //vip (p)
else if(iFlags & ADMIN_CHAT) admin = 9  //sms admin (i)


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

static  color[10]
if(admin)
{
get_user_team(id, color, 9)
format(strName, 191, "%s^x01[^x04%s^x01] ^x03%s ", alive, g_szTag[admin], g_name)
format(strText, 191, "^x01%s", message)
}
else
{
get_user_name(id, g_name, 32)
get_user_team(id, color, 9)
format(strName, 191, "%s^x04%s ^x03%s", alive, rankNames[PlayerRank[id]], g_name)
format(strText, 191, "%s", message)
}

format(message, 191, "%s ^x01: %s", strName, strText)

sendMessage(color, isAlive)// Sends the colored message
return PLUGIN_CONTINUE;
}

public hook_teamsay(id)
{
read_args(message, 191)
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 1: copy(playerTeamName, 11, "Terrorists")
case 2: copy(playerTeamName, 18, "Counter-Terrorists")
default: copy(playerTeamName, 9, "Spectator")
}

get_user_name(id, g_name, charsmax(g_name))
new isAlive 
new admin = 0, iFlags = get_user_flags(id)
if(iFlags & ADMIN_LEVEL_B) admin = 1  //owner
else if(iFlags & ADMIN_LEVEL_C) admin = 2   //administrator
else if(iFlags & ADMIN_LEVEL_D) admin = 3  //global
else if(iFlags&  ADMIN_LEVEL_G) admin=4 //otgowornik
else if(iFlags& ADMIN_LEVEL_H) admin=5  //ekip banove
else if(iFlags & ADMIN_BAN) admin = 6  //admin
else if(iFlags & ADMIN_LEVEL_F) admin = 7  //test
else if(iFlags & ADMIN_LEVEL_E) admin = 8  //vip
else if(iFlags & ADMIN_CHAT) admin = 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(id, color, 9)
format(strName, 191, "%s(%s) ^x01[^x04%s^x01] ^x03%s ", alive, playerTeamName,  g_szTag[admin], g_name)
format(strText, 191, "^x01%s", message)
}
else
{
get_user_name(id, g_name, 32)
get_user_team(id, color, 9);
format(strName, 191, "%s(%s) ^x04%s ^x03%s", alive, playerTeamName, rankNames[PlayerRank[id]], g_name)
format(strText, 191, "%s", message)
}

format(message, 191, "%s ^x01: %s", strName, strText)
sendTeamMessage(color, isAlive, playerTeam)
return PLUGIN_CONTINUE
}

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

get_pcvar_string(g_AdminListenFlag, temp_cvar, charsmax(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(player, teamName, 9)// Stores user's team name to change back after sending the message
changeTeamInfo(player, color)// Changes user's team according to color choosen
writeMessage(player, message)// Writes the message on player's chat
changeTeamInfo(player, teamName)// Changes user's team back to original
}
}
}

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

for(new player = 1; player < maxPlayers; player++)
{
if(!is_user_connected(player))
continue

get_pcvar_string(g_AdminListenFlag, temp_cvar, charsmax(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(player, teamName, 9)// Stores user's team name to change back after sending the message
changeTeamInfo(player, color)// Changes user's team according to color choosen
writeMessage(player, message)// Writes the message on player's chat
changeTeamInfo(player, teamName)// Changes user's team back to original
}
}
}
}


public changeTeamInfo(player, team[])
{
message_begin(MSG_ONE, teamInfo, _, 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(player, message[])
{
message_begin(MSG_ONE, sayText, {0, 0, 0}, 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(killer, g_name, 31)
ColorChat(0, GREEN, "[UplayCS] ^1Congratulations! ^x03%s^x01 got a new rank ^x04%s", g_name, rankNames[PlayerRank[killer]])
}
return PLUGIN_CONTINUE;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1026\\ f0\\ fs16 \n\\ par }
*/
Последна промяна от xvi на съб яну 21, 2017 7:49 pm, променено общо 1 път.

Потребителски аватар
dekema
Newbie
Мнения: 2
Регистриран: нед дек 25, 2016 12:42 pm
Баланс: Locked

съб яну 21, 2017 9:18 pm

Благодаря за отделеното време, но за жалост отново е така, вече не се налага да трия файловете в vault де, но като изляза и пак вляза пак съм 0/25. 

Когато компилирам кода излиза следното, 

Код: Трябва да си влязъл в системата, за да можеш да виждаш линковете

include\engine_const.inc(249) : warning 201: redefinition of constant/macro (symbol "TraceResult")

използвам online компилатор, защото когато го компилирам локално излиза после, че е невалиден плъгина.

Отговори

Върни се в “AMX Mod (X)”

  • Информация
  • Кой е на линия

    Потребители, разглеждащи този форум: Няма регистрирани потребители и 1 гост