|
Junior Member
|

09-13-2012
, 11:32
[HNS MYSQL] Data base Problems
|
#1
|
Here I give you the plugin my question is I have not really understand problems
well as create the database used xampp eh i was learning and
some will create the database tables but I need help
to create the tables below fails to tables.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <fakemeta>
#include <fun>
#include <sqlx>
#define MOD "Mv HNS + XP"
#define HOST ""
#define USER ""
#define PASS ""
#define DB ""
#define MAX_ITEMS 11
#define MAX_LVL 100
#define next_level(%1) (%1 * 15)
#define cost_hp(%1) (100 + g_level[%1])
#define fm_get_user_money(%1) get_pdata_int(%1, 115)
new const sound_level_up[] = { "mv/up.wav" }
new const sound_hh[] = { "sound/mv/hh.mp3" }
new const sound_party[] = { "buttons/bell1.wav" }
new const numeros[][] = { "1", "2" , "3", "4", "5", "6", "7", "8", "9", "0" };
new g_team_names[][] = { "", "TERRORIST", "CT", "SPECTATOR" }
new g_msgTeamInfo, g_msgSayText, g_MsgSync, g_MsgSync2, g_MsgSync3, g_MsgSync4, g_MsgSync5, g_msgMoney, g_maxplayers;
new Handle:g_hTuple
new happyhour_time[2] = { 1, 7 }
new bool:is_happyhour[2]
new HAPPYHOUR_MULTIPLIER
new g_playername[33][32]
new g_password[33][32]
new g_msn[33][32]
new g_registro[33]
new g_level[33], g_frags[33], frags_carn[33]
new create_day[33][11], create_hour[33][11]
new hud_registro[33][200]
new item_name[MAX_ITEMS][32]
new item_cost[MAX_ITEMS]
new item_level[MAX_ITEMS]
new Float:item_time[MAX_ITEMS]
new item_i
new tiempo_jugado[33][3]
new g_matados[33][2]
new g_data[33][3]
new g_items[33]
new g_velocidad[33], g_danio[33], g_leap[33]
new g_Leap_force, g_Leap_height
#define next_point(%1) ((%1 + 1) * 10)
#define porciento_mejora(%1) (%1 * 20)
#define MAX_VIDA 5
#define MAX_DANIO 5
#define MAX_VIDA_M 50
#define MAX_DANIO_M 50
#define MAX_TOP 1010
new const g_top_names[][] =
{
"Nivel",
"M. Knife",
"M. Laser",
"Horas Jugadas"
}
new const g_top_orden[][] =
{
"Niveles",
"M. Knifes",
"M. Lasers",
"T. Jugado"
}
new const g_top_consulta[][] =
{
"lvls",
"mknife",
"mlaser",
"ths"
}
new const g_top_consulta2[][] =
{
"frags",
"mknife",
"mlaser",
"tmin"
}
new const g_top_columna[] =
{
1,
7,
8,
11
}
new g_top[33]
new g_party[33]
new g_combo_party[33]
new g_puntos_vida[33], g_puntos_danio[33], g_puntos[33], g_puntos_g[33]
#define CARNAGE_ROUND 5
new g_round
new g_carnage
#define ITEMS_STARTID g_data[id][0]
#define ITEMS_SELECTION (g_data[id][0]+key)
#define WPN_TOPID g_data[id][1]
#define WPN_MAXTOP g_data[id][2]
enum
{
KNIFE = 0,
LASER
}
enum
{
SEGUNDOS = 0,
MINUTOS,
HORAS
}
enum
{
M_TEAM = 0,
M_REGISTRO
}
enum Color
{
YELLOW = 1,
GREEN,
TEAM_COLOR,
GREY,
RED,
BLUE
}
enum (+= 100)
{
TASK_SHOWHUD = 2000
}
#define ID_SHOWHUD (taskid - TASK_SHOWHUD)
const PEV_SPEC_TARGET = pev_iuser2
const KEYSMENU = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
public plugin_precache()
{
precache_sound(sound_level_up)
precache_generic(sound_hh)
precache_sound(sound_party)
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
}
public plugin_natives()
{
native_items("Granada HE", 3000, 5, 1.0)
native_items("Gravedad", 8000, 10, 15.0)
native_items("Velocidad", 9000, 20, 10.0)
native_items("Extra Damage", 9000, 30, 20.0)
native_items("Pasos Silencios", 5000, 40, 30.0)
native_items("Invisible", 10000, 50, 15.0)
native_items("200 HP", 9500, 60, 1.0)
native_items("AK-47 (3 balas)", 13000, 70, 1.0)
native_items("Salto Largo", 13000, 80, 15.0)
native_items("Respawn", 16000, 90, 1.0)
native_items("Inmunidad", 16000, 100, 5.0)
register_native("hnsxp_frag", "native_hnsxp_frag", 1)
register_native("hnsxp_carnage", "native_hnsxp_carnage", 1)
}
public native_hnsxp_frag(id, amount)
{
if (amount == 1)
g_matados[id][LASER]++
if (g_party[id])
{
static i
for(i = 0; i < 32; i++)
if ((1<<i) & g_party[id])
{
g_combo_party[i+1] += amount * HAPPYHOUR_MULTIPLIER
ColorChat(i+1, BLUE, "^4<Mv>^1 : Combo party ^3%d^1 de ^3%s^1 al terminar la ronda recibe^3 %d%% ^1del combo", g_playername[i+1], g_combo_party[i+1], floatround(porciento_party(i+1)))
client_cmd(i+1, "spk ^"%s^"", sound_party)
}
}
else
g_frags[id] += amount * HAPPYHOUR_MULTIPLIER
check_level(id)
guardar_datos(id)
}
public native_hnsxp_carnage()
{
return g_carnage
}
public plugin_init()
{
g_msgTeamInfo = get_user_msgid("TeamInfo")
g_msgSayText = get_user_msgid("SayText")
register_clcmd("LOGUEAR_PASSWORD", "loguear_password")
register_clcmd("CREAR_PASSWORD", "crear_password")
register_clcmd("CONFIRMAR_PASSWORD", "confirmar_password")
register_clcmd("CAMBIAR_PASSWORD", "cambiar_password")
register_clcmd("CONFIRMAR_NUEVA_PASSWORD", "confirmar_nueva_password")
register_clcmd("CREAR_MSN", "crear_msn")
register_menu("menu registro", KEYSMENU, "registro")
register_menu("menu shop", KEYSMENU, "shop")
register_menu("menu game", KEYSMENU, "game")
register_menu("menu mejoras", KEYSMENU, "mejoras")
register_menu("menu estadisticas", KEYSMENU, "estadisticas")
register_menu("menu top", KEYSMENU, "top")
register_menu("menu party", KEYSMENU, "party")
register_message(get_user_msgid("VGUIMenu"), "vgui")
register_clcmd("jointeam", "change_team")
register_clcmd("chooseteam", "change_team")
register_event("HLTV" , "round_start" , "a", "1=0", "2=0")
register_logevent("round_end", 2, "1=Round_End")
g_Leap_force = register_cvar("zp_zclass_leap_force", "570")
g_Leap_height = register_cvar("zp_zclass_leap_height", "275")
register_clcmd("say", "hook_say")
RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
register_forward(FM_ClientUserInfoChanged, "ClientUserInfoChanged")
register_event("StatusValue", "showStatus", "be", "1=2", "2!0")
register_event("StatusValue", "hideStatus", "be", "1=1", "2=0")
g_MsgSync = CreateHudSyncObj()
g_MsgSync2 = CreateHudSyncObj()
g_MsgSync3 = CreateHudSyncObj()
g_MsgSync4 = CreateHudSyncObj()
g_MsgSync5 = CreateHudSyncObj()
g_maxplayers = get_maxplayers()
g_msgMoney = get_user_msgid("Money")
MySQLx_Init()
g_round = 0
}
public vgui(msg_id, msg_dest, msg_entity)
{
menu_registro(msg_entity)
return PLUGIN_HANDLED
}
public change_team(id)
{
switch (g_registro[id])
{
case M_TEAM: menu_game(id)
case M_REGISTRO: menu_registro(id)
}
return PLUGIN_HANDLED
}
public plugin_end()
{
SQL_FreeHandle(g_hTuple)
}
public client_connect(id)
{
get_user_name(id, g_playername[id], charsmax(g_playername[]))
set_task(1.0, "ShowHUD", id+TASK_SHOWHUD, _, _, "b")
reset_datos(id)
cargar_datos(id)
cargar_cuenta(id)
remove_item(id)
}
public client_disconnect(id)
{
remove_task(id+TASK_SHOWHUD)
reset_datos(id)
clear_registro_HUD(id)
}
public reset_datos(id)
{
g_party[id] = 0
g_combo_party[id] = 0
g_level[id] = 1
g_frags[id] = 0
frags_carn[id] = 0
g_puntos_vida[id] = 0
g_puntos_danio[id] = 0
g_puntos[id] = 0
g_puntos_g[id] = 0
create_day[id][0] = 0
create_hour[id][0] = 0
g_matados[id][KNIFE] = 0
g_matados[id][LASER] = 0
tiempo_jugado[id][SEGUNDOS] = 0
tiempo_jugado[id][MINUTOS] = 0
tiempo_jugado[id][HORAS] = 0
g_registro[id] = M_REGISTRO
client_cmd(id, "setinfo _vgui_menus 1")
}
public ClientUserInfoChanged(id, buffer)
{
if(!is_user_connected(id))
return FMRES_IGNORED;
static newname[32]
engfunc(EngFunc_InfoKeyValue, buffer, "name", newname, charsmax(newname))
get_user_name(id, g_playername[id], charsmax(g_playername[]))
if (equal(newname, g_playername[id]))
{
return FMRES_IGNORED;
}
engfunc(EngFunc_SetClientKeyValue, id, buffer, "name", g_playername[id])
return FMRES_SUPERCEDE;
}
public fw_PlayerSpawn_Post(id)
{
if (!is_user_alive(id) || !cs_get_user_team(id))
return;
if (g_registro[id] != M_TEAM)
{
server_cmd("kick #%d ^"<Mv> Motivo: Intento de bug de cuentas.^"", get_user_userid(id))
}
g_items[id] = 1
fm_set_user_health(id, mejora_vida(id, cost_hp(id)))
set_task(12.0, "check_carnage", id)
}
public check_carnage(id)
{
if (!g_carnage)
return;
set_user_health(id, 100)
fm_strip_user_weapons(id)
give_item(id, "weapon_knife")
give_item(id, "weapon_awp")
cs_set_weapon_ammo(fm_find_ent_by_owner(-1, "weapon_awp", id), 10)
}
public fw_PlayerKilled(victim, attacker, shouldgib)
{
if (victim == attacker || !is_user_connected(attacker))
return;
if (g_carnage)
{
static hh
hh = HAPPYHOUR_MULTIPLIER
frags_carn[attacker] += hh
if (frags_carn[attacker] > 9)
{
g_puntos[attacker] += hh
frags_carn[attacker] = 0
ColorChat(attacker, TEAM_COLOR, "^4<Mv> ^1: Ganaste^3 %d ^1 puntos.", hh)
client_print(attacker, print_center, "Ganaste %d puntos.", hh)
client_cmd(attacker, "mp3 play %s", sound_hh)
}
else
{
ColorChat(attacker, TEAM_COLOR, "^4<Mv> ^1: Ganaste^3 %d ^1 carnage-frags.", hh)
client_print(attacker, print_center, "Tenes %d/10 Carnage-Frags.", frags_carn[attacker])
client_cmd(attacker, "spk ^"%s^"", sound_party)
}
}
else
{
if (g_party[attacker])
{
static i
for(i = 0; i < 32; i++)
if ((1<<i) & g_party[attacker])
{
g_combo_party[i+1] += 1 * HAPPYHOUR_MULTIPLIER
ColorChat(i+1, BLUE, "^4<Mv>^1 : Combo party ^3%d^1 de ^3%s^1 al terminar la ronda recibe^3 %d%% ^1del combo", g_playername[i+1], g_combo_party[i+1], floatround(porciento_party(i+1)))
client_cmd(i+1, "spk ^"%s^"", sound_party)
}
}
else
g_frags[attacker] += 1 * HAPPYHOUR_MULTIPLIER
}
if (get_user_weapon(attacker) == CSW_KNIFE)
g_matados[attacker][KNIFE]++
check_level(attacker)
guardar_datos(attacker)
}
public round_start()
{
static id
for (id = 1; id <= g_maxplayers; id++)
if (g_party[id])
g_combo_party[id] = 0
check_happyhour()
g_round++
g_carnage = 0
if (g_round == CARNAGE_ROUND)
{
g_round = 0
g_carnage = 1
}
}
public round_end()
{
static id
for (id = 1; id <= g_maxplayers; id++)
if (g_party[id])
{
static frags
frags = (g_combo_party[id] / bit_total(g_party[id]))
g_frags[id]+= frags
ColorChat(0, BLUE, "^4<Mv> ^1: Combo party finalizado! Ganas %d frags.", frags)
client_cmd(id, "spk ^"%s^"", sound_party)
check_level(id)
}
}
check_level(id)
{
if (g_level[id] == MAX_LVL)
return
while (g_frags[id] >= next_level(g_level[id]))
{
g_frags[id] = 0
g_level[id]++
ColorChat(0, TEAM_COLOR, "^4<Mv> ^1: El Player^4 %s ^1a subido a nivel^3 %d", g_playername[id], g_level[id])
client_cmd(id, "spk ^"%s^"", sound_level_up)
}
}
check_happyhour()
{
static szhour[4], hour
format_time(szhour, charsmax(szhour), "%H")
hour = str_to_num(szhour)
new start, end
start = happyhour_time[0]
end = happyhour_time[1]
new bool:_hh
while (start != end)
{
if (start == 24)
start = 0
if (start == hour)
{
_hh = true
break;
}
start++
}
if (_hh)
{
if (!is_happyhour[0])
{
is_happyhour[0] = true
ColorChat(0, TEAM_COLOR, "^4<Mv> ^1: Ha comenzado ^3HappyHour^1.")
client_print(0, print_center, "Comenzo la HAPPY-HOUR !!!")
client_cmd(0, "mp3 play %s", sound_hh)
}
else
{
HAPPYHOUR_MULTIPLIER = 2
return;
}
}
else if(happyhour_time[1] == hour)
{
if (!is_happyhour[1])
{
is_happyhour[1] = true
ColorChat(0, TEAM_COLOR, "^4<Mv> ^1: Ha terminado ^3HappyHour^1.")
client_print(0, print_center, "Termino la HAPPY-HOUR !!!")
client_cmd(0, "mp3 play %s", sound_hh)
}
}
HAPPYHOUR_MULTIPLIER = 1
}
public ShowHUD(taskid)
{
static id
id = ID_SHOWHUD;
if (g_registro[id] != M_TEAM)
{
set_hudmessage(0, 0, 250, 0.02, 0.2, 2, 0.1, 10.0, 0.05, 1.0, 1)
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync3, hud_registro[ID_SHOWHUD])
return;
}
if (is_user_connected(id))
{
if (tiempo_jugado[id][SEGUNDOS] > 59)
{
tiempo_jugado[id][SEGUNDOS] = 0
tiempo_jugado[id][MINUTOS]++
}
else
{
tiempo_jugado[id][SEGUNDOS]++
}
if (tiempo_jugado[id][MINUTOS] > 59)
{
tiempo_jugado[id][MINUTOS] = 0
tiempo_jugado[id][HORAS]++
}
}
if (!is_user_alive(id))
{
id = pev(id, PEV_SPEC_TARGET)
if (!is_user_alive(id)) return;
}
static hud[256], len, full[72]
if (g_level[id] == MAX_LVL)
formatex(full, 71, "FULL")
else
formatex(full, 71, "/ %d - Restantes: %d - Completo: %0.2f%%", next_level(g_level[id]), next_level(g_level[id]) - g_frags[id], porciento_nivel(id))
if (id != ID_SHOWHUD)
{
len = 0
len += formatex(hud[len], charsmax(hud) - len, "- Especteando a: %s^n^n- Nivel: %d | Frags: %d %s", g_playername[id], g_level[id], g_frags[id], full)
set_hudmessage(0, 255, 255, 0.02, 0.2, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, hud)
}
else
{
len = 0
set_hudmessage(0, 50, 100, 0.02, 0.8, 0, 1.0, 1.0, 1.0, 1.0)
len = 0
hud[0] = '^0'
for (new i = 0; i < 32; i++)
{
if ((1<<i) & g_party[id])
len += formatex(hud[len], charsmax(hud) - len, "%s - Nivel: %d - Completo: %0.2f%%^n", g_playername[i+1], g_level[i+1], porciento_nivel(i+1));
}
len += formatex(hud[len], charsmax(hud) - len, "^nNivel: %d | Frags: %d %s", g_level[id], g_frags[id], full)
ShowSyncHudMsg(id, g_MsgSync, hud)
if (HAPPYHOUR_MULTIPLIER >= 2)
{
set_hudmessage(0, 50, 100, 0.05, 0.02, 1, 1.0, 1.0, 1.0, 1.0)
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync4, "HappyHour: ganas el doble de frags.")
}
set_hudmessage(255, 0, 0, 0.05, 0.05, g_carnage ? 2 : 1, 1.0, 1.0, 1.0, 1.0)
if (g_carnage)
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync5, "Modo Carnage !!!")
else
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync5, "Modo Carnage: falta %d rondas.", CARNAGE_ROUND - g_round)
}
}
public showStatus(id)
{
if (!is_user_connected(id))
return;
static target
target = read_data(2)
if (!is_user_connected(target))
return;
set_hudmessage(0, 50, 100, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01)
ShowSyncHudMsg(id, g_MsgSync2, "- %s^n- Nivel: %d", g_playername[target], g_level[target])
}
public hideStatus(id)
{
ClearSyncHud(id, g_MsgSync2)
}
clear_registro_HUD(id)
{
ClearSyncHud(id, g_MsgSync3)
hud_registro[id][0] = '^0'
}
public hook_say(id)
{
new say[256], alive
read_args(say, 255)
remove_quotes(say)
alive = !is_user_alive(id)
if(equal(say, ""))
return PLUGIN_HANDLED
if(equal(say, "/shop"))
{
menu_shop(id)
ColorChat(0, BLUE, "^4<Mv> ^1: Escribi ^3/shop^1 para comprar items.")
}
if(equal(say, "/yo"))
{
menu_estadisticas(id)
ColorChat(0, BLUE, "^4<Mv> ^1: Escribi ^3/yo^1 para mirar tus estadisticas.")
}
if(equal(say, "/top"))
{
clcmd_top(id)
ColorChat(0, BLUE, "^4<Mv> ^1: Escribi ^3/top^1 para mirar el top jugadores.")
}
if(contain(say, "happy") != -1)
ColorChat(0, BLUE, "^4<Mv> ^1: la ^3HAPPY-HOUR^1 Comienza a las^4 %d^1 y Termina a las^4 %d^1.", happyhour_time[0], happyhour_time[1])
for(new i = 0; i < sizeof(numeros); i++)
{
if(contain(say, numeros[i]) != -1)
{
ColorChat(id, BLUE, "^4<Mv> ^1: Prohibido los numeros")
return PLUGIN_HANDLED
}
}
switch(cs_get_user_team(id))
{
case CS_TEAM_UNASSIGNED: ColorChat(0, GREY, "^1*MUERTO* ^4[^3%d^4] ^3%s ^1: %s", g_playername[id], say)
case CS_TEAM_T: ColorChat(0, RED, "%s ^4[^3%d^4] ^3%s ^1: %s", alive ? "^1*MUERTO*" : "", g_level[id], g_playername[id], say)
case CS_TEAM_CT: ColorChat(0, BLUE, "%s ^4[^3%d^4] ^3%s ^1: %s", alive ? "^1*MUERTO*" : "", g_level[id], g_playername[id], say)
case CS_TEAM_SPECTATOR: ColorChat(0, GREY, "^1*MUERTO* ^4[^3%d^4] ^3%s ^1: %s", g_playername[id], say)
}
static data[256]
formatex(data, sizeof data - 1, "| %s : %s", g_playername[id], say)
log_to_file("say.log", data)
return PLUGIN_HANDLED
}
public ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
{
static message[256]
switch(type)
{
case YELLOW:
{
message[0] = 01
}
case GREEN:
{
message[0] = 04
}
default:
{
message[0] = 03
}
}
vformat(message[1], 251, msg, 4)
message[192] = '^0'
new team, ColorChange, index, MSG_Type
if(id)
{
MSG_Type = MSG_ONE_UNRELIABLE
index = id
}
else
{
index = FindPlayer()
MSG_Type = MSG_BROADCAST
}
team = get_user_team(index)
ColorChange = ColorSelection(index, MSG_Type, type)
ShowColorMessage(index, MSG_Type, message)
if(ColorChange)
{
Team_Info(index, MSG_Type, g_team_names[team])
}
}
FindPlayer()
{
new i = -1
while(i <= get_maxplayers())
{
if(is_user_connected(++i))
{
return i
}
}
return -1
}
ShowColorMessage(id, type, message[])
{
message_begin(type, g_msgSayText, _, id)
write_byte(id)
write_string(message)
message_end()
}
Team_Info(id, type, team[])
{
message_begin(type, g_msgTeamInfo, _, id)
write_byte(id)
write_string(team)
message_end()
return 1
}
ColorSelection(index, type, Color:Type)
{
switch(Type)
{
case RED:
{
return Team_Info(index, type, g_team_names[1])
}
case BLUE:
{
return Team_Info(index, type, g_team_names[2])
}
case GREY:
{
return Team_Info(index, type, g_team_names[0])
}
}
return 0;
}
stock fm_set_user_health(id, health)
{
(health > 0) ? set_pev(id, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, id);
}
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) {}
return entity;
}
public menu_shop(id)
{
if (!is_user_connected(id))
return;
static menu[400], len, i
len = 0
new money = fm_get_user_money(id);
len += formatex(menu[len], sizeof menu - 1 - len, "\yMenu \rSHOP^n^n")
for (i = ITEMS_STARTID; i < min(ITEMS_STARTID+7, min(ITEMS_STARTID+7, item_i)); i++)
{
if (g_level[id] >= item_level[i])
{
if (g_items[id])
len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s %s[$%d]^n", i-ITEMS_STARTID+1, item_name[i], money >= item_cost[i] ? "\y" : "\r", item_cost[i])
else
len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s^n", i-ITEMS_STARTID+1, item_name[i])
}
else
len += formatex(menu[len], sizeof menu - 1 - len, "\d%d. %s \r(nivel %d)^n", i-ITEMS_STARTID+1, item_name[i], item_level[i])
}
len += formatex(menu[len], sizeof menu - 1 - len, "^n\r8.\w Anterior^n\r9.\w Siguiente ^n^n\r0.\w Salir del menu")
show_menu(id, KEYSMENU, menu, -1, "menu shop")
}
public shop(id, key)
{
if (key >= 7 || ITEMS_SELECTION >= item_i)
{
switch (key)
{
case 7: if (ITEMS_STARTID-7 >= 0) ITEMS_STARTID -= 7
case 8: if (ITEMS_STARTID+7 < item_i) ITEMS_STARTID += 7
case 9: return PLUGIN_HANDLED;
}
menu_shop(id)
return PLUGIN_HANDLED;
}
buy_item(id, ITEMS_SELECTION);
return PLUGIN_HANDLED;
}
buy_item(id, itemid)
{
new money = fm_get_user_money(id)
if (g_carnage)
{
ColorChat(id, GREY, "^4<Mv> ^1: no podes comprar items en ^3CARNAGE^1.")
return;
}
if (!g_items[id])
{
ColorChat(id, TEAM_COLOR, "^4<Mv> ^1: solo podes comprar 1 item por ronda.")
return;
}
if (g_level[id] < item_level[itemid])
{
ColorChat(id, TEAM_COLOR, "^4<Mv> ^1: no tenes suficiente nivel para comprar este item.")
return;
}
if (money < item_cost[itemid])
{
ColorChat(id, TEAM_COLOR, "^4<Mv> ^1: no tenes suficiente plata para comprar este item.")
return;
}
if (itemid != 9)
{
if (!is_user_alive(id))
{
ColorChat(id, TEAM_COLOR, "^4<Mv> ^1: tenes que estar vivo para poder comprar este item.")
return;
}
}
else
{
if (is_user_alive(id))
{
ColorChat(id, TEAM_COLOR, "^4<Mv> ^1: tenes que estar muerto para poder comprar este item.")
return;
}
}
switch (itemid)
{
case 0: give_item(id, "weapon_hegrenade")
case 1: set_pev(id, pev_gravity, 0.1)
case 2: g_velocidad[id] = true
case 3: g_danio[id] = true
case 4: set_user_footsteps(id, 1)
case 5: set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 10)
case 6: set_user_health(id, 200)
case 7:
{
give_item(id, "weapon_ak47")
cs_set_weapon_ammo(fm_find_ent_by_owner(-1, "weapon_ak47", id), 3)
}
case 8: g_leap[id] = true
case 9: ExecuteHamB(Ham_CS_RoundRespawn, id)
case 10: set_user_godmode(id, 1)
}
set_task(Float:item_time[itemid], "remove_item", id)
ColorChat(id, TEAM_COLOR, "^4<Mv> ^1: has comprado ^3%s^1, Recuerda que solo podes comprar 1 item por ronda.", item_name[itemid])
fm_set_user_money(id, money - item_cost[itemid])
g_items[id]--
}
public remove_item(id)
{
set_pev(id, pev_gravity, 1.0)
set_user_godmode(id, 0)
set_user_footsteps(id, 0)
set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 250);
g_velocidad[id] = false
g_danio[id] = false
g_leap[id] = false
}
public fw_PlayerPreThink(id)
{
if (!is_user_alive(id))
return;
if (g_velocidad[id])
set_pev(id, pev_maxspeed, 350.0)
if (allowed_Leap(id))
{
g_leap[id] = true
static Float:velocity[3]
velocity_by_aim(id, get_pcvar_num(g_Leap_force), velocity)
velocity[2] = get_pcvar_float(g_Leap_height)
set_pev(id, pev_velocity, velocity)
}
}
allowed_Leap(id)
{
if (!g_leap[id])
return false
static buttons
buttons = pev(id, pev_button)
if (!(pev(id, pev_flags) & FL_ONGROUND) || fm_get_speed(id) < 20 || !(buttons & IN_JUMP) || !(buttons & IN_DUCK))
return false
return true
}
stock fm_get_speed(entity)
{
static Float:velocity[3]
pev(entity, pev_velocity, velocity)
return floatround(vector_length(velocity))
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
if (!is_user_alive(attacker))
return;
if (g_danio[attacker])
damage *= 3.0
else
damage *= mejora_danio(attacker, 1.0)
SetHamParamFloat(4, damage)
}
native_items(const name[], cost, level, Float:time)
{
if (item_i >= sizeof item_name)
return;
copy(item_name[item_i], sizeof item_name[] - 1, name)
item_cost[item_i] = cost
item_level[item_i] = level
item_time[item_i] = time
item_i++
}
public fm_set_user_money (index, i_Money)
{
set_pdata_int (index, 115, i_Money);
message_begin (MSG_ONE, g_msgMoney, _, index);
write_long (i_Money);
write_byte (1);
message_end ();
}
public MySQLx_Init()
{
g_hTuple = SQL_MakeDbTuple(HOST, USER, PASS, DB)
}
public guardar_datos(id)
{
static szQuery[912];
formatex(szQuery, 911, "REPLACE INTO `mv_datos` (`nick`, `lvls`, `frags`, `pts`, `ptsg`, `mvida`, `mdanio`, `mknife`, `mlaser`, `tseg`, `tmin`, `ths`, `cfrags`) VALUES ('%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d');", g_playername[id], g_level[id], g_frags[id], g_puntos[id], g_puntos_g[id], g_puntos_vida[id], g_puntos_danio[id], g_matados[id][KNIFE], g_matados[id][LASER], tiempo_jugado[id][SEGUNDOS], tiempo_jugado[id][MINUTOS], tiempo_jugado[id][HORAS], frags_carn[id])
SQL_ThreadQuery(g_hTuple, "query_guardar", szQuery)
}
public cargar_datos(id)
{
static szQuery[256], iData[1];
formatex(szQuery, 255, "SELECT * FROM `mv_datos` WHERE (`nick` = '%s');", g_playername[id]);
iData[0] = id;
SQL_ThreadQuery(g_hTuple, "query_load", szQuery, iData, 1);
}
public query_guardar(iFailState, Handle:hQuery, szError[], iError, iData[], iDataSize, Float:fQueueTime)
{
if(iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED)
{
log_amx("%s", szError)
return
}
}
public query_load(iFailState, Handle:hQuery, szError[], iError, iData[], iDataSize, Float:fQueueTime)
{
if(iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED)
{
log_amx("%s", szError)
return
}
else
{
new id = iData[0]
g_level[id] = SQL_ReadResult(hQuery, 1)
g_frags[id] = SQL_ReadResult(hQuery, 2)
g_puntos[id] = SQL_ReadResult(hQuery, 3)
g_puntos_g[id] = SQL_ReadResult(hQuery, 4)
g_puntos_vida[id] = SQL_ReadResult(hQuery, 5)
g_puntos_danio[id] = SQL_ReadResult(hQuery, 6)
g_matados[id][KNIFE] = SQL_ReadResult(hQuery, 7)
g_matados[id][LASER] = SQL_ReadResult(hQuery, 8)
tiempo_jugado[id][SEGUNDOS] = SQL_ReadResult(hQuery, 9)
tiempo_jugado[id][MINUTOS] = SQL_ReadResult(hQuery, 10)
tiempo_jugado[id][HORAS] = SQL_ReadResult(hQuery, 11)
frags_carn[id] = SQL_ReadResult(hQuery, 12)
}
}
public menu_registro(id)
{
static menu[999], len
len = 0
len += formatex(menu[len], sizeof menu - 1 - len, "\w______________________________^n")
len += formatex(menu[len], sizeof menu - 1 - len, "\yBienvenido(a) Usuario^n\y%s \dNuestra Web \rwww.Net4Play.net^n", MOD)
len += formatex(menu[len], sizeof menu - 1 - len, "\w______________________________^n^n")
len += formatex(menu[len], sizeof menu - 1 - len, "\r1.\w LOGEARME^n")
len += formatex(menu[len], sizeof menu - 1 - len, "\r2.\w CREAR CUENTA")
show_menu(id, KEYSMENU, menu, -1, "menu registro")
}
public registro(id, key)
{
switch(key)
{
case 0: check_loguear(id)
case 1: check_crear(id)
}
return PLUGIN_HANDLED
}
public check_crear(id)
{
static query[256], data[1]
formatex(query, 255, "SELECT `cuenta` FROM `mv_cuentas` WHERE ( `cuenta` = '%s' );", g_playername[id])
data[0] = id
SQL_ThreadQuery(g_hTuple, "query_crear", query, data, 1)
}
public query_crear(iFailState, Handle:hQuery, szError[], iError, data[], iDataSize, Float:fQueueTime)
{
if(iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED)
{
log_amx("%s", szError)
return
}
else
{
new id = data[0]
if(SQL_NumResults(hQuery))
{
menu_registro(id)
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "La Cuenta %s^nya existe.", g_playername[id])
}
else
{
client_cmd(id, "messagemode CREAR_PASSWORD")
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "Ingresa una Password^npara tu Cuenta.")
}
}
}
public crear_password(id)
{
new pw[64]
read_args(pw, charsmax(pw))
remove_quotes(pw)
trim(pw)
if(!pw[0])
client_cmd(id, "messagemode CREAR_PASSWORD")
else
{
copy(g_password[id], charsmax(g_password[]), pw)
client_cmd(id, "messagemode CONFIRMAR_PASSWORD")
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "Ingresa nuevamente la password^npara confirmarla.")
}
}
public confirmar_password(id)
{
new pw[64]
read_args(pw, charsmax(pw))
remove_quotes(pw)
trim(pw)
if(!pw[0])
client_cmd(id, "messagemode CREAR_PASSWORD")
else
{
if(equal(pw, g_password[id]))
{
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "Te has registrado.^nTu cuenta es: %s con la passowrd: %s", g_playername[id], g_password[id])
client_cmd(id, "messagemode CREAR_MSN")
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "Es MUY IMPORTANTE que pongas tu mail real^nDe lo contrario no podras recuperar tu cuenta^nPulsando shft+2 aparece la arroba^nPulsando shift+? aparece el guion bajo")
}
else
{
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "Las password^nno coinciden.")
client_cmd(id, "messagemode CREAR_PASSWORD")
menu_registro(id)
}
}
}
public crear_msn(id)
{
new pw[64]
read_args(pw, charsmax(pw))
remove_quotes(pw)
trim(pw)
if(!pw[0])
client_cmd(id, "messagemode CREAR_MSN")
else
{
copy(g_msn[id], charsmax(g_msn[]), pw)
guardar_cuenta(id)
engclient_cmd(id, "jointeam", "5")
engclient_cmd(id, "joinclass", "5")
g_registro[id] = M_TEAM
menu_game(id)
}
}
public guardar_cuenta(id)
{
static szQuery[712], iData[1]
get_time("%d/%m/%Y", create_day[id], charsmax(create_day[]))
get_time("%H:%M:%S", create_hour[id], charsmax(create_hour[]))
formatex(szQuery, 711, "INSERT INTO `mv_cuentas` (`cuenta`, `password`, `msn`, `cday`, `chour`) VALUES('%s', '%s', '%s', '%s', '%s');", g_playername[id], g_password[id], g_msn[id], create_day[id], create_hour[id])
iData[0] = id
SQL_ThreadQuery(g_hTuple, "query_guardar", szQuery)
}
public check_loguear(id)
{
static szQuery[128], iData[1]
formatex(szQuery, 128, "SELECT `password` FROM `mv_cuentas` WHERE ( `cuenta` = '%s' );", g_playername[id])
iData[0] = id
SQL_ThreadQuery(g_hTuple, "query_loguear", szQuery, iData, 1)
}
public query_loguear(iFailState, Handle:hQuery, szError[], iError, iData[], iDataSize, Float:fQueueTime)
{
if(iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED)
{
log_amx("%s", szError)
return
}
else
{
new id = iData[0]
if(SQL_NumResults(hQuery))
password(id)
else
{
menu_registro(id)
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "La Cuenta %s^n no existe.", g_playername[id])
}
}
}
public password(id)
{
static szQuery[256], iData[1]
formatex(szQuery, 255, "SELECT `password` FROM `mv_cuentas` WHERE ( `cuenta` = '%s' );", g_playername[id])
iData[0] = id
SQL_ThreadQuery(g_hTuple, "query_password", szQuery, iData, 1)
}
public query_password(iFailState, Handle:hQuery, szError[], iError, iData[], iDataSize, Float:fQueueTime)
{
if(iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED)
{
log_amx("%s", szError)
return
}
else
{
new id = iData[0]
new ip = SQL_FieldNameToNum(hQuery, "password")
while (SQL_MoreResults(hQuery))
{
SQL_ReadResult(hQuery, ip,g_password[id], charsmax(g_password[]))
SQL_NextRow(hQuery)
}
client_cmd(id, "messagemode LOGUEAR_PASSWORD")
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "Ingresa la Password^nde tu Cuenta.")
}
}
public loguear_password(id)
{
new pass[64]
read_args(pass, charsmax(pass))
remove_quotes(pass)
trim(pass)
if(!pass[0])
client_cmd(id, "messagemode LOGUEAR_PASSWORD")
else
{
if(equal(pass, g_password[id]))
{
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "Te has logueado.^nTu cuenta es: %s.", g_playername[id])
engclient_cmd(id, "jointeam", "5")
engclient_cmd(id, "joinclass", "5")
g_registro[id] = M_TEAM
menu_game(id)
}
else
{
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "La password es incorrecta.^ntu cuenta es: %s", g_playername[id])
menu_registro(id)
}
}
}
public cambiar_password(id)
{
new npw[64]
read_args(npw, charsmax(npw))
remove_quotes(npw)
trim(npw)
if(!npw[0])
client_cmd(id, "messagemode CAMBIAR_PASSWORD")
else
{
copy(g_password[id], charsmax(g_password[]), npw)
client_cmd(id, "messagemode CONFIRMAR_NUEVA_PASSWORD")
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "Ingresa la nueva password.^npara confirmarla")
}
}
public confirmar_nueva_password(id)
{
new npw[64]
read_args(npw, charsmax(npw))
remove_quotes(npw)
trim(npw)
if(!npw[0])
client_cmd(id, "messagemode CAMBIAR_PASSWORD")
else
{
if(equal(npw, g_password[id]))
check_npassword(id)
else
{
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "Las passwords no coinciden.")
menu_game(id)
}
}
}
public check_npassword(id)
{
static szQuery[256], iData[1]
formatex(szQuery, 255, "UPDATE `mv_cuentas` SET `password` = '%s' WHERE ( `cuenta` = '%s' );", g_password[id], g_playername[id])
iData[0] = id
SQL_ThreadQuery(g_hTuple, "query_npassword", szQuery)
}
public query_npassword(iFailState, Handle:hQuery, szError[], iError, iData[], iDataSize, Float:fQueueTime)
{
if(iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED)
{
log_amx("%s", szError)
return
}
else
{
new id = iData[0]
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "Has cambiado tu password.^nTu password actual es: %s", g_password[id])
menu_game(id)
}
}
public cargar_cuenta(id)
{
static szQuery[256], iData[1]
formatex(szQuery, 255, "SELECT `cday`, `chour` FROM `mv_cuentas` WHERE ( `cuenta` = '%s' );", g_playername[id])
iData[0] = id
SQL_ThreadQuery(g_hTuple, "query_data", szQuery, iData, 1)
}
public query_data(iFailState, Handle:hQuery, szError[], iError, iData[], iDataSize, Float:fQueueTime)
{
if(iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED)
{
log_amx("%s", szError)
return
}
else
{
new id = iData[0]
new icday = SQL_FieldNameToNum(hQuery, "cday")
new ichour = SQL_FieldNameToNum(hQuery, "chour")
while (SQL_MoreResults(hQuery))
{
SQL_ReadResult(hQuery, icday, create_day[id], charsmax(create_day[]))
SQL_ReadResult(hQuery, ichour, create_hour[id], charsmax(create_hour[]))
SQL_NextRow(hQuery)
}
}
}
public menu_game(id)
{
static menu[999], len
len = 0
new day[10], hour[10]
get_time("%d/%m", day, charsmax(day))
get_time("%H:%M", hour, charsmax(hour))
len += formatex(menu[len], sizeof menu - 1 - len, "\w______________________________^n")
len += formatex(menu[len], sizeof menu - 1 - len, "\ywww.Net4Play.net ^n\y%s ^n", MOD)
len += formatex(menu[len], sizeof menu - 1 - len, "\w______________________________^n^n")
len += formatex(menu[len], sizeof menu - 1 - len, "\r-\w La Fecha actual es \y%s %s^n^n", hour, day)
len += formatex(menu[len], sizeof menu - 1 - len, "%s Menu SHOP^n", g_carnage ? "\d1." : "\r1.\w")
len += formatex(menu[len], sizeof menu - 1 - len, "\r2.\w Estadisticas^n")
len += formatex(menu[len], sizeof menu - 1 - len, "\r3.\w Cambiar Password^n")
len += formatex(menu[len], sizeof menu - 1 - len, "\r4.\w Mejoras^n")
//len += formatex(menu[len], sizeof menu - 1 - len, "\r5.\w PARTY \r(BETA)^n")
len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r0.\w Salir del Menu")
show_menu(id, KEYSMENU, menu, -1, "menu game")
}
public game(id, key)
{
switch (key)
{
case 0: menu_shop(id)
case 1: menu_estadisticas(id)
case 2:
{
client_cmd(id, "messagemode CAMBIAR_PASSWORD")
clear_registro_HUD(id)
formatex(hud_registro[id], charsmax(hud_registro[]), "Ingresa la nueva password.^nTu password actual es: %s", g_password[id])
}
case 3: menu_mejoras(id)
//case 4: menu_party(id)
case 4..8: menu_game(id)
}
return PLUGIN_HANDLED;
}
public Float:porciento_nivel(id)
{
new Float:number
number = ((g_frags[id] * 100.0) / next_level(g_level[id]))
return number
}
public menu_lvls(id)
{
new niveles[50], Posicion[10]
new menu = menu_create("\yLista de Niveles", "lvls")
for(new i = 1; i < MAX_LVL + 1; i++)
{
formatex(niveles, charsmax(niveles), "\wNivel %d \d|%s Frags: %d", i, g_level[id] >= i ? "\y" : "\r", next_level(i))
num_to_str(i, Posicion, charsmax(Posicion))
menu_additem(menu, niveles, Posicion)
}
menu_setprop(menu, MPROP_BACKNAME, "Anterior")
menu_setprop(menu, MPROP_NEXTNAME, "Siguiente")
menu_setprop(menu, MPROP_EXITNAME, "Salir del Menu")
menu_display(id, menu, 0)
return PLUGIN_HANDLED;
}
public lvls(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], iName[64], access, callback
menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)
switch(str_to_num(data))
{
case 0..MAX_LVL: menu_lvls(id)
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
stock fm_strip_user_weapons(id)
{
static ent
ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"))
if (!pev_valid(ent)) return;
dllfunc(DLLFunc_Spawn, ent)
dllfunc(DLLFunc_Use, ent, id)
engfunc(EngFunc_RemoveEntity, ent)
}
public menu_mejoras(id)
{
static menu[999], len
len = 0
len += formatex(menu[len], sizeof menu - 1 - len, "\yMenu de mejoras^n^n\yTenes \w%d \ypuntos para gastar^n", g_puntos[id])
len += formatex(menu[len], sizeof menu - 1 - len, "\yGanaras tu proximo punto al matar en \rCARNAGE^n^n")
if (g_puntos_vida[id] >= MAX_VIDA)
len += formatex(menu[len], sizeof menu - 1 - len, "\r1.\d Aumentar vida (%d) (MAX) (\w%d%%\d)^n", g_puntos_vida[id], porciento_mejora(g_puntos_vida[id]))
else
{
if (g_puntos[id] >= next_point(g_puntos_vida[id]))
len += formatex(menu[len], sizeof menu - 1 - len, "\r1.\w Aumentar vida \d(\y%d\d) \d(\y%d puntos\d) (\w%d%%\d)^n", g_puntos_vida[id], next_point(g_puntos_vida[id]), porciento_mejora(g_puntos_vida[id]))
else
len += formatex(menu[len], sizeof menu - 1 - len, "\r1.\d Aumentar vida (%d) (\r%d puntos\d) (\w%d%%\d)^n", g_puntos_vida[id], next_point(g_puntos_vida[id]), porciento_mejora(g_puntos_vida[id]))
}
if (g_puntos_danio[id] >= MAX_DANIO)
len += formatex(menu[len], sizeof menu - 1 - len, "\r2.\d Aumentar danio (%d) (MAX) (\w%d%%\d)^n", g_puntos_danio[id], porciento_mejora(g_puntos_danio[id]))
else
{
if (g_puntos[id] >= next_point(g_puntos_danio[id]))
len += formatex(menu[len], sizeof menu - 1 - len, "\r2.\w Aumentar danio \d(\y%d\d) \d(\y%d puntos\d) (\w%d%%\d)^n", g_puntos_danio[id], next_point(g_puntos_danio[id]), porciento_mejora(g_puntos_danio[id]))
else
len += formatex(menu[len], sizeof menu - 1 - len, "\r2.\d Aumentar danio (%d) (\r%d puntos\d) (\w%d%%\d)^n", g_puntos_danio[id], next_point(g_puntos_danio[id]), porciento_mejora(g_puntos_danio[id]))
}
len += formatex(menu[len], sizeof menu - 1 - len, "^n\r8.%s Reestablecer mejoras^n", g_puntos_g[id] ? "\w" : "\d")
len += formatex(menu[len], sizeof menu - 1 - len, "\r0.\w Salir del menu")
show_menu(id, KEYSMENU, menu, -1, "menu mejoras")
}
public mejoras(id, key)
{
switch (key)
{
case 0:
{
if (g_puntos_vida[id] >= MAX_VIDA)
{
menu_mejoras(id)
return PLUGIN_HANDLED;
}
if (g_puntos[id] >= next_point(g_puntos_vida[id]))
{
g_puntos_g[id] += next_point(g_puntos_vida[id])
g_puntos[id] -= next_point(g_puntos_vida[id])
g_puntos_vida[id]++
menu_mejoras(id)
}
else
menu_mejoras(id)
}
case 1:
{
if (g_puntos_danio[id] >= MAX_DANIO)
{
menu_mejoras(id)
return PLUGIN_HANDLED;
}
if (g_puntos[id] >= next_point(g_puntos_danio[id]))
{
g_puntos_g[id] += next_point(g_puntos_danio[id])
g_puntos[id] -= next_point(g_puntos_danio[id])
g_puntos_danio[id]++
menu_mejoras(id)
}
else
menu_mejoras(id)
}
case 2..6: menu_mejoras(id)
case 7:
{
if (g_puntos_g[id] > 0)
{
g_puntos_danio[id] = 0
g_puntos_vida[id] = 0
g_puntos[id] += g_puntos_g[id]
g_puntos_g[id] = 0
menu_mejoras(id)
}
else
menu_mejoras(id)
}
case 8: menu_mejoras(id)
}
return PLUGIN_HANDLED;
}
mejora_vida(id, base)
{
new total = (MAX_VIDA_M * base) / 100
total = total / MAX_VIDA
total = base + total * g_puntos_vida[id]
return total
}
Float:mejora_danio(id, Float:base)
{
new Float:total = (MAX_DANIO_M * base) / 100.0
total = total / MAX_DANIO
total = base + (total * g_puntos_danio[id])
return total
}
public menu_estadisticas(id)
{
static menu[999], len
len = 0
new horas, minutos
horas = tiempo_jugado[id][HORAS]
minutos = tiempo_jugado[id][MINUTOS]
len += formatex(menu[len], sizeof menu - 1 - len, "\yEstadisticas de jugador^n^n")
len += formatex(menu[len], sizeof menu - 1 - len, "\yAlias: \w%s^n", g_playername[id])
len += formatex(menu[len], sizeof menu - 1 - len, "\yFrags: \w%d \y(\w%d%%\y)^n", g_frags[id], floatround(porciento_nivel(id)))
len += formatex(menu[len], sizeof menu - 1 - len, "\yFrags para proximo nivel: \w%d^n", next_level(g_level[id]) - g_frags[id])
len += formatex(menu[len], sizeof menu - 1 - len, "\yCarnage-Frags: \w%d / 10^n", frags_carn[id])
len += formatex(menu[len], sizeof menu - 1 - len, "\yPuntos: \w%d^n", g_puntos[id])
len += formatex(menu[len], sizeof menu - 1 - len, "\yDanio: \w%d %d%% \yVida: \w%d %d%% ^n", g_puntos_danio[id], porciento_mdanio(id), g_puntos_vida[id], porciento_mvida(id))
len += formatex(menu[len], sizeof menu - 1 - len, "\yM. Knife: \w%d \yM. Laser: \w%d^n", g_matados[id][KNIFE], g_matados[id][LASER])
len += formatex(menu[len], sizeof menu - 1 - len, "\ySos miembro desde el \w%s %s^n", create_day[id], create_hour[id])
len += formatex(menu[len], sizeof menu - 1 - len, "\yJugaste durante \w%s%d horas %s%d minutis^n^n", horas > 9 ? "" : "0", horas, minutos > 9 ? "" : "0", minutos)
len += formatex(menu[len], sizeof menu - 1 - len, "\r1.\w Lista de niveles^n")
len += formatex(menu[len], sizeof menu - 1 - len, "\r2.\w Lista de Top jugadores^n^n")
len += formatex(menu[len], sizeof menu - 1 - len, "\r0.\w Salir")
show_menu(id, KEYSMENU, menu, -1, "menu estadisticas")
}
public estadisticas(id, key)
{
switch(key)
{
case 0: menu_lvls(id)
case 1: clcmd_top(id)
}
return PLUGIN_HANDLED
}
public clcmd_top(id)
{
static szQuery[256], iData[1]
formatex(szQuery, 255, "SELECT * FROM `mv_datos` ORDER BY `%s` DESC, `%s` DESC LIMIT %d", g_top_consulta[g_top[id]], g_top_consulta2[g_top[id]], MAX_TOP)
iData[0] = id
SQL_ThreadQuery(g_hTuple, "menu_top", szQuery, iData, 1)
return PLUGIN_CONTINUE;
}
public menu_top(iFailState, Handle:hQuery, szError[], iError, iData[], iDataSize, Float:fQueueTime)
{
if(iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED)
{
log_amx("%s", szError)
return
}
else
{
new id = iData[0]
if(SQL_NumResults(hQuery))
{
new menu[1750], len, weap, maxloops, cuenta[33]
len = 0
maxloops = min(WPN_TOPID+10, SQL_NumResults(hQuery))
WPN_MAXTOP = SQL_NumResults(hQuery)
len += formatex(menu[len], sizeof menu - 1 - len, "\yLista Top Jugadores^n^n")
weap = WPN_TOPID
for(new i = 0;i < weap;i++)
SQL_NextRow(hQuery)
while(SQL_MoreResults(hQuery))
{
if(weap < maxloops)
{
SQL_ReadResult(hQuery, 0, cuenta, 32)
weap++
len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\y %s \w%s: \r%d^n", weap, cuenta, g_top_names[g_top[id]], SQL_ReadResult(hQuery, g_top_columna[g_top[id]]))
SQL_NextRow(hQuery)
}
else
break;
}
len += formatex(menu[len], sizeof menu - 1 - len, "^n\r7.\w Ordenar por \y[%s]^n^n", (g_top[id] > 2) ? (g_top_orden[0]) : (g_top_orden[(g_top[id])]))
len += formatex(menu[len], sizeof menu - 1 - len, "\r8.\w Anterior^n")
len += formatex(menu[len], sizeof menu - 1 - len, "\r9.\w Siguiente^n")
len += formatex(menu[len], sizeof menu - 1 - len, "\r0.\w Salir")
show_menu(id, KEYSMENU, menu, -1, "menu top")
}
}
return
}
public top(id, key)
{
switch(key)
{
case 6: (g_top[id] > 2) ? (g_top[id] = 0) : (g_top[id] += 1)
case 7: ((WPN_TOPID - 10) < 0) ? (WPN_TOPID = 0) : (WPN_TOPID -= 10)
case 8: ((WPN_TOPID + 10) >= WPN_MAXTOP) ? (WPN_TOPID) : (WPN_TOPID += 10)
case 9: return PLUGIN_HANDLED
}
clcmd_top(id)
return PLUGIN_HANDLED
}
public menu_party(id)
{
static Menu[999], iLen
iLen = 0
iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "\yMenu \rPARTY \d(BETA)^n^n")
iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "\d--------------------^n^n")
if (g_party[id])
{
for (new i = 0; i < 32; i++)
if ((1<<i) & g_party[id])
iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "\r- \w%s^n", g_playername[i+1]);
}
else
{
iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "\dNo estas en party^n");
}
iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "^n\d--------------------^n^n")
if (g_party[id])
{
iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "\r5.\w Invitar al Party^n")
iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "\r6.\w Salir del Party^n")
}
else
{
iLen += formatex(Menu[iLen], sizeof Menu - 1 - iLen, "\r5.\w Crear Party^n")
}
show_menu(id, KEYSMENU, Menu, -1, "menu party")
}
public party(id, key)
{
switch (key)
{
case 0..3: menu_party(id)
case 4: form_party(id)
case 5:
{
if (g_party[id])
remove_from_team(id)
}
case 6..8: menu_party(id)
case 9: return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public form_party(id)
{
new target, body
get_user_aiming(id, target, body)
if (is_user_connected(target))
{
if (g_party[target])
{
client_print(id, print_center, "%s ya esta en party", g_playername[target])
}
else
{
client_print(id, print_center, "Has invitado a %s", g_playername[target])
add_to_team(id, target)
}
}
else
{
client_print(id, print_center, "No estas apuntando a nadie")
}
menu_party(id)
}
add_to_team(id, player)
{
new buffer[64];
format(buffer, charsmax(buffer), "PARTY: Invitacion de %s", g_playername[id]);
new menu = menu_create(buffer, "confirm_handle");
new tinybuff[3];
tinybuff[0] = 1;
tinybuff[1] = id;
tinybuff[2] = 0;
menu_additem(menu, "Aceptar", tinybuff);
tinybuff[2] = 1;
menu_additem(menu, "Cancelar", tinybuff);
menu_display(player, menu, 0);
}
public remove_from_team(id)
{
new menu = menu_create("PARTY: Salir del party ?", "confirm_handle");
new tinybuff[3];
tinybuff[0] = 0;
tinybuff[1] = id;
tinybuff[2] = 0;
menu_additem(menu, "Aceptar", tinybuff);
tinybuff[2] = 1;
menu_additem(menu, "Cancelar", tinybuff);
menu_display(id, menu, 0);
}
public confirm_handle(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[4];
new access, callback, key, team;
menu_item_getinfo(menu, item, access, data, charsmax(data), _, _, callback);
team = data[1];
key = data[2];
if (data[0] == 1)
{
if (key == 0)
{
new lineup = g_party[team];
lineup |= (1<<(id-1));
for(new i = 0; i < 32; i++)
{
if ((1<<i) & lineup)
{
g_party[i+1] = lineup;
if (g_party[i+1] == 1)
menu_confirm(team)
}
}
}
else client_print(team, print_center, "%s Cancelo la invitacion", g_playername[id]);
}
else
{
if (key == 0)
remove_team(id);
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
menu_confirm(id)
{
new Name[33], menu[128], menuid
get_user_name(id, Name , 32)
formatex(menu, charsmax(menu), "PARTY: ah sido creado")
menuid = menu_create(menu, "confirmt")
formatex(menu, charsmax(menu), "\yContinuar")
menu_additem(menuid, menu, "7")
menu_display(id, menuid)
}
remove_team(id)
{
new lineup = g_party[id];
g_party[id] = 0;
lineup &= ~(1<<(id-1));
for(new i = 0; i < 32; i++)
if ((1<<i) & lineup)
g_party[i+1] = lineup;
}
bit_total(value)
{
static total, i; total = 0;
for (i = 0; i < 32; i++)
if ((1<<i) & value) total++;
return total;
}
public Float:porciento_party(id)
{
new Float:number
number = (100.0 / bit_total(g_party[id]))
return number
}
porciento_mvida(id)
{
return g_puntos_vida[id] * MAX_VIDA_M / MAX_VIDA
}
porciento_mdanio(id)
{
return g_puntos_danio[id] * MAX_DANIO_M / MAX_DANIO
}
Well here are the tables but my question is that as all the tables are called
but be filled nose as the other do not quite understand why this question is the
I need that I have to explain a bit.
(`nick`, `lvls`, `frags`, `pts`, `ptsg`, `mvida`, `mdanio`, `mknife`, `mlaser`, `tseg`, `tmin`, `ths`, `cfrags`) esas son las tablas del hns
[IMG]http://**************/photo/my-images/651/sinttuloqjv.png[/IMG]
Last edited by iTzLeandro; 09-13-2012 at 12:34.
|
|