hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2025.08.16. 01:52



Jelenlévő felhasználók

Jelenleg 350 felhasználó van jelen :: 1 regisztrált, 0 rejtett és 349 vendég

A legtöbb felhasználó (2883 fő) 2025.07.30. 16:00-kor tartózkodott itt.

Regisztrált felhasználók: Google [Bot]az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása Hozzászólás a témához  [33 hozzászólás ]  OldalElőző1234Következő
Szerző Üzenet
 Hozzászólás témája: Re: Rpg mod
HozzászólásElküldve:2012.04.25. 13:06 
Offline
Beavatott

Csatlakozott:2012.04.12. 16:22
Hozzászólások:87
Megköszönték neki: 1 alkalommal
na akkor most mit csináljak?


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Rpg mod
HozzászólásElküldve:2012.04.25. 14:18 
Offline
Beavatott

Csatlakozott:2012.04.12. 16:22
Hozzászólások:87
Megköszönték neki: 1 alkalommal
na mondja már el valaki a legegyszerűbb módszert


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Rpg mod
HozzászólásElküldve:2012.04.25. 14:25 
Offline
Őskövület
Avatar

Csatlakozott:2012.02.07. 23:34
Hozzászólások:2192
Megköszönt másnak: 27 alkalommal
Megköszönték neki: 55 alkalommal
Megkeresed a plugint amit használsz. A .SMA fájl -t ide feltöltöd vagy kimásolod és beilleszted.

_________________
[sma]CMD:fear(playerid, params[]){ new str[5]; if(!sscanf(params, "s[5]", str)){ if(egyezik(str, "find")) Msg(playerid, "A-a!");}  return 1;}[/sma]


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Rpg mod
HozzászólásElküldve:2012.04.25. 14:33 
Offline
Beavatott

Csatlakozott:2012.04.12. 16:22
Hozzászólások:87
Megköszönték neki: 1 alkalommal
próbáltam és 87000 valamennyi karakter és nem engedte,feltölteni meg nem tudom hogy kell ami ezen az oldalon van fent rpg mod nével azt használom.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Rpg mod
HozzászólásElküldve:2012.04.25. 14:44 
Offline
Imperátor
Avatar

Csatlakozott:2009.04.21. 09:33
Hozzászólások:3991
Megköszönt másnak: 5 alkalommal
Megköszönték neki: 135 alkalommal
Felezd ketté :)

csak írta:
próbáltam és 87000 valamennyi karakter és nem engedte,feltölteni meg nem tudom hogy kell ami ezen az oldalon van fent rpg mod nével azt használom.

_________________
Kód:
I'm back

Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Rpg mod
HozzászólásElküldve:2012.04.25. 14:54 
Offline
Beavatott

Csatlakozott:2012.04.12. 16:22
Hozzászólások:87
Megköszönték neki: 1 alkalommal
Kód:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <fun>
#include <cstrike>
#include <nvault>
#include <sqlx>


#define VERSION "1.0b3"


#define MAX_PLAYERS 32
#define UPDATE_INTERVAL 0.1   //do not modify
#define TID_TIMER 3536

#define MAX_LVL 50000

#define MAX_XP_MULTI 10000.0

#define MAX_UPGS 12
#define UPG_REGEN 0
#define UPG_HEALTH 1
#define UPG_RESUP 2
#define UPG_VAMP 3
#define UPG_STEALTH 4
#define UPG_LJ 5
#define UPG_ICESTAB 6
#define UPG_FROST 7
#define UPG_DENIAL 8
#define UPG_IMPULSE 9
#define UPG_MEDIC 10
#define UPG_BHOP 11

#define DENIAL_BLOCK -3
#define DENIAL_NEXT_SPAWN -4
#define DENIAL_START 10
#define DENIAL_STRIP 8
#define DENIAL_GIVE 7

#define CREDITS_PER_LVL 5

#define CXT_KILL 0  //arg1: attacker, arg2: victim
#define CXT_DMG 1  //arg1: attacker, arg2: victim, arg3: dmg_amount

#define XP_START 600
#define XP_INC 5

#define DATA_NOT_LOADED 0
#define DATA_NOT_FOUND 1
#define DATA_LOADED 2
#define DATA_LOADING 3

#define SAVEBY_STEAMID 1
#define SAVEBY_IP 2
#define SAVEBY_NAME 3
#define SAVEBY_LOGIN 4  //special case (g_saveby is never equal 4)
#define SAVEBY_BOT 5    //special case (g_saveby is never equal 5)

#define SAVEDB_NVAULT 1
#define SAVEDB_MYSQL 2

#define REG_NONE 1
#define REG_TRY 2
#define REG_DONE 3

#define DB_NONE 0
#define DB_CONNECTING 1
#define DB_READY 2

#define LOGIN_COOLDOWN 10.0

#define FREQ_S_NONE 0
#define FREQ_S_NEW_ROUND 1
#define FREQ_S_INTERVAL 2

#define MAX_SETTINGS 2
#define SETT_MENU_ON_SPAWN 0
#define SETT_INFO_UNDER_CHAT 1


new g_max_players
new Float:g_t_time
new g_timer_entid


new Float:g_p_login_time[MAX_PLAYERS+1]
new g_p_xp[MAX_PLAYERS+1]
new g_p_temp_xp[MAX_PLAYERS+1] //xp gained since last save
new g_p_credits[MAX_PLAYERS+1]
new g_p_upg[MAX_PLAYERS+1][MAX_UPGS]
new g_p_level[MAX_PLAYERS+1]
new g_p_progress[MAX_PLAYERS+1]

new g_p_menu_page[MAX_PLAYERS+1]
new g_p_team[MAX_PLAYERS+1]

new g_p_settings[MAX_PLAYERS+1][MAX_SETTINGS]
new g_settings_maxval[MAX_SETTINGS] = {1, 1}
new g_settings_default[MAX_SETTINGS+1] = "11"
new bool:g_p_authorized[MAX_PLAYERS+1]

new bool:g_upg_enabled[MAX_UPGS]
new g_enabled_upgs
new g_enabled_list[MAX_UPGS]
new g_upg_name[MAX_UPGS][32] = {"Regenera'cio'", "E'let+", "tolte'ny uta'npo'tla's", "Ve'rsziva's", "A'tla'tszo'sa'g",
    "Hoszu' ugra's", "Dermeszto csapa's", "Fagyaszto lovede'kek", "Ragaszkoda's", "Impulzus", "Medikus", "Bunnyhop" }
new g_upg_sp[MAX_UPGS] = {20,30,10,60,30,30,110,5,100,40,20,100}
new g_upg_ip[MAX_UPGS] = {25,35,5,25,25,25,90,5,5,25,5,900}
new g_upg_maxlvl[MAX_UPGS] = {10, 10, 10, 15, 5, 5, 3, 15, 1, 5, 15, 2}

new g_p_sm_upg[MAX_PLAYERS+1][MAX_UPGS] //list of upgs displayed in sell menu
new g_p_sm_upg_cnt[MAX_PLAYERS+1] //amount of upgs on the list

new g_max_bpammo[33] = {0,52,0,90,1,32,1,100,90,1,120,100,100,90,90,90,100,120,30,120,200,32,90,120,90,2,35,90,90,0,100,0,0}
new g_gi_names[32][32] = {"", "weapon_p228", "", "weapon_scout", "weapon_hegrenade",
"weapon_xm1014", "weapon_c4", "weapon_mac10", "weapon_aug", "weapon_smokegrenade", "weapon_elite",
"weapon_fiveseven", "weapon_ump45", "weapon_sg550", "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18",
"weapon_awp", "weapon_mp5navy", "weapon_m249", "weapon_m3", "weapon_m4a1", "weapon_tmp",
"weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552", "weapon_ak47",
"weapon_knife", "weapon_p90", ""}
new Float:g_weap_speed[32] = {0.0, 250.0, 0.0, 260.0, 250.0, 240.0, 250.0, 250.0, 240.0,
250.0, 250.0, 250.0, 250.0, 210.0, 240.0, 240.0, 250.0, 250.0, 210.0, 250.0, 220.0, 230.0,
230.0, 250.0, 210.0, 250.0, 250.0, 235.0, 221.0, 250.0, 245.0, 0.0}

new pc_xp_mult
new pc_upgs

new Float:g_mradius
new Float:g_sq_mradius

new Float:g_p_angle[MAX_PLAYERS+1][3]


new g_c_regen[MAX_PLAYERS+1]
new g_p_maxhealth[MAX_PLAYERS+1]
new g_c_resup[MAX_PLAYERS+1]
new Float:g_p_next_lj[MAX_PLAYERS+1]
new bool:g_p_jump[MAX_PLAYERS+1]
new g_c_frost[MAX_PLAYERS+1]
new g_c_ice[MAX_PLAYERS+1]
new g_c_denial[MAX_PLAYERS+1]
new g_c_impulse[MAX_PLAYERS+1]
new g_c_medic[MAX_PLAYERS+1]

new bool:g_block_denial //if true, denial will not work on next round


new g_p_buttons[MAX_PLAYERS+1]
new bool:g_p_alive[MAX_PLAYERS+1]
new g_p_weap_num[MAX_PLAYERS+1]
new g_p_weap[MAX_PLAYERS+1][32]
new g_p_has_c4[MAX_PLAYERS+1]
new CsArmorType:g_p_atype[MAX_PLAYERS+1]
new g_p_armor[MAX_PLAYERS+1]

new Float:g_xp_multipler
new g_msgStatusText

new pc_savedata
new pc_saveby
new pc_savedb
new pc_frequent_save

new pc_sql_host
new pc_sql_user
new pc_sql_pass
new pc_sql_db

new pc_start_lvl

new pc_bot_start_lvl
new pc_bot_savedata
new pc_bot_buy_upgrades

new pc_def_upgs
new pc_bot_def_upgs
new pc_user_control
new pc_in_team

new bool:g_freezetime
new g_p_authid[MAX_PLAYERS+1][32]
new g_p_ip[MAX_PLAYERS+1][32]
new g_p_name[MAX_PLAYERS+1][32]
new g_p_data_loaded[MAX_PLAYERS+1]
new g_p_defkit[MAX_PLAYERS+1]

new g_saveby
new g_saveby_name[6][16] = {"", "rpgm_sid", "rpgm_ip", "rpgm_name", "rpgm_reg", "rpgm_bot"}

new g_savedb

new g_p_username[MAX_PLAYERS+1][32]
new g_p_password[MAX_PLAYERS+1][32]
new g_p_login_status[MAX_PLAYERS+1]
new bool:g_p_pw_hidden[MAX_PLAYERS+1]

new Handle:g_sql_tuple
new Handle:g_sql_connection
new g_db_status
new g_sql_tables
new g_frequent_save
new g_bot_savedata
new g_bot_def_upgs[MAX_UPGS]
new g_bot_def_cost
new g_bot_def_lvl_req
new g_def_upgs[MAX_UPGS]
new g_def_cost
new g_def_lvl_req

new g_user_control
new g_in_team


