Junior Member
|
12-16-2017
, 10:52
Re: I need an xp plugin + patents + rank + HUD + menu
|
#15
|
Quote:
Originally Posted by tarsisd2
from what you wrote, it does exactly what you are looking for, maybe just some tweaks, no one its going to make some thing big as the one you are describing for free, thats just too much work
|
help me
This plugin is in error, can you help me?
Code:
#include <amxmodx>
// #include <amxmisc>
// #include <cstrike>
// #include <engine>
#include <fakemeta>
#include <nfvault>
#include <dhudmessage>
// #include <hamsandwich>
// #include <fun>
// #include <xs>
// #include <sqlx>
#define PLUGIN "Sistema de Patente"
#define VERSION "1.0"
#define AUTHOR "Hannah"
/*------ Prefix ------*/
new xPrefix [] = "!n[!gNightKillers!n]!t:";
/* Admin Prefix */
#define FLAG_DONO ADMIN_LEVEL_C
#define FLAG_MASTER ADMIN_LEVEL_D
#define FLAG_SUPREMO ADMIN_LEVEL_G
#define FLAG_ADMIN ADMIN_LEVEL_B
#define FLAG_VIP ADMIN_LEVEL_H
#define FLAG_GIRL ADMIN_LEVEL_F
#define AD1 "DONO"
#define AD2 "MASTER"
#define AD3 "SUPREMO"
#define AD4 "ADMIN"
#define AD5 "V.I.P"
#define AD6 "GIRL"
/*------ DATA ------*/
enum _:DATA
{
Nick[30],
Frags
}
/*------ Patentes ------*/
new const Rank[][DATA] =
{
{ "Prata I", 200 },
{ "Prata II", 400 },
{ "Prata III", 600 },
{ "Prata IV", 800 },
{ "Prata Elite", 1000 },
{ "Ouro I", 1200 },
{ "Ouro II", 1400 },
{ "Ouro III", 1600 },
{ "Ouro Mestre",1800 },
{ "AK I", 2000 },
{ "AK II", 2500 },
{ "AK Cruzada", 3000 },
{ "Aguia I", 3500 },
{ "Aguia II", 4500 },
{ "Supremo Master", 7000 },
{ "Global Elite", 100000 },
{ "NightKillers Global", 1500000000000000 }
}
/*------ Global ------*/
new g_rank[33];
new g_frags[33];
/*------ Morte ------*/
new cvar_hsx2;
new cvar_knifex2;
/*------ Outros ------*/
new VaultRank[128], szRank[180], szKey[30]
new g_maxplayers, g_msgTeamInfo, g_msgSayText, g_playername[33][32];
/*------ Salvar ------*/
#define XD is_user_connected(id) || !is_user_bot(id) || !is_user_hltv(id)
/*------ Plugi-Init ------*/
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
/*------ Patente ------*/
register_clcmd("say /patente", "szybkie_menu")
register_clcmd("patente", "cmdPatente")
register_clcmd("allpatentes", "ShowMotd")
register_clcmd("say_team /patente", "szybkie_menu")
register_clcmd("say /patentes", "szybkie_menu")
register_clcmd("say_team /patentes", "szybkie_menu")
register_clcmd("say .patente", "szybkie_menu")
register_clcmd("say_team .patente", "szybkie_menu")
register_clcmd("say .patentes", "szybkie_menu")
register_clcmd("say_team .patentes", "szybkie_menu")
/*--------------------*/
register_clcmd("say", "message_saytext")
register_clcmd("say_team", "message_sayteam")
/*------ Evento ------*/
register_event("DeathMsg", "Event_DeathMsg", "a")
register_logevent("logevent_round_end", 2, "1=Round_End")
/*------ Quantidade ------*/
cvar_knifex2 = register_cvar("rank_knifex2", "2") // 1 - x2 Frags KNIFE | 0 - Nada
cvar_hsx2 = register_cvar("rank_hsx2", "1") // 1 - x2 Frags HS | 0 - Nada
/*------ Outros ------*/
g_maxplayers = get_maxplayers()
g_msgTeamInfo = get_user_msgid("TeamInfo")
g_msgSayText = get_user_msgid("SayText")
nfv_file("SystemRank", VaultRank, charsmax(VaultRank))
}
public cmdPatente(id)
{
xClientPrintColor(id, "!g-----------------------------------------------------------------------------------------------")
xClientPrintColor(id, "%s !nPatente: !g%s", xPrefix, Rank[g_rank[id]][Nick])
xClientPrintColor(id, "%s !nProx Patente: !g%s", xPrefix, Rank[g_rank[id]+1][Nick])
xClientPrintColor(id, "%s !nXP Restante: !g%d", xPrefix, Rank[g_rank[id]][Frags] - g_frags[id])
xClientPrintColor(id, "!g-----------------------------------------------------------------------------------------------")
}
/*=============================================================================================================
================================================== PUTINSERVER ================================================
==============================================================================================================*/
public client_putinserver(id)
{
g_rank[id] = 0
g_frags[id] = 0
Cargar(id)
set_task(1.1, "hud_status", id, _, _, "b")
new player = 0
// Player dead?
if (!is_user_alive(player))
{
// Target not alive
if (!is_user_alive(player))
return;
}
new player_name[32]
get_user_name(id, player_name, charsmax(player_name))
xClientPrintColor(0, "!g-----------------------------------------------------------------------------------------------")
xClientPrintColor(0, "%s !nPlayer: !g%s !nConectado.", xPrefix, player_name)
xClientPrintColor(0, "%s !nPatente: !g%s !t|| !nProx Patente: !g%s", xPrefix, Rank[g_rank[player]][Nick], Rank[g_rank[player]+1][Nick])
xClientPrintColor(0, "%s !nXP Restante: !g%d", xPrefix, Rank[g_rank[player]][Frags] - g_frags[player])
xClientPrintColor(0, "!g-----------------------------------------------------------------------------------------------")
}
public ShowMotd(id)
{
show_motd(id, "allpatentes.txt")
}
/*==============================================================================================================
==================================================== GUARDAR ===================================================
==============================================================================================================*/
public client_disconnect(id)
{
if(XD) Guardar(id);
}
public logevent_round_end()
{
for(new id = 1; id <= g_maxplayers; id++)
{
if(XD)
Guardar(id);
}
}
public hud_status(id)
{
if(!is_user_alive(id) || !is_user_connected(id) )
return;
set_dhudmessage(random(255), random(255), random(255), 0.02, 0.2, 0, 1.0, 1.1, 0.0, 0.0, -1)
show_dhudmessage(id,"» NightKillers 4Fun^n» Patente: %s^n» Prox Patente: %s^n» XP Restante: %d", Rank[g_rank[id]][Nick], Rank[g_rank[id]+1][Nick], Rank[g_rank[id]][Frags] - g_frags[id])
}
public szybkie_menu(id)
{
new menu = menu_create("\r» \yNigthKillerS \w| Menu Patentes:^n» \yPatentes by Maico.", "menu_wybierz")
menu_additem(menu, "\r» \wVisualizar Sua Patente\y.", "1", 0)
menu_additem(menu, "\r» \wHUD Patente: \d|\yDESATIVAR\d|", "2", 0)
menu_additem(menu, "\r» \wLista de Patentes \y+ \wInformacoes", "3", 0)
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
}
public menu_wybierz(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new acces, callback
menu_item_getinfo(menu, item, acces, data,5, iName, 63, callback)
new key = str_to_num(data)
switch(key)
{
case 1 : client_cmd(id,"patente")
case 2 : remove_task(id)
case 3 : client_cmd(id,"allpatentes")
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
/*==============================================================================================================
==================================================== UP RANK ===================================================
==============================================================================================================*/
public Event_DeathMsg() {
new attacker = read_data(1)
new victim = read_data(2)
new hs = read_data(3)
new weaponid = get_user_weapon(attacker)
if(victim == attacker) return;
if(is_user_alive(attacker)) {
g_frags[attacker]++
if(get_pcvar_num(cvar_knifex2)) {
if(weaponid == CSW_KNIFE)
g_frags[attacker]++
}
if(get_pcvar_num(cvar_hsx2)) {
if(hs) g_frags[attacker]++
}
AumentarRank(attacker)
}
}
/*==============================================================================================================
==================================================== UP RANK ===================================================
==============================================================================================================*/
AumentarRank(id)
{
new Aumento = false
while(g_frags[id] >= Rank[g_rank[id]][Frags])
{
Aumento = true
g_rank[id]++
}
if(Aumento) {
xClientPrintColor(id, "%s !nUP Patente: !g%s", xPrefix, Rank[g_rank[id]][Nick])
Aumento = false
}
}
/*==============================================================================================================
====================================================== SAY =====================================================
==============================================================================================================*/
public message_saytext(id) {
static said[192]
read_args(said, charsmax(said))
remove_quotes(said)
if (said[0] == '@' || said[0] == '%' || said[0] == '!' || equal (said, "/"))
return PLUGIN_HANDLED
if (!ValidMessage(said, 1)) return PLUGIN_CONTINUE;
static color[11], name[32], alive[11]
get_user_team(id,color,charsmax(color))
get_user_name(id,name,charsmax(name))
if (is_user_alive (id)) {
alive = ""
} else {
alive = "*MORTO* "
}
if (is_user_admin(id)) {
if (get_user_flags(id) & FLAG_DONO)
format(said, charsmax(said), "^x01%s^x01[^x03%s^x01] ^x01[^x04%s^x01] ^x03%s: ^x04%s", alive, AD1, Rank[g_rank[id]][Nick], name, said)
else if (get_user_flags(id) & FLAG_MASTER)
format(said, charsmax(said), "^x01%s^x01[^x03%s^x01] ^x01[^x04%s^x01] ^x03%s: ^x04%s", alive, AD2, Rank[g_rank[id]][Nick], name, said)
else if (get_user_flags(id) & FLAG_SUPREMO)
format(said, charsmax(said), "^x01%s^x01[^x03%s^x01] ^x01[^x04%s^x01] ^x03%s: ^x04%s", alive, AD3, Rank[g_rank[id]][Nick], name, said)
else if (get_user_flags(id) & FLAG_ADMIN)
format(said, charsmax(said), "^x01%s^x01[^x03%s^x01] ^x01[^x04%s^x01] ^x03%s: ^x04%s", alive, AD4, Rank[g_rank[id]][Nick], name, said)
else if (get_user_flags(id) & FLAG_VIP)
format(said, charsmax(said), "^x01%s^x01[^x03%s^x01] ^x01[^x04%s^x01] ^x03%s: ^x04%s", alive, AD5, Rank[g_rank[id]][Nick], name, said)
else if (get_user_flags(id) & FLAG_GIRL)
format(said, charsmax(said), "^x01%s^x01[^x03%s^x01] ^x01[^x04%s^x01] ^x03%s: ^x04%s", alive, AD6, Rank[g_rank[id]][Nick], name, said)
} else {
format(said, charsmax(said), "^x01%s^x01[^x04%s^x01] ^x03%s: ^x01%s", alive, Rank[g_rank[id]][Nick], name, said)
}
static i, team[11]
for (i = 1; i <= g_maxplayers; i++) {
if (!is_user_connected(i)) continue
get_user_name(id,name,charsmax(name))
if (is_user_admin(i) || is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i)) {
get_user_team(i, team, charsmax(team))
changeTeamInfo(i, color)
writeMessage(i, said)
changeTeamInfo(i, team)
}
}
return PLUGIN_HANDLED_MAIN;
}
public message_sayteam(id)
{
static said[192]
read_args(said, charsmax(said))
remove_quotes(said)
if (said[0] == '@' || said[0] == '%' || said[0] == '!' || equal (said, "/"))
return PLUGIN_HANDLED
if (!ValidMessage(said, 1)) return PLUGIN_CONTINUE;
static playerTeam, playerTeamName[19]
playerTeam = get_user_team(id)
switch (playerTeam) {
case 1: copy(playerTeamName, 11, "TR")
case 2: copy(playerTeamName, 18, "CT")
default: copy(playerTeamName, 9, "SPEC")
}
static color[11], name[32], alive[11]
get_user_team(id,color,charsmax(color))
get_user_name(id,name,charsmax(name))
if (is_user_alive (id)) {
alive = ""
} else {
alive = "*MORTO* "
}
if (is_user_admin(id)) {
if (get_user_flags(id) & FLAG_DONO)
format(said, charsmax(said), "^x01%s -%s ^x01[^x03%s^x01] ^x01[^x04%s^x01] ^x03%s: ^x04%s", alive, playerTeam, AD1, Rank[g_rank[id]][Nick], name, said)
else if (get_user_flags(id) & FLAG_MASTER)
format(said, charsmax(said), "^x01%s -%s ^x01[^x03%s^x01] ^x01[^x04%s^x01] ^x03%s: ^x04%s", alive, playerTeam, AD2, Rank[g_rank[id]][Nick], name, said)
else if (get_user_flags(id) & FLAG_SUPREMO)
format(said, charsmax(said), "^x01%s -%s ^x01[^x03%s^x01] ^x01[^x04%s^x01] ^x03%s: ^x04%s", alive, playerTeam, AD3, Rank[g_rank[id]][Nick], name, said)
else if (get_user_flags(id) & FLAG_ADMIN)
format(said, charsmax(said), "^x01%s -%s ^x01[^x03%s^x01] ^x01[^x04%s^x01] ^x03%s: ^x04%s", alive, playerTeam, AD4, Rank[g_rank[id]][Nick], name, said)
else if (get_user_flags(id) & FLAG_VIP)
format(said, charsmax(said), "^x01%s -%s ^x01[^x03%s^x01] ^x01[^x04%s^x01] ^x03%s: ^x04%s", alive, playerTeam, AD5, Rank[g_rank[id]][Nick], name, said)
else if (get_user_flags(id) & FLAG_GIRL)
format(said, charsmax(said), "^x01%s -%s ^x01[^x03%s^x01] ^x01[^x04%s^x01] ^x03%s: ^x04%s", alive, playerTeam, AD6, Rank[g_rank[id]][Nick], name, said)
} else {
format(said, charsmax(said), "^x01%s -%s ^x01(^x04%s^x01) ^x03%s: ^x01%s", alive, playerTeam, Rank[g_rank[id]][Nick], name, said)
}
static i, team[11]
for (i = 1; i <= g_maxplayers; i++) {
if (!is_user_connected(i)) continue;
get_user_name(id,name,charsmax(name))
if (get_user_team(i) == playerTeam || is_user_admin(i)) {
if (is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i)) {
get_user_team(i, team, charsmax(team))
changeTeamInfo(i, color)
writeMessage(i, said)
changeTeamInfo(i, team)
}
}
}
return PLUGIN_HANDLED_MAIN;
}
public changeTeamInfo(player, team[]) {
message_begin(MSG_ONE, g_msgTeamInfo, _, player)
write_byte(player)
write_string(team)
message_end()
}
public writeMessage(player, message[]) {
message_begin(MSG_ONE, g_msgSayText, {0, 0, 0}, player)
write_byte(player)
write_string(message)
message_end()
}
/*==============================================================================================================
==================================================== SALVAR ====================================================
==============================================================================================================*/
Guardar(id)
{
formatex(szKey, charsmax(szKey), "data_ranks")
formatex(szRank, charsmax(szRank), "%d %d", g_frags[id], g_rank[id])
nfv_set_data(VaultRank, szKey, g_playername[id], szRank)
}
Cargar(id) {
new g_load_c1[25], g_load_c2[25]
formatex(szKey, charsmax(szKey), "data_ranks")
if(!nfv_get_data(VaultRank, szKey, g_playername[id], szRank, sizeof(szRank) - 1)) return;
parse(szRank, g_load_c1, charsmax(g_load_c1), g_load_c2, charsmax(g_load_c2))
g_frags[id] = str_to_num(g_load_c1)
g_rank[id] = str_to_num(g_load_c2)
}
/*==============================================================================================================
============================================== VERIFICAR MENSAGEM ==============================================
==============================================================================================================*/
stock ValidMessage(text[], maxcount)
{
static len, i, count
len = strlen(text)
count = 0
if (!len)
return false;
for (i = 0; i < len; i++)
{
if (text[i] != ' ')
{
count++
if (count >= maxcount)
return true;
}
}
return false;
}
stock is_user_admin(id)
{
new __flags=get_user_flags(id);
return (__flags>0 && !(__flags&ADMIN_USER));
}
/*==============================================================================================================
===================================================== COLOR ====================================================
==============================================================================================================*/
stock xClientPrintColor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4")
replace_all(msg, 190, "!n", "^1")
replace_all(msg, 190, "!t", "^3")
if (id) players[0] = id; else get_players(players, count, "ch")
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
write_byte(players[i])
write_string(msg)
message_end()
}
}
}
|
|