01/02/2021, 08:40 PM
Buenas noches chicos, estoy aprendiendo pawn basico y quisiera que me ayudaran a colocarle al menu de natives de skylar que tenga niveles, osea las armas bloqueadas por levels, estuve leyendo la guia de Blackfur y intentando pero no logro entender.
Este es el code de los rangos
Código PHP:
#include <amxmodx>
#include <cstrike>
#include <TiendaNatives>
#include <ColorChat>
#define gPlugin "Tienda[Natives]"
#define Prefix "[Preegamer]"
enum _:DATA_TIENDA {
NOMBRE[20],
PRECIO
}
new const ItemsTienda[][DATA_TIENDA] = {
{"Gatling", 4000},
{"Plasma-Gun", 5000},
{"Balrog-III", 8000},
{"Ak47 GOLDEN", 10000},
{"Ak PALADIN", 12000},
{"Dual Uzi", 1000}
}
public plugin_init() {
/* = Plugin = */
register_plugin(gPlugin, "1.0", "Skylar")
/* = Clcmd = */
register_clcmd("nightvision", "menu_tienda")
}
public menu_tienda(id) {
new i, menu, text[100]
menu = menu_create("\r[\wPreegamer\r] \d-.::\wArmas Especiales\d::.", "handler_tienda")
for(i = 0; i < sizeof(ItemsTienda); i++) {
if(cs_get_user_money(id) < ItemsTienda[i][PRECIO]) {
formatex(text, charsmax(text), "\d%s \r[ $%d ]", ItemsTienda[i][NOMBRE], ItemsTienda[i][PRECIO])
} else {
formatex(text, charsmax(text), "\w%s \y[ $%d ]", ItemsTienda[i][NOMBRE], ItemsTienda[i][PRECIO])
}
menu_additem(menu, text, _, _, menu_makecallback("tienda_callback"))
}
menu_display(id, menu)
}
public tienda_callback(id, menu, item) {
if(cs_get_user_money(id) < ItemsTienda[item][PRECIO])
return ITEM_DISABLED;
return ITEM_ENABLED;
}
public handler_tienda(id, menu, item) {
if(item == MENU_EXIT)
return PLUGIN_HANDLED;
switch(item) {
case 0: tienda_gatling(id);
case 1: tienda_plasma(id);
case 2: tienda_balrog(id);
case 3: tienda_akgolden(id);
case 4: tienda_akpaladin(id);
case 5: tienda_uzi(id);
}
cs_set_user_money(id, cs_get_user_money(id) - ItemsTienda[item][PRECIO], 1)
ColorChat(id, GREEN, "%s^1 Compraste:^4 %s.", Prefix, ItemsTienda[item][NOMBRE])
return PLUGIN_HANDLED;
}
Este es el code de los rangos
Código PHP:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
#define level_up(%1) (%1 * %1 * 10)
new g_level[33]
new g_exp[33]
new g_rangos[33]
enum _:Info_Rangos
{
RangosName[33],
RangosNivel
}
new const Rangos[][Info_Rangos] = {
{ "[Sin Rango]", 25 },
{ "[Bronce I]", 70},
{ "[Bronce II]", 120 },
{ "[Bronce III]", 175 },
{ "[Plata I]", 250 },
{ "[Plata II]", 370 },
{ "[Plata III]", 500 },
{ "[Oro I]", 700 },
{ "[Oro II]", 750 },
{ "[Oro III]", 890 },
{ "[Oro IV]", 980},
{ "[Platino I]", 1300 },
{ "[Platino II]", 1600 },
{ "[Platino Platino III]", 1900 },
{ "[Platino IV]", 2000},
{ "[Diamante I]", 2500},
{ "[Diamante II]", 3000},
{ "[Diamante III]", 3200},
{ "[Diamante IV]", 3500},
{ "[Heroico]", 4000},
{ "[Gran Maestro]", 5000},
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_Killed, "player", "fw_playerkilled_post", 1)
}
public client_putinserver(id)
{
set_task(2.0,"hud",id,_,_,"b")
}
public hud(id)
{
new CurrentTime[9]
get_time("%H:%M:%S",CurrentTime,8)
set_hudmessage(255, 0, 0, 0.0, 0.0, 0, 6.0, 12.0)
show_hudmessage(id, "[Nivel] : %d^n[Rango] : %s^n[Experiencia] : %d^n[Hora] : %s", g_level[id], Rangos[g_rangos[id]][RangosName], g_exp[id], CurrentTime)
}
public fw_playerkilled_post(victim, attacker)
{
if(!is_user_connected(attacker))
return HAM_IGNORED;
if(victim == attacker)
return HAM_IGNORED;
g_exp[attacker] += 10
level(attacker)
return HAM_IGNORED;
}
public level(id)
{
while(g_exp[id] >= level_up(g_level[id]) && g_level[id] < 100)
{
g_level[id]++
ChatColor(id, "!g[VZG] !ySubiste al nivel %d", g_level[id])
rangos(id)
}
}
public rangos(id)
{
if (g_level[id] >= Rangos[g_rangos[id] + 1][RangosNivel] && g_rangos[id] < 9)
{
g_rangos[id]++
ChatColor(id, "!g[VZG] !ySubiste al rango !g%s", Rangos[g_rangos[id]][RangosName])
}
}
stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4") // Green Color
replace_all(msg, 190, "!y", "^1") // Default Color
replace_all(msg, 190, "!team", "^3") // Team Color
replace_all(msg, 190, "!team2", "^0") // Team2 Color
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();
}
}
}
}