public plugin_init(){
    register_plugin("RPG mod", VERSION, "Sylwester")
    register_cvar("rpgm_ver", VERSION, FCVAR_SERVER)

    g_msgStatusText = get_user_msgid("StatusText")
    g_max_players = get_maxplayers()

    register_clcmd("say", "handle_say")
    register_clcmd("say_team", "handle_say")
    register_clcmd("rpgmenu", "menu_main")

    register_clcmd("amx_rpglogin", "rpg_login", -1, "<felhaszna'lo'> <jelszo'> ")

    register_clcmd("amx_rpg_lvl", "change_lvl_cmd", ADMIN_CVAR, "<@all|@t|@ct|#userid|name> <+|=|-> <amount> - changes target level ")
    register_clcmd("amx_rpg_drop_upgs", "drop_upg_cmd", ADMIN_CVAR, "<@all|@t|@ct|#userid|name> - forces target(s) to sell all upgrades ")
    register_clcmd("amx_rpg_set_upgs", "set_upg_cmd", ADMIN_CVAR, "<@all|@t|@ct|#userid|name> <upgrades string> - set target(s) upgrades ")

    register_srvcmd("amx_rpg_global_reset", "global_data_reset", ADMIN_CVAR, "<RENAME|DELETE> - rename or delete all current data files/tables ")

    pc_xp_mult = register_cvar("rpgm_xp_mult", "1.0", 0, 1.0)
    pc_upgs = register_cvar("rpgm_upgs", "111111111111")
    pc_savedata = register_cvar("rpgm_savedata", "1") //1 - yes //0 - no
    pc_saveby = register_cvar("rpgm_saveby", "1") //1 - steamid //2 - ip //3 - name
    pc_savedb = register_cvar("rpgm_savedb", "1") //1 - nvault //2 - sql

    pc_frequent_save = register_cvar("rpgm_frequent_save", "0")
    //0-save only on disconnect //1-save all on new round
    //2-every 10secs save player with highest xp gained since last save

    pc_start_lvl = register_cvar("rpgm_start_lvl", "0")

    pc_bot_start_lvl = register_cvar("rpgm_bot_start_lvl", "0")
    pc_bot_savedata = register_cvar("rpgm_bot_savedata", "0")
    pc_bot_buy_upgrades = register_cvar("rpgm_bot_buy_upgrades", "0")

    pc_def_upgs = register_cvar("rpgm_def_upgrades", "000000000000")
    pc_bot_def_upgs = register_cvar("rpgm_bot_def_upgrades", "0000000000000")
   
    pc_user_control = register_cvar("rpgm_user_control", "1")

    pc_sql_host = register_cvar("rpgm_sql_host", "")
    pc_sql_user = register_cvar("rpgm_sql_user", "")
    pc_sql_pass = register_cvar("rpgm_sql_pass", "")
    pc_sql_db = register_cvar("rpgm_sql_db", "")

    pc_in_team = register_cvar("rpgm_in_team", "0") //0-both team //1-only terro //2-only ct

    register_event("Damage", "damage_event", "b", "2!0")
    register_event("DeathMsg", "player_death", "a")
    register_event("CurWeapon", "event_CurWeapon", "be", "1=1")
    register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
    register_logevent("logevent_round_start", 2, "1=Round_Start")
    register_event("TextMsg", "block_denial", "a", "2&#Game_C") //game commencing
    register_event("TextMsg", "block_denial", "a", "2&#Game_will_restart_in") //round restart
    register_message(get_user_msgid("Health"), "fix_0hp")

    register_menucmd(register_menuid("\yRPG mod \d[#]"), 1023, "hnd_menu_main")
    register_menucmd(register_menuid("\yRPG mod \d[#.1]"), 1023, "hnd_menu_buy_upg")
    register_menucmd(register_menuid("\yRPG mod \d[#.2]"), 1023, "hnd_menu_sell_upg")
    register_menucmd(register_menuid("\yRPG mod \d[#.4]"), 1023, "hnd_menu_help")
    register_menucmd(register_menuid("\yRPG mod \d[#.5]"), 1023, "hnd_menu_settings")
    register_menucmd(register_menuid("\yRPG mod \d[#.6]"), 1023, "hnd_menu_data")

    RegisterHam(Ham_Spawn, "player", "player_spawn", 1)
    register_forward(FM_PlayerPreThink, "player_PreThink")
    register_forward(FM_PlayerPostThink, "player_PostThink")
    register_forward(FM_CmdStart,"fwd_CmdStart")

    //exec_cfg_file()  //rpg mod cfg file unfinished

    create_timer()
    g_db_status = DB_NONE
    set_task(0.1, "prepare_database")
}


public global_data_reset(id, level, cid){
    new arg[32], path[128], file[128], cache[128], temp[128], file2[128]
    if (!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED

    read_args(arg, 31)

    if(g_db_status == DB_NONE){
        log_amx("SERVER: [ amx_rpg_global_reset %s ] - adatba'zis nincs csatlakozva", arg)
        return PLUGIN_HANDLED
    }

    get_datadir(path, 127)
    format(path, 127, "%s/vault/", path)

    if(contain(arg, "DELETE")==0){
        g_db_status = DB_NONE
        if(g_savedb==SAVEDB_NVAULT){
            for(new i=1; i<6; i++){
                format(file, 127, "%s%s.vault", path, g_saveby_name[i])
                if(file_exists(file) && !delete_file(file)){
                    log_amx("SERVER: [ amx_rpg_global_reset %s ] - Sikertelen pro'ba'lja meg ujra %s", arg, file)
                    return PLUGIN_HANDLED
                }
            }
        }else if(g_savedb==SAVEDB_MYSQL){
            for(new i=1; i<6; i++){
                format(cache, 127, "drop table if exists %s;", g_saveby_name[i])
                SQL_ThreadQuery(g_sql_tuple, "handle_change_table_query", cache)
            }
        }
    }else if(contain(arg, "RENAME")==0){
        g_db_status = DB_NONE
        get_time("%y%m%d%H%M%S", temp, 127)
        if(g_savedb==SAVEDB_NVAULT){
            for(new i=1; i<6; i++){
                format(file, 127, "%s%s.vault", path, g_saveby_name[i])
                format(file2, 127, "%s%s_%s.vault", path, temp, g_saveby_name[i])
                if(file_exists(file) && !rename_file(file, file2, 1)){
                    log_amx("SERVER: [ amx_rpg_global_reset %s ] - Sikertelen proba'lja ma'shogy %s", arg, file)
                    return PLUGIN_HANDLED
                }
            }
        }else if(g_savedb==SAVEDB_MYSQL){
            for(new i=1; i<6; i++){
                format(cache, 127, "RENAME TABLE %s TO %s_%s;", g_saveby_name[i], temp, g_saveby_name[i])
                SQL_ThreadQuery(g_sql_tuple, "handle_change_table_query", cache)
            }
        }
    }else{
        log_amx("SERVER: [ amx_rpg_global_reset %s ], invalid argument - must be DELETE or RENAME", arg)
        return PLUGIN_HANDLED
    }
    log_amx("SERVER: [ amx_rpg_global_reset %s ] - sikeres", arg)
    prepare_database()
    return PLUGIN_HANDLED
}


public handle_change_table_query(FailState,Handle:Query,Error[],Errcode,Data[],DataSize){
    if(FailState){
        log_amx("SQL Hiba: %s (%d)", Error, Errcode)
        return PLUGIN_HANDLED
    }
    return PLUGIN_CONTINUE
}


public prepare_database(){
    g_db_status = DB_NONE
    g_frequent_save = get_pcvar_num(pc_frequent_save)
    g_bot_savedata = get_pcvar_num(pc_bot_savedata)
    if(get_pcvar_num(pc_savedata) == 0)
        return

    g_saveby = get_pcvar_num(pc_saveby)
    if(g_saveby < 1 || g_saveby > 3)  //1 - steamid //2 - ip //3 - name
        g_saveby = 1
    g_savedb = get_pcvar_num(pc_savedb)
    if(g_savedb < 1 || g_savedb > 2)
        g_savedb = 1
    switch(g_savedb){
        case SAVEDB_MYSQL: sql_init()
        case SAVEDB_NVAULT: {
            g_db_status = DB_READY
            p_vars_reset_all()
            data_load_all()
        }
    }
}


public incorrect_login_data(id){
    client_print(id, print_chat, "[RPG mod]Hiba a felhaszna'lo' vagy jelszo' 3és 10 karakter kozott legyen!!")
    client_print(id, print_chat, "[RPG mod]Hiba a felhaszna'lo' vagy jelszo' nem megengedett karaktereket tartalmaz,, '-' és '_'")
    client_print(id, print_console, "[RPG mod]Hiba a felhaszna'lo' vagy jelszo' 3és 10 karakter kozott legyen!!")
    client_print(id, print_console, "[RPG mod]Hiba a felhaszna'lo' vagy jelszo' nem megengedett karaktereket tartalmaz,, '-' és '_'")
    return PLUGIN_HANDLED
}


public rpg_login(id, level, cid){
    static cache[128], len, Float:time
    if (!cmd_access(id, level, cid, 3))
        return PLUGIN_HANDLED
    if(g_p_login_status[id] == REG_DONE){
        client_print(id, print_chat, "[RPG mod]Hiba: te ma'r bejelekezte'l")
        client_print(id, print_console, "[RPG mod]Hiba: te ma'r bejelekezte'l")
        return PLUGIN_HANDLED
    }

    time = get_gametime()
    if(time - g_p_login_time[id] < LOGIN_COOLDOWN && g_p_login_time[id] != 0.0){
        client_print(id, print_chat, "[RPG mod]Hiba: az amx_rpglogin-t csak minden %.-dik ma'sodpercben haszna'lhatod", LOGIN_COOLDOWN)
        client_print(id, print_console, "[RPG mod]Hiba: az amx_rpglogin-t csak minden %.-dik ma'sodpercben haszna'lhatod", LOGIN_COOLDOWN)
        return PLUGIN_HANDLED
    }

    g_p_login_time[id] = time
    read_args(cache, 127)
    strbreak(cache, g_p_username[id], 31, cache, 127)
    remove_quotes(g_p_username[id])
    len = strlen(g_p_username[id])
    if(len<3 || len>10){
        incorrect_login_data(id)
    }
    for(new i=0; i<len; i++){
        if((g_p_username[id][i] < 'a' || g_p_username[id][i] > 'z') &&
        (g_p_username[id][i] < 'A' || g_p_username[id][i] > 'Z') &&
        (g_p_username[id][i] < '0' || g_p_username[id][i] > '9') &&
        g_p_username[id][i] != '-' && g_p_username[id][i] != '_'){
            incorrect_login_data(id)
        }
    }

    strbreak(cache, g_p_password[id], 31, cache, 127)
    remove_quotes(g_p_password[id])
    len = strlen(g_p_password[id])
    if(len<3 || len>10){
        incorrect_login_data(id)
    }
    for(new i=0; i<len; i++){
        if((g_p_password[id][i] < 'a' || g_p_password[id][i] > 'z') &&
        (g_p_password[id][i] < 'A' || g_p_password[id][i] > 'Z') &&
        (g_p_password[id][i] < '0' || g_p_password[id][i] > '9') &&
        g_p_password[id][i] != '-' && g_p_password[id][i] != '_'){
            incorrect_login_data(id)
        }
    }
    for(new i=1; i<=g_max_players; i++){
        if(i==id || !is_user_connected(i))
            continue
        if(equal(g_p_username[i], g_p_username[id])){
            client_print(id, print_chat, "[RPG mod]Hiba: a felhaszna'lot ma'r haszna'lja'k.")
            client_print(id, print_console, "[RPG mod]Hiba: a felhaszna'lot ma'r haszna'lja'k.")
            g_p_username[id] = ""
            g_p_password[id] = ""
            return PLUGIN_HANDLED
        }
    }
    g_p_login_status[id] = REG_TRY
    g_p_data_loaded[id] = DATA_NOT_LOADED
    data_load(id)
    return PLUGIN_HANDLED
}


public fix_0hp(msg_id, msg_dest, id){
    if(!is_user_alive(id))
        return
    if(get_msg_arg_int(1) % 256 == 0)
        set_msg_arg_int(1, 0, 255)
}


public force_drop_upgrades(id){
    for(new i=0; i<MAX_UPGS; i++){
        g_p_credits[id] += as_sum_fn(g_p_upg[id][i], g_upg_sp[i], g_upg_ip[i])
        g_p_upg[id][i] = 0
        upgrade_change(id, i)
    }
}


public drop_upg_cmd(id, level, cid){
    static players[MAX_PLAYERS], pnum, arg[32], tmp, i, name[32]
    if (!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED
    read_argv(1, arg, 31)
    pnum = 0
    if(equali(arg, "@all")){
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i))
                players[pnum++] = i
    }else if(equali(arg, "@t")){
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i) && get_user_team(i)==1)
                players[pnum++] = i
    }else if(equali(arg, "@ct")){
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i) && get_user_team(i)==2)
                players[pnum++] = i
    }else if(arg[0] == '#'){
        tmp = str_to_num(arg[1])
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i) && get_user_userid(i)==tmp)
                players[pnum++] = i
    }else{
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i)){
                get_user_name(i, name, 31)
                if(equal(name, arg)){
                    pnum = 0
                    players[pnum++] = i
                    break
                }else if(contain(name, arg)>-1){
                    players[pnum++] = i
                }
            }
    }
   
    if(pnum<=0){
        client_print(id, print_console, "[RPG mod]Hiba: Nem tala'lhato'")
        return PLUGIN_HANDLED
    }

    for(i=0; i<pnum; i++){
        force_drop_upgrades(players[i])
    }

    get_user_name(id, name, 31)
    log_amx("ADMIN %s used cmd [ amx_rpg_drop_upg %s ], ettol a ja'te'kosto'l %d", name, arg, pnum)
    client_print(0, print_chat, "ADMIN %s: [Elvette a fejleszte'se't: %s], ettol a ja'te'kosto'l: %d", name, arg, pnum)
    return PLUGIN_HANDLED
}


public set_upg_cmd(id, level, cid){
    static players[MAX_PLAYERS], pnum, arg[32], args[63], tmp, i, j, name[32]
    if (!cmd_access(id, level, cid, 3))
        return PLUGIN_HANDLED
    read_argv(1, arg, 31)
    pnum = 0
    if(equali(arg, "@all")){
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i))
                players[pnum++] = i
    }else if(equali(arg, "@t")){
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i) && get_user_team(i)==1)
                players[pnum++] = i
    }else if(equali(arg, "@ct")){
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i) && get_user_team(i)==2)
                players[pnum++] = i
    }else if(arg[0] == '#'){
        tmp = str_to_num(arg[1])
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i) && get_user_userid(i)==tmp)
                players[pnum++] = i
    }else{
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i)){
                get_user_name(i, name, 31)
                if(equal(name, arg)){
                    pnum = 0
                    players[pnum++] = i
                    break
                }else if(contain(name, arg)>-1){
                    players[pnum++] = i
                }
            }
    }

    if(pnum<=0){
        client_print(id, print_console, "[RPG mod]Hiba: nem tala'lhato'")
        return PLUGIN_HANDLED
    }
   
    new cost, lvl_req, upgs[MAX_UPGS]
    read_argv(2, arg, 31)
    for(i=0; i<MAX_UPGS; i++){
        if(!g_upg_enabled[i]){
            upgs[i] = 0
            continue
        }
        if(arg[i] >= '0' && arg[i] <= '9')
            upgs[i] = arg[i]-'0'
        else if(arg[i] >= 'a' && arg[i] <= 'z')
            upgs[i] = arg[i]-'a'+10
        else if(arg[i] >= 'A' && arg[i] <= 'Z')
            upgs[i] = arg[i]-'A'+10
        else
            upgs[i] = 0
        if(upgs[i] < 0)
            upgs[i] = 0
        if(upgs[i] > g_upg_maxlvl[i])
            upgs[i] = g_upg_maxlvl[i]
        cost += as_sum_fn(upgs[i], g_upg_sp[i], g_upg_ip[i])
    }
    lvl_req = cost / CREDITS_PER_LVL
   
    for(i=0; i<pnum; i++){
        for(j=0; j<MAX_UPGS; j++){
            g_p_upg[players[i]][j] = upgs[j]
            upgrade_change(players[i], j)
        }
        if(g_p_level[players[i]] < lvl_req){
            g_p_level[players[i]] = lvl_req
            g_p_xp[players[i]] = as_sum_fn(lvl_req, XP_START, XP_INC)
            g_p_progress[players[i]] = 0

        }
        g_p_credits[players[i]] = g_p_level[players[i]]*CREDITS_PER_LVL - cost
        data_save(players[i])
    }

    read_args(args, 63)
    get_user_name(id, name, 31)
    log_amx("ADMIN %s used cmd [ amx_rpg_set_upgs %s ], Ennek a ja'te'kosnak: %d", name, args, pnum)
    client_print(0, print_chat, "ADMIN %s: [A1ta'littotta a fejleszte'seit: %s], Ennek a ja'te'kosnak: %d", name, args, pnum)
    return PLUGIN_HANDLED
}


public change_lvl_cmd(id, level, cid){
    static players[MAX_PLAYERS], pnum, arg[32], args[63], tmp, amount, i, j, name[32]
    if (!cmd_access(id, level, cid, 4))
        return PLUGIN_HANDLED
    read_argv(1, arg, 31)
    pnum = 0
    if(equali(arg, "@all")){
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i))
                players[pnum++] = i
    }else if(equali(arg, "@t")){
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i) && get_user_team(i)==1)
                players[pnum++] = i
    }else if(equali(arg, "@ct")){
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i) && get_user_team(i)==2)
                players[pnum++] = i
    }else if(arg[0] == '#'){
        tmp = str_to_num(arg[1])
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i) && get_user_userid(i)==tmp)
                players[pnum++] = i
    }else{
        for(i=1; i<=g_max_players; i++)
            if(is_user_connected(i)){
                get_user_name(i, name, 31)
                if(equal(name, arg)){
                    pnum = 0
                    players[pnum++] = i
                    break
                }else if(contain(name, arg)>-1){
                    players[pnum++] = i
                }
            }
    }

    if(pnum<=0){
        client_print(id, print_console, "[RPG mod]Hiba: Nem tala'lhato'")
        return PLUGIN_HANDLED
    }

    read_argv(3, arg, 31)
    amount = str_to_num(arg)
   
    read_argv(2, arg, 1)
    if(amount<0 || (amount==0 && arg[0]!='=')){
        client_print(id, print_console, "[RPG mod]Hiba: Nem tala'hato'")
        return PLUGIN_HANDLED
    }

    switch(arg[0]){
        case '+': { //increases level and credits
            for(i=0; i<pnum; i++){
                g_p_level[players[i]] += amount
                g_p_xp[players[i]] = as_sum_fn(g_p_level[players[i]], XP_START, XP_INC)
                g_p_credits[players[i]] += amount * CREDITS_PER_LVL
                g_p_progress[players[i]] = 0
                set_default_lvl_upg(players[i])//will not set lvl if player has lvl > default lvl
                data_save(players[i])
            }
        }
        case '-': { //reduces level and credits
            for(i=0; i<pnum; i++){
                g_p_level[players[i]] -= amount
                g_p_xp[players[i]] = as_sum_fn(g_p_level[players[i]], XP_START, XP_INC)
                g_p_credits[players[i]] -= amount * CREDITS_PER_LVL
                g_p_progress[players[i]] = 0
                if(g_p_credits[players[i]] < 0)
                    force_drop_upgrades(players[i])
                if(g_p_credits[players[i]] < 0)
                    g_p_level[players[i]] = 0  //will reset to default in set_default_lvl_upg
                set_default_lvl_upg(players[i])//will not set lvl if player has lvl > default lvl
                data_save(players[i])
            }
        }
        case '=': { //set level and credits (all previous upg sell penalty is gone)
            for(i=0; i<pnum; i++){
                g_p_level[players[i]] = amount
                g_p_xp[players[i]] = as_sum_fn(g_p_level[players[i]], XP_START, XP_INC)
                g_p_credits[players[i]] = amount * CREDITS_PER_LVL
                g_p_progress[players[i]] = 0
                for(j=0; j<MAX_UPGS; j++)
                    g_p_credits[players[i]] -= as_sum_fn(g_p_upg[players[i]][j], g_upg_sp[j], g_upg_ip[j])
                if(g_p_credits[players[i]] < 0)
                    force_drop_upgrades(players[i])
                set_default_lvl_upg(players[i])//will not set lvl if player has lvl > default lvl
                data_save(players[i])
            }
        }
        default: {
            client_print(id, print_console, "[RPG mod]Error: invalid 2nd argument - must be - or + or = ")
            return PLUGIN_HANDLED
        }
    }
   
    read_args(args, 63)
    get_user_name(id, name, 31)
    log_amx("ADMIN %s used cmd [ amx_rpg_lvl %s ], affected players: %d", name, args, pnum)
    client_print(0, print_chat, "ADMIN %s: [level change: %s], affected players: %d", name, args, pnum)
    return PLUGIN_HANDLED
}


/*
#########################################################################################
#########################################################################################
#########################################################################################
#########################################################################################
*/
public block_denial(){  //called on game commencing and round restart
    g_block_denial = true
}


////////////////////////////////check_cfg_file() UNFINISHED
public check_cfg_file(){
    new cfgdir[128], cache[256], fh
    get_configsdir(cfgdir, 127)
    format(cfgdir, 127, "%s%s", cfgdir, "/rpg_mod")

    if(!dir_exists(cfgdir)){
        log_amx("Config dir does not exist (%s), ke'szite's...", cfgdir)
        if(mkdir(cfgdir)!=0){
            log_amx("Error: Could not create dir (%s).", cfgdir)
            return
        }
    }

    formatex(cache, 255, "%s%s", cfgdir, "/rpg_mod.cfg")
    if(!file_exists(cache)){
        log_amx("Config file does not exist: (%s), ke'szite's...", cache)
        fh = fopen(cache, "wt")
        if(!fh){
            log_amx("Error: Could not open file for writing (%s).", cache)
            return
        }else{
            fputs(fh, "// RPG Mod Configuration File^n")
            fputs(fh, "echo Executing RPG Mod Configuration File^n^n")
            fputs(fh, "rpgm_save 1^t^t^t//1 = save data, 0 = don't save data^n")
            fputs(fh, "rpgm_saveby 1^t^t^t//1 = STEAMID, 2 = ip, 3 = name^n")
            fputs(fh, "rpgm_savedb 1^t^t^t//1 = nVault, 2 = MySql^n^n")
            fputs(fh, "rpgm_upgs 111111111111^n")
            fputs(fh, "rpgm_xp_mult 1.0^n")

            fclose(fh)
        }

    }

    server_cmd("exec %s", cache)
}

//xp needed to gain lvls, upgrades cost are elements of arithmetic sequence
//so I need functions to get number of elements from sum
//and sum from number of elements
public as_num_fs(sum, base, diff){ //returns number of elements
    static l, r, mid, bool:found
    if(sum<10000)
        //this formula is not working with high values of sum (getting out of int max limit)
        return (sqroot((2*base-diff)*(2*base-diff) + 8*diff*sum) - (2*base-diff))/(2*diff)

    if(sum<base)
        return 0
    r = 1
    //binary search - not as fast as formula above but still faster than linera search...
    while( ( 2*base + diff*(r-1) )*r/2 < sum)
        r = r*2
    l = r/2
    //now the number we are looking for is somewhere between l and r
    found = false
    while(!found){
        mid = (l+r)/2
        if(( 2*base + diff*(mid-1) )*mid/2 > sum)
            r = mid-1
        else if(( 2*base + diff*mid )*(mid+1)/2 <= sum)
            l = mid+1
        else
            found = true
    }
    return mid
}


public as_sum_fn(num, base, diff) //returns sum of elements
    return num*(base*2 + diff*(num-1))/2


public data_save_all(){
    if(g_db_status != DB_READY)
        return
    for(new id=1; id<=g_max_players; id++){
        if(is_user_connected(id) && (g_p_authorized[id] || g_saveby != SAVEBY_STEAMID))
            data_save(id)
    }
}


public data_load_all(){
    for(new id=1; id<=g_max_players; id++){
        if((is_user_connected(id) || is_user_connecting(id))
        && (g_p_authorized[id] || g_saveby != SAVEBY_STEAMID))
            data_load(id)
    }
}


public data_save(id){
    static nv_hnd, data[256], cache[512], key[64], i, saveby, pos
    if(g_db_status != DB_READY || g_p_data_loaded[id] == DATA_NOT_LOADED)
        return

    if(g_p_login_status[id] == REG_DONE){
        saveby = SAVEBY_LOGIN
        i = -3
    }else{
        saveby = g_saveby
        i = -2
    }

    if(is_user_bot(id)){
        if(g_bot_savedata == 0)
            return
        else
            saveby = SAVEBY_BOT
    }

    switch(saveby){
        case SAVEBY_STEAMID: copy(key, 31, g_p_authid[id])
        case SAVEBY_IP: copy(key, 31, g_p_ip[id])
        case SAVEBY_NAME:{
            if(g_savedb == SAVEDB_NVAULT)
                copy(key, 31, g_p_name[id])
            else
                SQL_QuoteString(g_sql_connection, key, 63, g_p_name[id])
        }
        case SAVEBY_LOGIN: copy(key, 31, g_p_username[id])
        case SAVEBY_BOT:{ //
            if(g_savedb == SAVEDB_NVAULT)
                copy(key, 31, g_p_name[id])
            else
                SQL_QuoteString(g_sql_connection, key, 63, g_p_name[id])
        }
    }

    pos = 0
    data = ""
    for(; i<MAX_UPGS; i++){
        switch(i){
            case -3: pos += formatex(data[pos], 255-pos, "%s ", g_p_password[id])
            case -2: pos += formatex(data[pos], 255-pos, "%d ", g_p_xp[id])
            case -1: pos += formatex(data[pos], 255-pos, "%d ", g_p_credits[id])
            default: pos += formatex(data[pos], 255-pos, "%d ", as_sum_fn(g_p_upg[id][i], g_upg_sp[i], g_upg_ip[i]))
        }
    }

    if(g_savedb == SAVEDB_NVAULT){
        nv_hnd = nvault_open(g_saveby_name[saveby])
        if(nv_hnd == INVALID_HANDLE){
            log_amx("Nem sikerult megynyitni nVault-ot %s.", g_saveby_name[saveby])
            g_p_login_status[id] = REG_NONE
            return
        }
        nvault_set(nv_hnd, key, data)
        g_p_temp_xp[id] = 0
        nvault_close(nv_hnd)
    }else{ // g_savedb == SAVEDB_MYSQL
        formatex(cache, 511, "REPLACE INTO %s (db_key, data) VALUES ('%s', '%s');", g_saveby_name[saveby], key, data)
        new temp[2]
        temp[0] = id
        SQL_ThreadQuery(g_sql_tuple, "handle_sql_save", cache, temp, 2)
    }
    if(saveby == SAVEBY_LOGIN){
        data_delete(id, g_saveby)
    }
}


public handle_sql_save(FailState,Handle:Query,Error[],Errcode,Data[],DataSize){
    if(g_db_status != DB_READY)
        return PLUGIN_HANDLED
    if(FailState){
        log_amx("SQL Hiba: %s (%d)", Error, Errcode)
        return PLUGIN_HANDLED
    }
    g_p_temp_xp[Data[0]] = 0
    return PLUGIN_CONTINUE
}



public data_load(id){
    static nv_hnd, data[2], cache[256], ts, ret, key[32], i, saveby
    if(g_db_status != DB_READY || g_p_data_loaded[id] != DATA_NOT_LOADED
    || g_p_login_status[id] == REG_DONE)
        return

    if(g_p_login_status[id] == REG_TRY){
        saveby = SAVEBY_LOGIN
        i = -3
    }else{
        i = -2
        saveby = g_saveby
    }

    if(is_user_bot(id)){
        if(g_bot_savedata == 0)
            return
        else
            saveby = SAVEBY_BOT
    }
    switch(saveby){
        case SAVEBY_STEAMID: copy(key, 31, g_p_authid[id])
        case SAVEBY_IP: copy(key, 31, g_p_ip[id])
        case SAVEBY_NAME: {
            if(g_savedb == SAVEDB_NVAULT)
                copy(key, 31, g_p_name[id])
            else
                SQL_QuoteString(g_sql_connection, key, 63, g_p_name[id])
        }
        case SAVEBY_LOGIN: copy(key, 31, g_p_username[id])
        case SAVEBY_BOT: {
            if(g_savedb == SAVEDB_NVAULT)
                copy(key, 31, g_p_name[id])
            else
                SQL_QuoteString(g_sql_connection, key, 63, g_p_name[id])
        }
    }

    if(g_savedb == SAVEDB_NVAULT){
        nv_hnd = nvault_open(g_saveby_name[saveby])
        if(nv_hnd == INVALID_HANDLE){
            log_amx("nem sikerult megynitnin Vault-ot %s.", g_saveby_name[saveby])
            client_print(id, print_chat, "[RPG mod]Hiba: Nem sikerult csatlakozni az adatba'zishoz.")
            client_print(id, print_console, "[RPG mod]Hiba: Nem sikerult csatlakozni az adatba'zishoz.")
            g_p_login_status[id] = REG_NONE
            return
        }
        ret = nvault_lookup(nv_hnd, key, cache, 255, ts)
        nvault_close(nv_hnd)
        if(ret==0){
            g_p_data_loaded[id] = DATA_NOT_FOUND
            if(g_p_login_status[id] == REG_TRY){
                g_p_login_status[id] = REG_DONE
                data_save(id) //lets reserve this username
                client_print(id, print_chat, "[RPG mod]Te sikeresen regriszta'lta'l!!")
                client_print(id, print_console, "[RPG mod]Te sikeresen regriszta'lta'l!!")
                g_p_pw_hidden[id] = true
                set_default_lvl_upg(id)
            }
        }else{
            decode_data_str(id, cache, i)
        }
    }else{ // g_savedb == SAVEDB_MYSQL
        data[0] = id
        data[1] = i
        g_p_data_loaded[id] = DATA_LOADING
        format(cache, 255, "kiva'lasztot adat innen: %s WHERE db_key = '%s'", g_saveby_name[saveby], key)
        SQL_ThreadQuery(g_sql_tuple, "handle_sql_load", cache, data, 2)
    }

}


public handle_sql_load(FailState,Handle:Query,Error[],Errcode,Data[],DataSize){
    static id, i, cache[256]
    if(g_db_status != DB_READY)
        return PLUGIN_HANDLED
    if(FailState){
        log_amx("SQL Hiba: %s (%d)", Error, Errcode)
        return PLUGIN_HANDLED
    }

    id = Data[0]
    i = Data[1]
    if(SQL_MoreResults(Query)){
        SQL_ReadResult(Query, 0, cache, 255)
        decode_data_str(id, cache, i)
    }else{
        //first time connect
        g_p_data_loaded[id] = DATA_NOT_FOUND
        if(g_p_login_status[id] == REG_TRY){
            g_p_login_status[id] = REG_DONE
            data_save(id) //lets reserve this username
            client_print(id, print_chat, "[RPG mod]Te sikeresen regriszta'lta'l!!")
            client_print(id, print_console, "[RPG mod]Te sikeresen regriszta'lta'l!!")
            g_p_pw_hidden[id] = true
            set_default_lvl_upg(id)
        }
    }
    return PLUGIN_CONTINUE
}


public decode_data_str(id, data[], i){
    static temp[32], num
    for(; i<MAX_UPGS; i++){
        strbreak(data, temp, 31, data, 255)
        remove_quotes(temp)
        switch(i){
            case -3:{
                if(!equal(temp, g_p_password[id])){
                    client_print(id, print_chat, "[RPG mod]Hiba a felhaszna'lo' nem tala'lhato az adatba'zisban, vagy rosz jelszo.")
                    client_print(id, print_console, "[RPG mod]Hiba a felhaszna'lo' nem tala'lhato az adatba'zisban, vagy rosz jelszo.")
                    g_p_username[id] = ""
                    g_p_password[id] = ""
                    g_p_login_status[id] = REG_NONE
                    g_p_data_loaded[id] = DATA_LOADED
                    set_default_lvl_upg(id)
                    return
                }
                client_print(id, print_chat, "[RPG mod] Sikeresen bejelentkezte'l")
                client_print(id, print_console, "[RPG mod] Sikeresen bejelentkezte'l")
                g_p_pw_hidden[id] = true
            }
            case -2:{
                g_p_xp[id] = str_to_num(temp)
                g_p_level[id] = as_num_fs(g_p_xp[id], XP_START, XP_INC)
                g_p_progress[id] = 100-(as_sum_fn(g_p_level[id]+1, XP_START, XP_INC)-g_p_xp[id])*100/(XP_START+XP_INC*g_p_level[id])
            }
            case -1: g_p_credits[id] = str_to_num(temp)
            default:{
                num = str_to_num(temp)
                g_p_upg[id][i] = as_num_fs(num, g_upg_sp[i], g_upg_ip[i])
                if(g_p_upg[id][i] > g_upg_maxlvl[i])
                    g_p_upg[id][i] = g_upg_maxlvl[i]
                if(!g_upg_enabled[i])
                    g_p_upg[id][i] = 0
                upgrade_change(id, i)
                g_p_credits[id] += num - as_sum_fn(g_p_upg[id][i], g_upg_sp[i], g_upg_ip[i])
            }
        }
    }


    g_p_data_loaded[id] = DATA_LOADED
    if(g_p_login_status[id] == REG_TRY)
        g_p_login_status[id] = REG_DONE
    set_default_lvl_upg(id)   
}


public data_delete(id, saveby){
    static nv_hnd, key[64], cache[128]
    if(g_db_status != DB_READY)
        return
    switch(saveby){
        case SAVEBY_STEAMID: copy(key, 31, g_p_authid[id])
        case SAVEBY_IP: copy(key, 31, g_p_ip[id])
        case SAVEBY_NAME: {
            if(g_savedb == SAVEDB_NVAULT)
                copy(key, 31, g_p_name[id])
            else
                SQL_QuoteString(g_sql_connection, key, 63, g_p_name[id])
        }
        case SAVEBY_LOGIN:{
            copy(key, 31, g_p_username[id])
            g_p_username[id] = ""
            g_p_password[id] = ""
        }
        case SAVEBY_BOT: {
            if(g_savedb == SAVEDB_NVAULT)
                copy(key, 31, g_p_name[id])
            else
                SQL_QuoteString(g_sql_connection, key, 63, g_p_name[id])
        }
    }

    if(g_savedb == SAVEDB_NVAULT){
        nv_hnd = nvault_open(g_saveby_name[saveby])
        if(nv_hnd == -1){
            log_amx("Nem sikerult megnyitni nvault-ot")
            return
        }
        nvault_remove(nv_hnd, key)
        nvault_close(nv_hnd)
    }else{ //g_savedb == SAVEDB_MYSQL
        formatex(cache, 127, "Torles innen %s WHERE db_key = '%s';", g_saveby_name[saveby], key)
        SQL_ThreadQuery(g_sql_tuple, "handle_sql_delete", cache)
    }
}


public handle_sql_delete(FailState,Handle:Query,Error[],Errcode,Data[],DataSize){
    if(g_db_status != DB_READY)
        return PLUGIN_HANDLED
    if(FailState){
        log_amx("SQL Hiba: %s (%d)", Error, Errcode)
        return PLUGIN_HANDLED
    }

    return PLUGIN_CONTINUE
}


public event_new_round(){
    g_freezetime = true
    if(g_block_denial){
        g_block_denial = false
        for(new id=1; id<=g_max_players; id++){
            g_c_denial[id] = DENIAL_BLOCK
        }
    }
    for(new id=1; id<=g_max_players; id++){
        g_c_regen[id] = 0
        g_c_resup[id] = 0
        g_p_next_lj[id] = 0.0
        g_p_jump[id] = false
        g_c_frost[id] = 0
        g_c_ice[id] = 0
        g_c_impulse[id] = 0
        g_c_medic[id] = 0
    }
    if(g_frequent_save==1)
        data_save_all()
}


public logevent_round_start(){
    g_freezetime = false
}


public update_StatusText(id){
    static cache[512]
    if(!g_user_control || (g_in_team && g_in_team != g_p_team[id])
    || !g_p_settings[id][SETT_INFO_UNDER_CHAT])
        return
    format(cache, 511, "[RPG mod][Szint: %d][Sza'szale'k: %d%s][Pontok: %d]  ird /rpg", g_p_level[id], g_p_progress[id], "%%", g_p_credits[id])
    message_begin(MSG_ONE_UNRELIABLE, g_msgStatusText, {0,0,0}, id)
    write_byte(0)
    write_string(cache)
    message_end()
}


public event_CurWeapon(id){
    reset_player_speed(id)
}


public player_death(id){
    static attacker, victim
    attacker = read_data(1)
    victim = read_data(2)
    if(!is_user_alive(victim)){
        g_p_alive[victim] = false
    }

    g_p_weap_num[victim] = 0
    get_user_weapons(victim, g_p_weap[victim], g_p_weap_num[victim])
    g_p_defkit[victim] = cs_get_user_defuse(victim)
    g_p_armor[victim] = cs_get_user_armor(victim, g_p_atype[victim])
    if(g_p_upg[victim][UPG_DENIAL] && g_c_denial[victim] != DENIAL_BLOCK && !(g_in_team && g_in_team != g_p_team[id]))
        g_c_denial[victim] = DENIAL_NEXT_SPAWN

    if(attacker == victim)
        return
    if(attacker < 1 || attacker > g_max_players)
        return
    if(victim < 1 || victim > g_max_players)
        return
    if(cs_get_user_team(victim)==cs_get_user_team(attacker))
        return
    fn_addxp(attacker, fn_calcxp(CXT_KILL, attacker, victim, 0))
}


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Rpg mod
HozzászólásElküldve:2012.04.25. 14:54 
Offline
Beavatott

Csatlakozott:2012.04.12. 16:22
Hozzászólások:87
Megköszönték neki: 1 alkalommal
Kód:
public fwd_CmdStart(id, uc_handle, seed){
    if(!is_user_alive(id))
        return FMRES_IGNORED
    g_p_buttons[id] = get_uc(uc_handle,UC_Buttons)
    return FMRES_IGNORED;
}


public player_PreThink(id){
    static Float:ftmp, Float:angle[3], sum, s, s2
    if(pev(id, pev_button)&IN_JUMP && !(pev(id, pev_oldbuttons)&IN_JUMP)
    && pev(id, pev_flags)&FL_ONGROUND){
        g_p_jump[id] = true
    }

    if(pev(id, pev_button)&IN_JUMP && !(pev(id, pev_oldbuttons)&IN_JUMP)
    && !(pev(id, pev_flags)&FL_ONGROUND)){
        g_p_jump[id] = false
    }

    if(is_user_alive(id)){
        pev(id, pev_fuser2, ftmp)
        ftmp -= 0.001*g_p_upg[id][UPG_LJ]*g_p_upg[id][UPG_LJ]*ftmp
        if(ftmp<0.0)
            ftmp=0.0

        if(g_c_ice[id]>0 || g_c_frost[id]>0){
            pev(id, pev_v_angle, angle)
            if(g_c_ice[id]>0){
                ftmp = 1000.0*sqroot(g_c_ice[id]-1)
                s = 2*sqroot(g_c_ice[id])
                s2= 1
                sum = s+s2
            }else{
                ftmp = 500.0
                s = 3
                s2 = 2
                sum = s+s2
            }
            g_p_angle[id][0] = g_p_angle[id][0]*s/sum + angle[0]*s2/sum
            if(angle[1]<-90.0 && g_p_angle[id][1]>90.0)
                g_p_angle[id][1] = (g_p_angle[id][1]-360.0)*s/sum + angle[1]*s2/sum
            else if(angle[1]>90.0 && g_p_angle[id][1]<-90.0)
                g_p_angle[id][1] = (g_p_angle[id][1]+360.0)*s/sum + angle[1]*s2/sum
            else
                g_p_angle[id][1] = g_p_angle[id][1]*s/sum + angle[1]*s2/sum

            if(g_p_angle[id][1]<-180.0)
                g_p_angle[id][1] += 360.0
            else if(g_p_angle[id][1]>180.0)
                g_p_angle[id][1] -= 360.0

            set_pev(id, pev_angles, g_p_angle[id])
            set_pev(id, pev_fixangle, 1)
        }

        set_pev(id, pev_fuser2, ftmp)
    }

    return FMRES_IGNORED
}


public player_PostThink(id){
    static Float:velocity[MAX_PLAYERS+1][3], Float:land_time[MAX_PLAYERS+1]
    static Float:tmp_time, Float:tmp_speed, Float:lj_max_speed, Float:weap_speed
    static Float:xy_speed[MAX_PLAYERS+1], on_ground[MAX_PLAYERS+1], tmp_on_ground
    pev(id, pev_velocity, velocity[id])

    tmp_on_ground = pev(id, pev_flags)&FL_ONGROUND
    if(on_ground[id] && !tmp_on_ground){//player just jumped/lost ground/fell
        if(g_p_jump[id]){
            g_p_jump[id] = false
            global_get(glb_time, tmp_time)
            tmp_speed = floatsqroot(velocity[id][0]*velocity[id][0] + velocity[id][1]*velocity[id][1])
            velocity[id][0] = velocity[id][0]/tmp_speed
            velocity[id][1] = velocity[id][1]/tmp_speed

            if(tmp_time-land_time[id]>0.08 || tmp_speed < 200.0 || g_p_upg[id][UPG_BHOP] < 2){
                xy_speed[id] = tmp_speed
            }

            weap_speed = g_weap_speed[get_user_weapon(id)]
            lj_max_speed = weap_speed*(1.0+0.2*g_p_upg[id][UPG_LJ])
            if(xy_speed[id]<lj_max_speed){
                xy_speed[id] = xy_speed[id]*(1.0+0.2*g_p_upg[id][UPG_LJ])
                if(xy_speed[id]>lj_max_speed){
                    xy_speed[id] = lj_max_speed
                }
            }
            if(g_c_frost[id] > 0 && xy_speed[id] > weap_speed){
                xy_speed[id] -= xy_speed[id]*0.2
            }
            velocity[id][0] = velocity[id][0]*xy_speed[id]
            velocity[id][1] = velocity[id][1]*xy_speed[id]
            if(!g_in_team || g_in_team == g_p_team[id])
                set_pev(id, pev_velocity, velocity[id])
        }
        on_ground[id] = tmp_on_ground
    }else if(!on_ground[id] && tmp_on_ground){ //player just landed
        global_get(glb_time, land_time[id])
        on_ground[id] = tmp_on_ground
    }

    if(g_p_upg[id][UPG_BHOP] && pev(id, pev_flags)&FL_ONGROUND && pev(id, pev_button)&IN_JUMP
    && g_c_ice[id]<=0 && (!g_in_team || g_in_team == g_p_team[id])){
        set_pev(id, pev_oldbuttons, pev(id, pev_oldbuttons) & ~IN_JUMP)
        set_pev(id, pev_gaitsequence, 6)
        set_pev(id, pev_frame, 0.0)
    }
    if(!tmp_on_ground){
        xy_speed[id] = floatsqroot(velocity[id][0]*velocity[id][0] + velocity[id][1]*velocity[id][1])
    }
    return FMRES_IGNORED
}


public damage_event(id){
    static weapon, bodypart, attacker, dmg, health, tmp
    attacker = get_user_attacker(id, weapon, bodypart)
    if(attacker<1 || attacker>32 || id<1 || id>32 || g_p_team[id]==g_p_team[attacker] || id==attacker)
        return

    dmg = read_data(2)
    fn_addxp(attacker, fn_calcxp(CXT_DMG, attacker, id, dmg))
    health = get_user_health(attacker)
    if(g_p_upg[id][UPG_IMPULSE] && (!g_in_team || g_in_team == g_p_team[id])){
        g_c_impulse[id] = 50
        reset_player_speed(id)
    }

    if(g_in_team && g_in_team != g_p_team[attacker])
        return

    if(g_p_upg[attacker][UPG_VAMP] && health<g_p_maxhealth[attacker]){
        tmp = get_user_health(id)
        if(tmp>0)
            tmp = 0
        tmp += dmg
        health += floatround(tmp*g_p_upg[attacker][UPG_VAMP]*0.075)
        if(health<g_p_maxhealth[attacker])
            set_user_health(attacker, health)
        else
            set_user_health(attacker, g_p_maxhealth[attacker])
    }

    if(g_p_upg[attacker][UPG_ICESTAB] && weapon==CSW_KNIFE
    && !(g_p_buttons[attacker] & IN_ATTACK) && (g_p_buttons[attacker] & IN_ATTACK2)){
        if(g_c_ice[id]<10*g_p_upg[attacker][UPG_ICESTAB]){
            g_c_ice[id] = 10*g_p_upg[attacker][UPG_ICESTAB] + 3
            pev(id, pev_v_angle, g_p_angle[id])
        }
    }

    if(g_p_upg[attacker][UPG_FROST] && ( weapon==CSW_P228 || weapon==CSW_ELITE
    || weapon==CSW_FIVESEVEN || weapon==CSW_USP || weapon==CSW_GLOCK18 || weapon==CSW_DEAGLE )){
        if(g_c_frost[id]<g_p_upg[attacker][UPG_FROST]){
            g_c_frost[id] = g_p_upg[attacker][UPG_FROST] + 3
            pev(id, pev_v_angle, g_p_angle[id])
        }
    }
}


public reset_player_speed(id){
    static Float:speed, weap
    if(g_freezetime)
        return
    weap = get_user_weapon(id)
    speed = g_weap_speed[weap]
    if(g_c_impulse[id]>0){
        speed += speed*0.25*g_p_upg[id][UPG_IMPULSE]
    }
    set_user_maxspeed(id, speed)
}


public select_random_upgrades(id){
    static upg_list[MAX_UPGS], last, i, upg
    for(i = 0; i<g_enabled_upgs; i++)
        upg_list[i] = g_enabled_list[i]
    last = g_enabled_upgs-1
    while(g_p_credits[id] >= 0){
        for(i=last; i>=0; i--)  //remove maxed upgs from list
            if(g_p_upg[id][ upg_list[i] ] >= g_upg_maxlvl[ upg_list[i] ]){
                upg_list[i] = upg_list[last]
                last--
            }
        if(last<0)
            return
        upg = upg_list[ random(last+1) ]
        g_p_credits[id] -= g_upg_sp[upg] + g_upg_ip[upg]*g_p_upg[id][upg]
        g_p_upg[id][upg]++
        upgrade_change(id, upg)
    }
}


public player_spawn(id){
    static temp
    if(is_user_alive(id)){
        g_p_team[id] = get_user_team(id)
        g_c_regen[id] = 0
        g_c_resup[id] = 0
        g_c_frost[id] = 0
        g_c_ice[id] = 0
        g_c_impulse[id] = 0
        g_c_medic[id] = 0
        g_p_alive[id] = true

        if(g_p_upg[id][UPG_STEALTH]){
            temp = 255-40*g_p_upg[id][UPG_STEALTH]
            if(temp<0)
                temp=0
            if(g_in_team && g_in_team != g_p_team[id])
                temp=255
            set_user_rendering(id, 0, 0, 0, 0, kRenderTransAlpha, temp)
        }

        if(g_in_team && g_in_team != g_p_team[id])
            return

        if(g_p_settings[id][SETT_MENU_ON_SPAWN])
            set_task(0.5, "menu_main", id)

        if(is_user_bot(id) && get_pcvar_num(pc_bot_buy_upgrades)==1){
            if(g_p_credits[id]>=0){
                select_random_upgrades(id)
            }
        }

        if(g_c_denial[id] == DENIAL_BLOCK){
            g_c_denial[id] = 0
        }
        if(g_c_denial[id] == DENIAL_NEXT_SPAWN){
            g_c_denial[id] = DENIAL_START
        }

        set_user_health(id, g_p_maxhealth[id])
    }
}


public update_vars(){
    static temp[MAX_UPGS+1], i, j, bool:upg_changed
    g_mradius = 300.0
    g_sq_mradius = g_mradius*g_mradius
    g_user_control = get_pcvar_num(pc_user_control)
    g_in_team = get_pcvar_num(pc_in_team)
    g_xp_multipler = get_pcvar_float(pc_xp_mult)
    if(g_xp_multipler > MAX_XP_MULTI)
        g_xp_multipler = MAX_XP_MULTI
    if(g_xp_multipler < 0.0)
        g_xp_multipler = 0.0
    g_enabled_upgs = 0
    upg_changed = false

    get_pcvar_string(pc_upgs, temp, MAX_UPGS)
    for(i=0; i<MAX_UPGS; i++){
        if(temp[i]!='0'){
            if(!g_upg_enabled[i])
                upg_changed = true
            g_upg_enabled[i] = true
            g_enabled_list[g_enabled_upgs] = i
            g_enabled_upgs++
        }else{
            if(g_upg_enabled[i])
                upg_changed = true
            g_upg_enabled[i] = false
        }
    }

    if(upg_changed){
        for(i=1; i<=g_max_players; i++){
            if(is_user_connected(i)){
                for(j=0; j<MAX_UPGS; j++){
                    if(!g_upg_enabled[j]){
                        g_p_credits[i] += as_sum_fn(g_p_upg[i][j], g_upg_sp[j], g_upg_ip[j])
                        g_p_upg[i][j] = 0
                        upgrade_change(i, j)
                    }
                }
            }
        }
    }

    get_pcvar_string(pc_bot_def_upgs, temp, MAX_UPGS)
    g_bot_def_cost = 0
    for(i=0; i<MAX_UPGS; i++){
        if(!g_upg_enabled[i]){
            g_bot_def_upgs[i] = 0
            continue
        }
        if(temp[i] >= '0' && temp[i] <= '9')
            g_bot_def_upgs[i] = temp[i]-'0'
        else if(temp[i] >= 'a' && temp[i] <= 'z')
            g_bot_def_upgs[i] = temp[i]-'a'+10
        else if(temp[i] >= 'A' && temp[i] <= 'Z')
            g_bot_def_upgs[i] = temp[i]-'A'+10
        else
            g_bot_def_upgs[i] = 0
        if(g_bot_def_upgs[i] < 0)
            g_bot_def_upgs[i] = 0
        if(g_bot_def_upgs[i] > g_upg_maxlvl[i])
            g_bot_def_upgs[i] = g_upg_maxlvl[i]
        g_bot_def_cost += as_sum_fn(g_bot_def_upgs[i], g_upg_sp[i], g_upg_ip[i])
    }
    g_bot_def_lvl_req = g_bot_def_cost / CREDITS_PER_LVL
   
    get_pcvar_string(pc_def_upgs, temp, MAX_UPGS)
    g_def_cost = 0
    for(i=0; i<MAX_UPGS; i++){
        if(!g_upg_enabled[i]){
            g_def_upgs[i] = 0
            continue
        }
        if(temp[i] >= '0' && temp[i] <= '9')
            g_def_upgs[i] = temp[i]-'0'
        else if(temp[i] >= 'a' && temp[i] <= 'z')
            g_def_upgs[i] = temp[i]-'a'+10
        else if(temp[i] >= 'A' && temp[i] <= 'Z')
            g_def_upgs[i] = temp[i]-'A'+10
        else
            g_def_upgs[i] = 0
        if(g_def_upgs[i] < 0)
            g_def_upgs[i] = 0
        if(g_def_upgs[i] > g_upg_maxlvl[i])
            g_def_upgs[i] = g_upg_maxlvl[i]
        g_def_cost += as_sum_fn(g_def_upgs[i], g_upg_sp[i], g_upg_ip[i])
    }
    g_def_lvl_req = g_def_cost / CREDITS_PER_LVL
}


public p_vars_reset_all(){
    for(new id=1; id<=g_max_players; id++)
        p_vars_reset(id)
}


public p_vars_reset(id){
    static i
    if(is_user_connected(id) || is_user_connecting(id)){
        g_p_xp[id] = 0
        g_p_temp_xp[id] = 0
        g_p_progress[id] = 0
        g_p_credits[id] = 0
        g_p_level[id] = 0

        for(i=0; i<MAX_UPGS; i++){
            g_p_upg[id][i] = 0
        }

        g_c_regen[id] = 0
        g_p_maxhealth[id] = 100
        g_c_resup[id] = 0
        g_p_next_lj[id] = 0.0
        g_p_jump[id] = false
        g_c_frost[id] = 0
        g_c_ice[id] = 0
        g_c_denial[id] = 0
        g_c_impulse[id] = 0
        g_c_medic[id] = 0
        get_user_name(id, g_p_name[id], 31)
        get_user_ip(id, g_p_ip[id], 31)
        set_default_lvl_upg(id)
        g_p_data_loaded[id] = DATA_NOT_LOADED
    }
}


public sql_init(){
    new host[32], user[32], pass[32], db[32], err[512], err_code

    if(g_db_status == DB_CONNECTING)
        return
    g_db_status = DB_CONNECTING

    get_pcvar_string(pc_sql_host, host, 31)
    get_pcvar_string(pc_sql_user, user, 31)
    get_pcvar_string(pc_sql_pass, pass, 31)
    get_pcvar_string(pc_sql_db, db, 31)
    g_sql_tuple = SQL_MakeDbTuple(host, user, pass, db)
   
    if(g_sql_connection != Empty_Handle)
        SQL_FreeHandle(g_sql_connection)

    g_sql_connection = SQL_Connect(g_sql_tuple,err_code,err,511)
    if(g_sql_connection == Empty_Handle){
        log_amx("SQL Hiba: %s (%d)", err, err_code)
        g_db_status = DB_NONE
        return
    }

    check_tables()
}


public check_tables(){
    static cache[256]
    g_sql_tables = 0
    for(new i=1; i<6; i++){
        //key in tables rpgm_name, rpgm_bot is VARCHAR(64) and VARCHAR(32) in others
        //it's because name may contain invalid characters and we need to backquote them
        //using SQL_QuoteString, this way name length may increase and be greater than 32
        formatex(cache, 255, "CREATE TABLE IF NOT EXISTS %s ( db_key VARCHAR(%d) NOT NULL, data VARCHAR(256), PRIMARY KEY ( db_key ) )", g_saveby_name[i], i==3||i==5?64:32)
        SQL_ThreadQuery(g_sql_tuple, "handle_create_table_query", cache)
    }
}


public handle_create_table_query(FailState,Handle:Query,Error[],Errcode,Data[],DataSize){
    if(g_db_status != DB_CONNECTING)
        return PLUGIN_HANDLED
    if(FailState){
        log_amx("SQL Hiba: %s (%d)", Error, Errcode)
        g_db_status = DB_NONE
        g_sql_tables = 0
        return PLUGIN_HANDLED
    }

    g_sql_tables++
    if(g_sql_tables == 5){ //sql connected and all tables created
        g_db_status = DB_READY
        p_vars_reset_all()  //######################################## necessary ?
        data_load_all()
    }
    return PLUGIN_CONTINUE
}


public create_timer(){
    g_timer_entid = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"))
    for(new i=1; i<4; i++){
        if(pev_valid(g_timer_entid)){
            break
        }else{
            log_amx("Hiba: Nem sikerult le'tre hozni pro'ba'lja meg(%d) mulva", i)
            g_timer_entid = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"))
        }
    }

    if(pev_valid(g_timer_entid)){
        set_pev(g_timer_entid, pev_classname, "rpgm_timer")
        global_get(glb_time, g_t_time)
        set_pev(g_timer_entid, pev_nextthink, g_t_time + UPDATE_INTERVAL)
        register_forward(FM_Think,"fwd_Think")
    }else{
        log_amx("Hiba: Nem sikerult le'tre hozni")
        set_task(UPDATE_INTERVAL, "timer_cycle", TID_TIMER, "", 0, "b")
    }
}


public fwd_Think(Ent){
    if(Ent != g_timer_entid)
        return FMRES_IGNORED
    g_t_time += UPDATE_INTERVAL
    set_pev(Ent, pev_nextthink, g_t_time)
    timer_cycle()
    return FMRES_IGNORED
}


public plugin_unpause(){
    if(pev_valid(g_timer_entid)){
        global_get(glb_time, g_t_time)
        g_t_time += UPDATE_INTERVAL
        set_pev(g_timer_entid, pev_nextthink, g_t_time)
    }

    //CHECK ALL PLAYER DATA ! #############################################
}


public timer_cycle(){
    static id, temp, temp2, temp3, i, origin[3], t_origin[3], CsArmorType:atype
    static glb_update_cnt, update_cnt[MAX_PLAYERS+1], save_time_cnt
    glb_update_cnt--
    if(glb_update_cnt<=0){
        glb_update_cnt = 30
        update_vars()
    }
   
    if(g_frequent_save == FREQ_S_INTERVAL && g_db_status == DB_READY){
        save_time_cnt--
        if(save_time_cnt<=0){
            save_time_cnt = 100
            id = 1
            for(i=2; i<=g_max_players; i++){
                if(g_p_temp_xp[i]>g_p_temp_xp[id])
                    id = i
            }
            if(g_p_temp_xp[id]>0)
                data_save(id)
        }
    }

    for(id=1; id<g_max_players; id++){
        if(!is_user_alive(id)){
            continue
        }

        update_cnt[id]--
        if(update_cnt[id]<=0){
            update_cnt[id] = 10
            update_StatusText(id)
        }

        if(g_c_frost[id]>0){
            g_c_frost[id]--
        }
        if(g_c_ice[id]>0){
            g_c_ice[id]--
        }

        if(g_in_team && g_in_team != g_p_team[id])
            continue

        if(g_p_upg[id][UPG_REGEN]){
            g_c_regen[id]--
            if(g_c_regen[id]<=0){
                g_c_regen[id] = 10
                temp = get_user_health(id)
                if(temp<g_p_maxhealth[id]){
                    temp += g_p_upg[id][UPG_REGEN]
                    if(temp<g_p_maxhealth[id])
                        set_user_health(id, temp)
                    else
                        set_user_health(id, g_p_maxhealth[id])
                }
            }
        }

        if(g_p_upg[id][UPG_RESUP]){
            g_c_resup[id]--
            if(g_c_resup[id]<=0){
                temp = get_user_weapon(id, temp2, temp3)
                if(temp<33 && temp3<g_max_bpammo[temp]){
                    temp3 += g_p_upg[id][UPG_RESUP]
                    if(temp!=CSW_HEGRENADE && temp!=CSW_C4 && temp!=CSW_SMOKEGRENADE && temp!=CSW_FLASHBANG){
                        if(temp3<g_max_bpammo[temp]){
                            cs_set_user_bpammo(id, temp, temp3)
                        }else{
                            cs_set_user_bpammo(id, temp, g_max_bpammo[temp])
                        }
                    }
                }
                g_c_resup[id] = 30
            }
        }

        if(g_c_denial[id]>0 && g_c_denial[id] <= DENIAL_START){
            g_c_denial[id]--
            if(g_c_denial[id]==DENIAL_STRIP){
                g_p_has_c4[id] = user_has_weapon(id, CSW_C4)
                strip_user_weapons(id)
            }
            if(g_c_denial[id]==DENIAL_GIVE){
                cs_set_user_armor(id, g_p_armor[id], g_p_atype[id])
                for(i=0; i<g_p_weap_num[id]; i++){
                    if(g_p_weap[id][i]!=CSW_C4){
                        give_item(id, g_gi_names[g_p_weap[id][i]])
                        if(g_max_bpammo[g_p_weap[id][i]]>1)
                            cs_set_user_bpammo(id, g_p_weap[id][i], g_max_bpammo[g_p_weap[id][i]])
                    }
                }
                if(g_p_has_c4[id] == 1){
                    give_item(id, "weapon_c4")
                    cs_set_user_plant(id, 1, 1)
                }
                if(cs_get_user_team(id) == CS_TEAM_CT){
                    cs_set_user_defuse(id, g_p_defkit[id])
                }
                g_c_denial[id] = 0
            }
        }

        if(g_c_impulse[id]>0){
            g_c_impulse[id]--
            if(g_c_impulse[id] == 0)
                reset_player_speed(id)
        }

        if(g_p_upg[id][UPG_MEDIC]){
            g_c_medic[id]--
            if(g_c_medic[id]<=0){
                g_c_medic[id] = 10
                get_user_origin(id, origin)
                for(i=1; i<=g_max_players; i++){
                    if(!is_user_alive(i) || i==id || g_p_team[id]!=g_p_team[i])
                        continue
                    get_user_origin(i, t_origin)
                    t_origin[0] -= origin[0]
                    t_origin[1] -= origin[1]
                    t_origin[2] -= origin[2]
                    if(t_origin[0]*t_origin[0]+t_origin[1]*t_origin[1]+t_origin[2]*t_origin[2]<g_sq_mradius){
                        temp = get_user_health(i)
                        if(temp<g_p_maxhealth[i]){
                            temp += g_p_upg[id][UPG_MEDIC]
                            if(temp<g_p_maxhealth[i])
                                set_user_health(i, temp)
                            else
                                set_user_health(i, g_p_maxhealth[i])
                        }else{
                            temp = cs_get_user_armor(i, atype)
                            if(atype==CS_ARMOR_NONE)
                                atype = CS_ARMOR_KEVLAR
                            if(temp<100){
                                temp += g_p_upg[id][UPG_MEDIC]
                                if(temp<100)
                                    cs_set_user_armor(i, temp, atype)
                                else
                                    cs_set_user_armor(i, 100, atype)
                            }
                        }
                    }
                }

            } //END if(g_c_medic[id]<=0)

        } // END if(g_p_upg[id][UPG_MEDIC])

    } //END for(id=1; id<g_max_players; id++)
}


public client_infochanged(id){ //update name
    static name[32]
    get_user_info(id, "name", name, 31)
    if(g_saveby == SAVEBY_NAME && !equal(g_p_name[id], name)){
        data_save(id)
        p_vars_reset(id)
        copy(g_p_name[id], 31, name)
        data_load(id)
    }
}


public set_default_lvl_upg(id){
    static level
    if(is_user_bot(id)){
        level = get_pcvar_num(pc_bot_start_lvl)
        if(g_bot_def_lvl_req > level)
            level = g_bot_def_lvl_req
        if(g_p_level[id] > level)
            return
        for(new i=0; i<MAX_UPGS; i++){
            g_p_upg[id][i] = g_bot_def_upgs[i]
            upgrade_change(id, i)
        }
        g_p_credits[id] = -g_bot_def_cost
    }else{
        level = get_pcvar_num(pc_start_lvl)
        if(g_def_lvl_req > level)
            level = g_def_lvl_req
        if(g_p_level[id] > level)
            return
        for(new i=0; i<MAX_UPGS; i++){
            g_p_upg[id][i] = g_def_upgs[i]
            upgrade_change(id, i)
        }
        g_p_credits[id] = -g_def_cost
    }

    g_p_xp[id] = as_sum_fn(level, XP_START, XP_INC)
    g_p_level[id] = as_num_fs(g_p_xp[id], XP_START, XP_INC)
    g_p_credits[id] += g_p_level[id] * CREDITS_PER_LVL
    g_p_progress[id] = 0
}


public client_connect(id){
    static i
    get_rpg_settings(id)
    g_p_xp[id] = 0
    g_p_temp_xp[id] = 0
    g_p_progress[id] = 0
    g_p_credits[id] = 0
    g_p_level[id] = 0
    for(i=0; i<MAX_UPGS; i++){
        g_p_upg[id][i] = 0
    }

    g_c_regen[id] = 0
    g_p_maxhealth[id] = 100
    g_c_resup[id] = 0
    g_p_next_lj[id] = 0.0
    g_p_jump[id] = false
    g_c_frost[id] = 0
    g_c_ice[id] = 0
    g_c_denial[id] = 0
    g_c_impulse[id] = 0
    g_c_medic[id] = 0

    set_default_lvl_upg(id)

    g_p_data_loaded[id] = DATA_NOT_LOADED
    g_p_authorized[id] = false
    g_p_login_status[id] = REG_NONE
    get_user_ip(id, g_p_ip[id], 31)
    get_user_name(id, g_p_name[id], 31)

    g_p_username[id] = ""
    g_p_password[id] = ""

    if(g_saveby != SAVEBY_STEAMID)
        data_load(id)
}


public client_authorized(id){
    g_p_authorized[id] = true
    get_user_authid(id, g_p_authid[id], 31)
    if(g_saveby == SAVEBY_STEAMID)
        data_load(id)
}


public client_disconnect(id){
    data_save(id)
}


public lvl_diff_mod(attacker, victim){
    static alvl, vlvl
    alvl = g_p_level[attacker]
    vlvl = g_p_level[victim]
    if(vlvl > alvl)
        return 1 + (vlvl-alvl)/100
    return 1
}


public fn_calcxp(const type, const arg1, const arg2, const arg3){
    switch(type){
        //CXT_KILL - arg1: attacker, arg2: victim
        case CXT_KILL: return 100*lvl_diff_mod(arg1, arg2)
        //CXT_DMG - arg1: attacker, arg2: victim, arg3: dmg_amount
        case CXT_DMG: return arg3*lvl_diff_mod(arg1, arg2)
    }
    return 0
}


public fn_addxp(id, xp){ //adds xp to player id and calculates lvl
    static temp_xp, next_lvl_xp
    if(is_user_bot(id) && g_bot_savedata == 0)
        return
    if(g_p_level[id] > MAX_LVL)
        return
    temp_xp = floatround(xp*g_xp_multipler)
    g_p_xp[id] += temp_xp
    if(g_frequent_save == FREQ_S_INTERVAL)
        g_p_temp_xp[id] += temp_xp
    next_lvl_xp = g_p_level[id]*XP_INC+XP_START
    temp_xp = (XP_START + next_lvl_xp)*(g_p_level[id]+1)/2

    while(g_p_xp[id]>=temp_xp){
        g_p_level[id]++
        g_p_credits[id] += CREDITS_PER_LVL
        next_lvl_xp += XP_INC
        temp_xp += next_lvl_xp
    }
    g_p_progress[id] = 100-(temp_xp-g_p_xp[id])*100/next_lvl_xp
}


public plugin_end(){
    data_save_all()
    if(g_db_status == DB_READY && g_savedb == SAVEDB_MYSQL)
        SQL_FreeHandle(g_sql_connection)
}


public handle_say(id){
    static cache[32], arg1[32], arg2[32]
    if(!g_user_control)
        return PLUGIN_CONTINUE
    read_args(cache, 31)
    remove_quotes(cache)
    strbreak(cache, arg1, 31, arg2, 31)
    if(containi(arg1, "rpg")>-1 || containi(arg1, "menu")>-1){
        menu_main(id)
    }else if(containi(arg1, "help")>-1){
        menu_help(id)
    }else if(equali(arg1, "/deletexp")){
        if(g_p_login_status[id] == REG_DONE){
            data_delete(id, SAVEBY_LOGIN)
            g_p_login_status[id] = REG_NONE
        }else{
            data_delete(id, g_saveby)
            p_vars_reset(id)
            data_load(id)
        }
    }
    return PLUGIN_CONTINUE
}


public show_upgrades_info(id){
    static temp[2048], pos
    pos = 0
    pos += format(temp[pos], 2048-pos, "<html><body style=^"background-color:#000000;color:#33EE33;font-size:18px;font-family:verdana;^">")
    pos += format(temp[pos], 2048-pos, "Regenera'cio': felgyo'gyít 1-10 hp 3 ma'sodpercenke'nt<br>")
    pos += format(temp[pos], 2048-pos, "E'let+: Hoza'ad az e'letedhez 25-250<br>")
    pos += format(temp[pos], 2048-pos, "Tolte'ny uta'npotla's: Minden 3 ma'sodpercben ad 1-10 golyo't a kezetben le'vo fegyverbe<br>")
    pos += format(temp[pos], 2048-pos, "Ve'rsziva's: Te megkapod a sebze'sed 7.5-112.5%% e'letnek<br>")
    pos += format(temp[pos], 2048-pos, "A'tla'tszo'sa'g: Te 16-78%% a'tla'tszo' leszel<br>")
    pos += format(temp[pos], 2048-pos, "Hosszu' ugra's: Megnoveli az ugra's sebesse'ge't 20-100%%-kal<br>")
    pos += format(temp[pos], 2048-pos, "Dermeszto csapa's: Ha megutsz valakit ke'sel az lelassul<br>")
    pos += format(temp[pos], 2048-pos, "Fagyaszto lovede'kek: Ha meglosz valakit akkor lelassul<br>")
    pos += format(temp[pos], 2048-pos, "Ragaszkoda's: Viszakapod a fegyvered a hala'lod uta'n<br>")
    pos += format(temp[pos], 2048-pos, "Impulzus: Ha meglonek megnol a sebese'ged<br>")
    pos += format(temp[pos], 2048-pos, "Medikus: A csapata'rsaidnak 1-15 pa'nce'lt add minden ma'sodpercben<br>")
    pos += format(temp[pos], 2048-pos, "Bunnyhop: lvl1 - autojumping, lvl2 - Nincs lasula's landola'skor<br>")
    pos += format(temp[pos], 2048-pos, "</body></html>")
    show_motd(id, temp, "[RPG mod] Fejleszte'si tudnivalo'k")
    return PLUGIN_HANDLED
}


public show_plugin_help(id){
    static temp[2048], pos
    pos = 0
    pos += format(temp[pos], 2048-pos, "<html><body style=^"background-color:#000000;color:#33EE33;font-size:18px;font-family:verdana;^">")
    pos += format(temp[pos], 2048-pos, "Ez a plugin megtala'lhato' (http://www.amxx.try.hu/ pluginokkozott)<br>")
    pos += format(temp[pos], 2048-pos, "<br>Az a le'nyeg hogy ole'seke'rt, sebze'se'rt kapod az xp-t.<br>")
    pos += format(temp[pos], 2048-pos, "Minden szintle'pe'se'rt kapsz 5 pontot<br>")
    pos += format(temp[pos], 2048-pos, "A pontokbo'l tudsz veni fejleszte'seket<br>")
    pos += format(temp[pos], 2048-pos, "Ha egy fejleszte'st eladsz akkor csak az a'ra 75%%-a't kapod vissza<br>")
    pos += format(temp[pos], 2048-pos, "<br>Ha csak egy gombnyoma'sra akarod kinyitni a menut ird be conzolba:<br>")
    pos += format(temp[pos], 2048-pos, "bind [egy betu] rpgmenu<br>")
    pos += format(temp[pos], 2048-pos, "Pe'lda: bind K rpgmenu )<br>")
    pos += format(temp[pos], 2048-pos, "<br>a ja'te'kos xp-je't steamid / ip / ne'vre menti<br>")
    pos += format(temp[pos], 2048-pos, "De aka'r regisztra'hatsz is amx_rpglogin segitse'ge'vel.<br>")
    pos += format(temp[pos], 2048-pos, "Ird be a conzolba: amx_rpglogin [Felhaszna'lo'] [Jelszo'] a regisztra'la'shoz<br>")
    pos += format(temp[pos], 2048-pos, "Pe'lda: amx_rpglogin toll papir<br>")
    pos += format(temp[pos], 2048-pos, "Evvel tudsz regrisztra'lni, A bejelentkeze's<br>")
    pos += format(temp[pos], 2048-pos, "Be kell bindelni igy:<br>")
    pos += format(temp[pos], 2048-pos, "pe'lda: bind F1 ^"amx_rpglogin toll papir^"<br>")
    pos += format(temp[pos], 2048-pos, "<br>ha torolni akarod az xp-det irb be /deletexp<br>")
    pos += format(temp[pos], 2048-pos, "</body></html>")
    show_motd(id, temp, "[RPG mod] Plugin Segitse'g")
    return PLUGIN_HANDLED
}


public show_credits(id){
    static temp[2048], pos
    pos = 0
    pos += format(temp[pos], 2048-pos, "<html><body style=^"background-color:#000000;color:#33EE33;font-size:18px;font-family:verdana;^">")
    pos += format(temp[pos], 2048-pos, "RPG mod Developer: Sylwester<br>")
    pos += format(temp[pos], 2048-pos, "Magyarositotta: KiSlAgUnA<br><br>")
    pos += format(temp[pos], 2048-pos, "Thanks to:<br>")
    pos += format(temp[pos], 2048-pos, "</body></html>")
    show_motd(id, temp, "[RPG mod] Credits")
    return PLUGIN_HANDLED
}


public show_levels(id){
    static temp[2048], players[32], num, i, j, x, pos
    get_players(players, num)

    for(i=1; i<num; i++){ //sort players
        j = i-1
        x = players[i]
        while(j>-1 && g_p_level[players[j]]<g_p_level[x]){
            players[j+1] = players[j]
            j--
        }
        players[j+1] = x
    }

    pos = 0
    pos += format(temp[pos], 2048-pos, "<html><body style=^"background-color:#000000;color:#33EE33;font-size:15px;font-family:verdana;^">")
    pos += format(temp[pos], 2048-pos, "<table border=^"1^"><tr><th>Ja'te'kos neve</th><th>Ja'te'kos szintje</th>")

    for(i=0; i<num; i++){
        pos += format(temp[pos], 2048-pos, "</tr><tr><td>%s</td><td>%d</td>", g_p_name[players[i]], g_p_level[players[i]])
    }
    pos += format(temp[pos], 2048-pos, "</tr></table></body></html>")
    show_motd(id, temp, "[RPG mod] Ja'te'kosok szintje")
    return PLUGIN_HANDLED
}


public menu_help(id){
    static pos, cache[512]
    pos = 0
    new keys = (1<<0)|(1<<1)|(1<<2)|(1<<9)

    pos += formatex(cache[pos], 511-pos, "\yRPG mod \d[#.4]\wSegitse'g^n")
    pos += formatex(cache[pos], 511-pos, "1. Fejleszte'si Info^n")
    pos += formatex(cache[pos], 511-pos, "2. Plugin segitse'g^n")
    pos += formatex(cache[pos], 511-pos, "3. Credits^n")
    pos += formatex(cache[pos], 511-pos, "^n0. Kile'p^n")

    show_menu( id, keys, cache, -1)

    return PLUGIN_HANDLED
}


public hnd_menu_help(id,key){
    switch (key){
        case 0: {show_upgrades_info(id); menu_help(id);}
        case 1: {show_plugin_help(id); menu_help(id);}
        case 2: {show_credits(id); menu_help(id);}
        case 9: menu_main(id)
        default: return PLUGIN_HANDLED
    }

    return PLUGIN_HANDLED
}


public get_rpg_settings(id){
    static tmp[32], i
    if(is_user_bot(id))
        return
    get_user_info(id, "_rpgm_cfg", tmp, 31)
    if(strlen(tmp) < MAX_SETTINGS){
        client_cmd(id, "setinfo _rpgm_cfg %s", g_settings_default)
        log_amx("missing settings for %d", id)
        copy(tmp, 31, g_settings_default)
    }
    for(i=0; i<MAX_SETTINGS; i++){
        if(tmp[i] >= '0' && tmp[i] <= '9')
            g_p_settings[id][i] = tmp[i]-'0'
        else
            g_p_settings[id][i] = 0
        if(g_p_settings[id][i] > g_settings_maxval[i])
            g_p_settings[id][i] = g_settings_maxval[i]
    }
}


public set_rpg_settings(id){
    static i, pos, cache[32]
    if(is_user_bot(id))
        return
    pos = 0
    for(i=0; i<MAX_SETTINGS; i++)
        pos += formatex(cache[pos], 32-pos, "%d", g_p_settings[id][i])
    client_cmd(id, "setinfo _rpgm_cfg %s", cache)
}


public menu_settings(id){
    static pos, cache[512]
    pos = 0
    new keys = (1<<0)|(1<<1)|(1<<2)|(1<<9)

    pos += formatex(cache[pos], 511-pos, "\yRPG mod \d[#.5]\wBea'llita'sok^n")
    pos += formatex(cache[pos], 511-pos, "1. Megynyitni \yFomenu\w Minden kor eleje'n [%s\w]^n", g_p_settings[id][0]?"\yBE":"\rKI")
    pos += formatex(cache[pos], 511-pos, "2. Informa'cio'k kiira'sa\w (Szint, Pontok)[%s\w]^n", g_p_settings[id][1]?"\yBE":"\rKI")
    pos += formatex(cache[pos], 511-pos, "^n0. Kile'p^n")

    show_menu( id, keys, cache, -1)
    return PLUGIN_HANDLED
}


public hnd_menu_settings(id,key){
    if(key==9){
        menu_main(id)
        return PLUGIN_HANDLED
    }
    if(key==2){
        client_cmd(id, "hud_centerid 0")
        menu_settings(id)
        return PLUGIN_HANDLED
    }

    g_p_settings[id][key] = !g_p_settings[id][key]
    set_rpg_settings(id)
    menu_settings(id)
    return PLUGIN_HANDLED
}


public menu_data(id){
    static pos, cache[512]
    pos = 0
    new keys = (1<<9)
    pos += formatex(cache[pos], 511-pos, "\yRPG mod \d[#.6]\wAdat info'k^n")
    if(g_db_status!=DB_READY){
        pos += formatex(cache[pos], 511-pos, "Adatba'zis nicns csatlakozba^n")
        pos += formatex(cache[pos], 511-pos, "Xp-d, fejleszte'seid pontjaid  \yNEM lesznek\w elmentve^n")
        pos += formatex(cache[pos], 511-pos, "^n0. Kile'p^n")
        show_menu( id, keys, cache, -1)
        return PLUGIN_HANDLED
    }
    keys = keys|(1<<0)
    pos += formatex(cache[pos], 511-pos, "Adatba'tis csatlakozva.^n")
    pos += formatex(cache[pos], 511-pos, "Xp, A fejleszte'seid e's Pontjaid \y elmente'se\w automatikus^n")
    if(g_frequent_save==1)
        pos += formatex(cache[pos], 511-pos, "Minden korben e's amikor")
    pos += formatex(cache[pos], 511-pos, "Minden korben e's amikor lekapcsolodsz")
    if(g_frequent_save==2)
        pos += formatex(cache[pos], 511-pos, " or gain much xp")

    if(g_p_login_status[id] == REG_DONE){
        pos += formatex(cache[pos], 511-pos, ".^nAdataid mente'se \yFelhaszna'lo'dra\w.^n")
        pos += formatex(cache[pos], 511-pos, "^n\wTe bejelentezte'l^n")
        pos += formatex(cache[pos], 511-pos, "\wFelhaszna'lo'd: \y%s^n", g_p_username[id])
        pos += formatex(cache[pos], 511-pos, "\wJelszo'd: %s%s^n", g_p_pw_hidden[id] ? "\d" : "\y", g_p_pw_hidden[id] ? "*****" : g_p_password[id])
        pos += formatex(cache[pos], 511-pos, "\w1Jelszo'^n %s", g_p_pw_hidden[id] ? "Mutata'sa":"Elrejte'se")
        pos += formatex(cache[pos], 511-pos, "^n0. Kile'p^n")
    }else{
        pos += formatex(cache[pos], 511-pos, ".^nAdataid mente'se ")
        switch(g_saveby){
            case SAVEBY_STEAMID: pos += formatex(cache[pos], 511-pos, "\ySTEAMID\w.^n")
            case SAVEBY_IP: pos += formatex(cache[pos], 511-pos, "\yIP\w.^n")
            case SAVEBY_NAME: pos += formatex(cache[pos], 511-pos, "\yNE'V\w.^n")
        }
        pos += formatex(cache[pos], 511-pos, "Te nem jelentkezte'l me'g be^n")
        pos += formatex(cache[pos], 511-pos, "1. Segitse'g^n")
        pos += formatex(cache[pos], 511-pos, "(Itt tala'lsz egy kis segitse'get hogyan regisztra'lj)^n")
        pos += formatex(cache[pos], 511-pos, "^n0. Kile'p^n")
    }

    show_menu( id, keys, cache, -1)
    return PLUGIN_HANDLED
}


public hnd_menu_data(id,key){
    if(key==9){
        menu_main(id)
        return PLUGIN_HANDLED
    }
    if(g_p_login_status[id] == REG_DONE){
        g_p_pw_hidden[id] = !g_p_pw_hidden[id]
    }else{
        show_plugin_help(id)
    }
    menu_data(id)
    return PLUGIN_HANDLED
}


public menu_main(id){
    static pos, cache[512]
    if(!g_user_control)
        return PLUGIN_HANDLED
    pos = 0
    new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<9)

    pos += formatex(cache[pos], 511-pos, "\yRPG mod \d[#]\wFomenu^n")
    if(g_in_team==1)
        pos += formatex(cache[pos], 511-pos, "Upgrades work only for \yTerrorists\w^n")
    else if(g_in_team==2)
        pos += formatex(cache[pos], 511-pos, "Upgrades work only for \yCT\w^n")
    pos += formatex(cache[pos], 511-pos, "1. Fejleszte's va'sa'rla'sa^n")
    pos += formatex(cache[pos], 511-pos, "2. Fejleszte's elada'sa^n")
    pos += formatex(cache[pos], 511-pos, "3. Jate'kosok szintje^n")
    pos += formatex(cache[pos], 511-pos, "4. Segitse'g^n")
    pos += formatex(cache[pos], 511-pos, "5. Bea'llita'sok^n")
    pos += formatex(cache[pos], 511-pos, "6. Informaciok^n")
    pos += formatex(cache[pos], 511-pos, "^n0. Kile'p^n")

    show_menu( id, keys, cache, -1)
    return PLUGIN_HANDLED
}


public hnd_menu_main(id,key){
    static i
    switch (key){
        case 0: menu_buy_upg(id, 0)
        case 1: {
            g_p_sm_upg_cnt[id] = 0

            for(i=0; i<MAX_UPGS; i++){
                if(g_p_upg[id][i]){
                    g_p_sm_upg[id][g_p_sm_upg_cnt[id]] = i
                    g_p_sm_upg_cnt[id]++
                }
            }
            menu_sell_upg(id, 0)
        }
        case 2: {show_levels(id); menu_main(id);}
        case 3: menu_help(id)
        case 4: menu_settings(id)
        case 5: menu_data(id)
        default: return PLUGIN_HANDLED
    }
    return PLUGIN_HANDLED
}


public menu_buy_upg(id, page){
    static i, keys, pos, upg, price, max, cache[1024]
    pos = 0
    keys = 0
    if(page*8>=g_enabled_upgs)
        page = 0
    g_p_menu_page[id] = page

    max = (g_enabled_upgs-1)/8+1
    if(max<1)
        max=1
    pos += format(cache[pos], 1023-pos, "\yRPG mod \d[#.1]\wFejleszte'sek^n\d[%d/%d]\w[Pontok: \y%d\w]^n\wn. \d[ \wlvl\d ][\wa'rak\d]\wKe'pesse'g neve^n^n", page+1, max, g_p_credits[id])
    max = g_enabled_upgs - page*8
    if(max>8)
        max=8
    for(i=0; i<8; i++){
        if(i>=max){
            pos += formatex(cache[pos], 1023-pos, "\d%d.^n", i+1)
            continue
        }
        upg = g_enabled_list[i+page*8]
        price = g_upg_sp[upg] + g_upg_ip[upg]*g_p_upg[id][upg]
        if(g_p_upg[id][upg] >= g_upg_maxlvl[upg]){
            pos += formatex(cache[pos], 1023-pos, "\d%d. [\rmax\d][-----]%s^n", i+1, g_upg_name[upg])
        }else if(price > g_p_credits[id]){
            pos += formatex(cache[pos], 1023-pos, "\d%d. [%4d ][\r%5d \d]%s^n", i+1, g_p_upg[id][upg]+1, price, g_upg_name[upg])
        }else{
            pos += formatex(cache[pos], 1023-pos, "\w%d. \d[\w%4d \d][\y%5d \d]\w%s^n", i+1, g_p_upg[id][upg]+1, price, g_upg_name[upg])
            keys = keys|(1<<i)
        }
    }

    pos += formatex(cache[pos], 1023-pos, "^n%s9. Tova'bb...^n", g_enabled_upgs>8 ? "\w" : "\d")
    keys = keys|(1<<8)|(1<<9)
    pos += formatex(cache[pos], 1023-pos, "\w0. Kile'p^n")
    show_menu( id, keys, cache, -1)
    return PLUGIN_HANDLED
}


public hnd_menu_buy_upg(id,key){
    static upg

    if(key<8){
        upg = g_enabled_list[g_p_menu_page[id]*8+key]
        g_p_credits[id] -= g_upg_sp[upg] + g_upg_ip[upg]*g_p_upg[id][upg]
        g_p_upg[id][upg]++
        upgrade_change(id, upg)
        menu_buy_upg(id, g_p_menu_page[id])
    }else if(key==8){
        menu_buy_upg(id, g_p_menu_page[id]+1)
    }else{
        menu_main(id)
    }

    return PLUGIN_HANDLED
}


public menu_sell_upg(id, page){
    static i, keys, pos, upg, value, max, cache[1024]
    pos = 0
    keys = 0
    if(page*8>=g_p_sm_upg_cnt[id])
        page = 0
    g_p_menu_page[id] = page

    max = (g_p_sm_upg_cnt[id]-1)/8+1
    if(max<1)
        max=1
    pos += format(cache[pos], 1023-pos, "\yRPG mod \d[#.2]\wElada's^n\d[%d/%d]\w[Pontok: \y%d\w]^n\wn. \d[ \wlvl\d ][\wElada'si a'r\d]\wKe'pesse'g neve^n^n", page+1, max, g_p_credits[id])
    max = g_p_sm_upg_cnt[id] - page*8
    if(max>8)
        max=8
    for(i=0; i<8; i++){
        if(i>=max){
            pos += formatex(cache[pos], 1023-pos, "\d%d.^n", i+1)
            continue
        }
        upg = g_p_sm_upg[id][i+page*8]
        value = g_upg_sp[upg] + g_upg_ip[upg]*(g_p_upg[id][upg]-1)
        if(g_upg_enabled[upg])
            value = value*3/4
        if(g_p_upg[id][upg] <= 0){
            pos += formatex(cache[pos], 1023-pos, "\d%d. [   \r0 \d][   \r0 \d]%s^n", i+1, g_upg_name[upg])
        }else{
            pos += formatex(cache[pos], 1023-pos, "\w%d. \d[\w%4d \d][\y%5d \d]\w%s^n", i+1, g_p_upg[id][upg], value, g_upg_name[upg])
            keys = keys|(1<<i)
        }
    }

    pos += formatex(cache[pos], 1023-pos, "^n%s9. Tova'bb...^n", g_p_sm_upg_cnt[id]>8 ? "\w" : "\d")
    keys = keys|(1<<8)|(1<<9)
    pos += formatex(cache[pos], 1023-pos, "\w0. Kile'p^n")
    show_menu( id, keys, cache, -1)
    return PLUGIN_HANDLED
}


public hnd_menu_sell_upg(id,key){
    static upg, value
    if(key<8){
        upg = g_p_sm_upg[id][g_p_menu_page[id]*8+key]
        value = g_upg_sp[upg] + g_upg_ip[upg]*(g_p_upg[id][upg]-1)
        if(g_upg_enabled[upg])
            value = value*3/4
        g_p_credits[id] += value
        g_p_upg[id][upg]--
        upgrade_change(id, upg)
        menu_sell_upg(id, g_p_menu_page[id])
    }else if(key==8){
        menu_sell_upg(id, g_p_menu_page[id]+1)
    }else{
        menu_main(id)
    }

    return PLUGIN_HANDLED
}


public upgrade_change(id, upg){
    static health, temp
    switch(upg){
        case UPG_HEALTH:{
            temp = 100 + g_p_upg[id][UPG_HEALTH]*25
            temp -= g_p_maxhealth[id]
            g_p_maxhealth[id] += temp
            if(!is_user_alive(id) || temp <= 0)
                return
            if(g_in_team && g_in_team != g_p_team[id])
                return
            health = get_user_health(id)
            if(health >= g_p_maxhealth[id])
                return
            health += temp
            if(health >= g_p_maxhealth[id])
                set_user_health(id, g_p_maxhealth[id])
            else
                set_user_health(id, health)
        }

        case UPG_STEALTH:{
            if(!is_user_alive(id))
                return
            if(g_in_team && g_in_team != g_p_team[id])
                return
            temp = 255-40*g_p_upg[id][UPG_STEALTH]
            if(temp<0)
                temp=0
            set_user_rendering(id, 0, 0, 0, 0, kRenderTransAlpha, temp)
        }
    }
}


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Rpg mod
HozzászólásElküldve:2012.04.25. 14:56 
Offline
Developer
Avatar

Csatlakozott:2011.06.01. 21:11
Hozzászólások:7966
Megköszönt másnak: 295 alkalommal
Megköszönték neki: 537 alkalommal
Talán nem a pc_bot_savedata = register_cvar("rpgm_bot_savedata", "0")??

_________________
http://www.easyrankup.eu


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Rpg mod
HozzászólásElküldve:2012.04.25. 14:59 
Offline
Beavatott

Csatlakozott:2012.04.12. 16:22
Hozzászólások:87
Megköszönték neki: 1 alkalommal
de az nem a botoknak menti el az xp-jét?


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Rpg mod
HozzászólásElküldve:2012.04.25. 15:07 
Offline
Őskövület
Avatar

Csatlakozott:2012.02.07. 23:34
Hozzászólások:2192
Megköszönt másnak: 27 alkalommal
Megköszönték neki: 55 alkalommal
csak írta:
de az nem a botoknak menti el az xp-jét?

Igen a botoknak menti el.

_________________
[sma]CMD:fear(playerid, params[]){ new str[5]; if(!sscanf(params, "s[5]", str)){ if(egyezik(str, "find")) Msg(playerid, "A-a!");}  return 1;}[/sma]


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése: Rendezés 
Új téma nyitása Hozzászólás a témához  [33 hozzászólás ]  OldalElőző1234Következő


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 22 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole