Официалният форум на iPlay.bg 

Помощ и въпроси свързани с направата/настройката на вашите сървъри, въпроси за добавянето на плъгини, настройването им и прочие.
 #392202  от Todorow93
 вт юни 07, 2016 6:08 pm
Значи плъгин запазва по ник левелите и точките за шопа , но доста често получавам оплаквания защо пак съм 0 левел на някои хора не ги запазва ето и кода.
Код: Избери всички
#include <amxmodx>
#include <colorchat>
#include <fvault>
#include <amxmisc>
#include <hamsandwich>
#include <fun>
#include <cstrike>
#include <frostnades>

new g_round[33] = 0;
new g_speed[33] = 0;
#define TASKID 1994
new iPoints[33];
new iMoney[33];
new g_Max;
new teamInfo
new gMaxPlayers, iLevels[33], iKills[33], g_msg_screenfade;
new bool:bPrefix, bool:bLogs, bool:bHud, gMenu, iKNum, iMax, bool:bFade, iLevHe, iLevSlot;
new bool:bBuy, bool:bSell, iPrice;
new const szgMenuItems[][] = { "Kupi Leveli", "Prodai Leveli", "\yList s igrachi", "\rInfo" };
new const gLogFile[] = "addons/amxmodx/configs/levels/LvlsAdmCmdsLogs.txt";
new const gDir[] = "addons/amxmodx/configs/levels/";


/*
         ==========================CVARS============================
        "levels_logs ^"1^" // da logva li admin komandite ot plugina",
        "levels_num_to_next ^"5^" // sled kolko ubiistva da dava sledvasht level",
        "levels_max_levels ^"5000^" // maksimalen broi leveli",
        "levels_chat_prefix ^"1^" //da ima li prefix pred nicka",
        "levels_hud_info ^"1^" // da ima li hud informaciq pod radara za levelite",
        "levels_fade ^"1^" // da ima li fade pri digane na nov level",
        "levels_he_lvl_num ^"1000^" // sled kolko levela da dava he granata pri spawn",
        
        "; za izkliu4vane ostavi stoinosta na max_levels cvar-a",
        "levels_slot_lvl_num ^"3000^" // sled kolko levela da dava reservation slot na igracha",
        
        "; za izkliu4vane ostavi stoinosta na max_levels cvar-a",
        "levels_buy ^"1^" // da moje li da se kupuvat leveli",
        "levels_sell ^"1^" // da moje li da se prodavat leveli",
        "levels_level_price ^"500^" // kolko da struva edin level v $"
*/
 
new const gLogFileText[][] = {
        "Log",
        "logvat se slednite komandi: amx_setlvl, amx_addlvl i amx_resetlvl",
        "====================================================================^n "
};

new const g_team_names[CsTeams][] = 
{ 
    "(Spectator) ", 
    "(Terrorist) ", 
    "(Counter-Terrorist) ", 
    "(Spectator) " 
}; 
 
enum Cvars {
        LOGS, KNUM, MAX, CHAT, HUD,
        FADE, HE, SLOT, KUPOVINA, PRODAJA, CENA
}
 
new const CvarsNames[Cvars][] = {
        "levels_logs", "levels_num_to_next", "levels_max_levels", "levels_chat_prefix", "levels_hud_info",
        "levels_fade", "levels_he_lvl_num", "levels_slot_lvl_num", "levels_buy", "levels_sell", "levels_level_price"
};
 
new const CvarsAmmount[Cvars][] = {
        "1", "5", "5000", "1", "1",
        "1", "1000", "3000", "1", "1", "500"
};
 
new pCvars[Cvars];
new const g_vault_name[] = "Levels";
new g_msgid_SayText; 
 
public plugin_init() {
        register_plugin("Levels", "1.1b", "DediHost/val4o0o0(rewrite)");
        //fvault_load(g_vault_name);
        g_msg_screenfade = get_user_msgid("ScreenFade");
        RegisterHam(Ham_Spawn, "player", "fw_PlSpawn", 1);
       
        for(new Cvars:i = LOGS; i < Cvars; i++)
                pCvars[i] = register_cvar(CvarsNames[i], CvarsAmmount[i]);
               
        register_cvar("Levels", "1", FCVAR_SPONLY | FCVAR_SERVER);
        set_task(0.5, "fw_CvarsCheck");
               
        gMaxPlayers = get_maxplayers();
        teamInfo = get_user_msgid("TeamInfo")
        register_event("DeathMsg", "fw_Death", "a");
       
        register_concmd("amx_setlvl", "fw_LvlSet", ADMIN_RCON, "<nick> <num> - setni level na igrach");
        register_concmd("amx_addlvl", "fw_LvlAdd", ADMIN_RCON, "<nick> <num> - dobavi level na igrach");
        register_concmd("amx_resetlvl", "fw_LvlReset", ADMIN_RCON, "<nick> - restartirai levelite na igrach");
        register_clcmd("say /levels", "fw_LevelsCmd");
        register_clcmd("say /shop", "shopped");
        register_clcmd("BROI_KUPUVANE_NA_LEVELI", "fw_BuyLvl");
        register_clcmd("BROI_PRODAJBA_NA_LEVELI", "fw_SellLvl");
        register_clcmd ("say", "hook_say")
        register_clcmd ("say_team", "hook_teamsay")
        g_msgid_SayText = get_user_msgid("SayText"); 
        g_Max = get_maxplayers();
        register_logevent("logevent_round_end", 2, "1=Round_End"); 
        register_event("TextMsg", "logevent_round_end", "a", "2=#Game_will_restart_in")  
        gMenu = menu_create("\rLevels Menu", "h_gMenu");
        for(new i = 0; i < sizeof szgMenuItems; i++)
                menu_additem(gMenu, szgMenuItems[i]);

}


public logevent_round_end(id)
{
    for( new i = 1 ; i <= g_Max ; i++ )
    {
        if( !is_user_connected(i) )
            continue;
             
        g_round[i] = 0;
    }
}
 
public plugin_precache() {
        if(!dir_exists(gDir))
                mkdir(gDir);
               
        if(!file_exists(gLogFile))
                for(new i = 0; i < sizeof gLogFileText; i++)
                        write_file(gLogFile, gLogFileText[i]);
}
 
public fw_CvarsCheck() {
        if(get_pcvar_num(pCvars[CHAT]) == 1)
                bPrefix = true;
        else bPrefix = false;
        if(get_pcvar_num(pCvars[LOGS]) == 1)
                bLogs = true;
        else bLogs = false;
        if(get_pcvar_num(pCvars[HUD]) == 1)
                bHud = true;
        else bHud = false;
        if(get_pcvar_num(pCvars[FADE]) == 1)
                bFade = true;
        else bFade = false;
        if(get_pcvar_num(pCvars[KUPOVINA]) == 1)
                bBuy = true;
        else bBuy = false;
        if(get_pcvar_num(pCvars[PRODAJA]) == 1)
                bSell = true;
        else bSell = false;
        iKNum = get_pcvar_num(pCvars[KNUM]);
        iMax = get_pcvar_num(pCvars[MAX]);
        iLevHe = get_pcvar_num(pCvars[HE]);
        iLevSlot = get_pcvar_num(pCvars[SLOT]);
        iPrice = get_pcvar_num(pCvars[CENA]);
}
 
public fw_BuyLvl(id) {
        new szFArg[35], szText[255];
        read_argv(1, szFArg, charsmax(szFArg));
        new iFArg = str_to_num(szFArg);
        if(iFArg <= 0)
                formatex(szText, charsmax(szText), "Nevaliden nomer na vpisvaneto");
        else {
                new iUserMoney = cs_get_user_money(id);
                new iCena = iPrice * iFArg;
                if(iUserMoney < iCena)
                        formatex(szText, charsmax(szText), "Ne razpolagash s dostatuchno pari za^3 %i^1 level. Trqbvat ti^3 %i", iFArg, iCena);
                else {
                        iLevels[id] += iFArg;
                        cs_set_user_money(id, iUserMoney - iCena);
                        formatex(szText, charsmax(szText), "Zakupi si^3 %i^1 levela za^3 %i^1$", iFArg, iCena);
                }
        }
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 %s", szText);
}
 
public fw_SellLvl(id) {
        new szFArg[35], szText[255];
        read_argv(1, szFArg, charsmax(szFArg));
        new iFArg = str_to_num(szFArg);
        if(iFArg <= 0)
                formatex(szText, charsmax(szText), "Pogreshen broi leveli");
        else {
                if(iLevels[id] < iFArg)
                        formatex(szText, charsmax(szText), "Nemas dovoljno levela, mozes da prodas najvise^3 %i^1 levela", iLevels[id]);
                else {
                        new iCena = iPrice * iFArg;
                        iLevels[id] -= iFArg;
                        cs_set_user_money(id, cs_get_user_money(id) + iCena);
                        formatex(szText, charsmax(szText), "Prodade si^3 %i^1 levela za^3 %i^1$", iFArg, iCena);
                }
        }
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 %s", szText);
}
 
public fw_PlSpawn(id) {
if(is_user_alive(id) && (iLevels[id] >= iLevHe)) {
give_item(id, "weapon_hegrenade");
}

if(is_user_alive(id)) {
new leveli[30], kilovi[30],points[33],money[60],szNum[55]
new szName[32]
get_user_name(id, szName, 31)
fvault_get_data(g_vault_name, szName, szNum, 101);
parse(szNum, leveli, charsmax(leveli), kilovi, charsmax(kilovi),points,charsmax(points),money,charsmax(money));
iLevels[id] = str_to_num(leveli);
iKills[id] = str_to_num(kilovi);
iPoints[id] = str_to_num(points);
iMoney[id] = str_to_num(money) + random_num(1000,3000);
}

set_task(0.5,"money",id)
}    

public money(id) {
if(is_user_connected(id)) {
if(iMoney[id] == 0) {
cs_set_user_money(id,800);
} else {
cs_set_user_money(id,iMoney[id]);
}
} 
}  
                
 
public fw_LevelsCmd(id)
        menu_display(id, gMenu);
 
public h_gMenu(id, menu, item) {
        switch(item) {
                case MENU_EXIT: return PLUGIN_HANDLED;
                case 0: {
                        if(!bBuy)
                                ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Opciqta e izkliu4ena");
                        else {
                                client_cmd(id, "messagemode BROI_KUPUVANE_NA_LEVELI");
                                ColorChat(id, GREEN, "[Levels] Broi leveli za zakupuvane, vseki e na cena: %i", iPrice);
                        }
                }
                case 1: {
                        if(!bSell)
                                ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Opciqta e izkliu4ena");
                        else {
                                client_cmd(id, "messagemode BROI_PRODAJBA_NA_LEVELI");
                                ColorChat(id, GREEN, "[Levels] Broi leveli za prodajba, cena na level: %i", iPrice);
                        }
                }
                case 2: {
                        set_hudmessage(255, 0, 0, -1.0, 0.49, 0, 6.0, 12.0);
                        show_hudmessage(id, "Pogledni si konzolata");
                        new num, players[32], player;
                        get_players(players, num, "a");
                        console_print(id, "=============================================");
                        console_print(id, " ^nList s igrachite na servera^n ");
                        for(new i = 0; i < num; i++) {
                                player = players[i];
                                new szName[35];
                                get_user_name(player, szName, charsmax(szName));
                                console_print(id, "Igrach: %s | Levels: %i | Kills: %i | Points: %i", szName, iLevels[player], iKills[player],iPoints[player]);
                        }
                        console_print(id, " ^n=============================================");
                }
                case 3: {
                        set_hudmessage(255, 0, 0, -1.0, 0.49, 0, 6.0, 12.0);
                        show_hudmessage(id, "Pogledni si konzolata");
                        console_print(id, "============================================= ^n ");
                        console_print(id, "Posle %i kill-ova dobicete visi level", iKNum);
                        console_print(id, "Maksimalen broi leveli %i", iMax);
                        if(bPrefix)
                        console_print(id, "* Prefix v chata za kolichestvoto leveli na daden igrach");
                        if(bHud)
                        console_print(id, "* Statistika pod radara za vashite leveli i nujni ubiistva za novi takiva!");
                        if(bFade)
                        console_print(id, "* Fade na ekrana pri vidigane na level");
                        if(iLevHe <= iMax)
                        console_print(id, "Sled %i levela, igracha poluchava he granata pri rajdane!", iLevHe);
                        if(iLevSlot <= iMax)
                        console_print(id, "Sled %i levela, igracha poluchava rezerviran slot!", iLevSlot);
                        console_print(id, " ");
                        console_print(id, "Admin komandi: ^n ");
                        console_print(id, "amx_setlvl <nick> <num> - setva na igrach leveli");
                        console_print(id, "amx_addlvl <nick> <num> - dava na igrach leveli");
                        console_print(id, "amx_resetlvl <nick> - restartira na igrach leveli");
                        console_print(id, " ^n=============================================");
                }
        }
        return PLUGIN_HANDLED;
}
 
public fw_LvlSet(id, level, cid) {
        if(!cmd_access(id, level, cid, 3))
        return PLUGIN_HANDLED;
        new szFArg[35], szSArg[16];
        read_argv(1, szFArg, charsmax(szFArg));
        read_argv(2, szSArg, charsmax(szSArg));
        new iNum = str_to_num(szSArg);
        new gTarget = cmd_target(id, szFArg, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS | CMDTARGET_OBEY_IMMUNITY);
        if(!is_user_connected(gTarget) || iNum > iMax)
        return PLUGIN_HANDLED;
        new szPlName[35], szAdmName[35];
        iLevels[gTarget] = iNum;
        get_user_name(id, szAdmName, charsmax(szAdmName));
        get_user_name(gTarget, szPlName, charsmax(szPlName));
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Setnahte na Igrach^3 %s^1 broi leveli^3 %s", szPlName, iNum);
        ColorChat(gTarget, TEAM_COLOR, "^4[Levels]^1 Admin^3 %s^1 ti setna ^3 %s level", szAdmName, iNum);
        if(bLogs) {
                new szText[250];
                formatex(szText, charsmax(szText), "[amx_setlvl] Admin: %s | Igrach: %s | Levels: %i", szAdmName, szPlName, iNum);
                write_file(gLogFile, szText);
        }
        return PLUGIN_HANDLED;
}
 
public fw_LvlAdd(id, level, cid) {
        if(!cmd_access(id, level, cid, 3))
        return PLUGIN_HANDLED;
        new szFArg[35], szSArg[16];
        read_argv(1, szFArg, charsmax(szFArg));
        read_argv(2, szSArg, charsmax(szSArg));
        new iNum = str_to_num(szSArg);
        new gTarget = cmd_target(id, szFArg, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS | CMDTARGET_OBEY_IMMUNITY);
        if(!is_user_connected(gTarget) || ((iLevels[gTarget] + iNum) > iMax))
        return PLUGIN_HANDLED;
        new szPlName[35], szAdmName[35];
        iLevels[gTarget] += iNum;
        get_user_name(id, szAdmName, charsmax(szAdmName));
        get_user_name(gTarget, szPlName, charsmax(szPlName));
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Dobavihte na igrach^3 %s^4 %i^1 levela", szPlName, iNum);
        ColorChat(gTarget, TEAM_COLOR, "^4[Levels]^1 Admin^3 %s^1 ti dade ^3 %s^1 levela", szAdmName, iNum);
        if(bLogs) {
                new szText[250];
                formatex(szText, charsmax(szText), "[amx_addlvl] Admin: %s | Igrach: %s | Levels: %i", szAdmName, szPlName, iNum);
                write_file(gLogFile, szText);
        }
        return PLUGIN_HANDLED;
}
 
public fw_LvlReset(id, level, cid) {
        if(!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED;
        new szFArg[35];
        read_argv(1, szFArg, charsmax(szFArg));
        new gTarget = cmd_target(id, szFArg, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS | CMDTARGET_OBEY_IMMUNITY);
        if(!is_user_connected(gTarget))
        return PLUGIN_HANDLED;
        new szPlName[35], szAdmName[35];
        iLevels[gTarget] = 0;
        get_user_name(id, szAdmName, charsmax(szAdmName));
        get_user_name(gTarget, szPlName, charsmax(szPlName));
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Resnahte na igrach ^3 %s^1 levelite", szPlName);
        ColorChat(gTarget, TEAM_COLOR, "^4[Levels]^1 Admin^3 %s^1 ti restartira levelite!", szAdmName);
        if(bLogs) {
                new szText[250];
                formatex(szText, charsmax(szText), "[amx_resetlvl] Admin: %s | Igrach: %s", szAdmName, szPlName);
                write_file(gLogFile, szText);
        }
        return PLUGIN_HANDLED;
}
 
 
public client_putinserver(id) {
        new szNum[55], leveli[30], kilovi[30],points[33],money[60]
        new szName[32]
        get_user_name(id, szName, 31)

        parse(szNum, leveli, charsmax(leveli), kilovi, charsmax(kilovi),points,charsmax(points));
        iLevels[id] = str_to_num(leveli);
        iKills[id] = str_to_num(kilovi);
        iPoints[id] = str_to_num(points);
        iMoney[id] = str_to_num(money);
        set_task(3.0, "fw_HudInfo", id);
        set_task(3.0, "fw_chatInfo", id);
        if(iLevels[id] >= iLevSlot) {
        server_cmd("amx_addadmin ^"%s^" ^"b^" ^"^" ^"id^"", szName);
        server_exec();
        }
}
 
 
public fw_HudInfo(id) {
        if(is_user_connected(id) && bHud) {
                set_hudmessage(0, 255, 0, 0.02, 0.17, 0, 6.0, 12.0);
                show_hudmessage(id, "[ Level: %i ] ^n[ Kills: %i / %i / Points: %i]", iLevels[id], iKills[id], iKNum, iPoints[id]);
                set_task(3.0, "fw_HudInfo", id);
                
        }
}

public fw_chatInfo(id) {
if(is_user_alive(id) && iLevels[id] >= iLevSlot) {
ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Chestito, poluchi rezerviran slot, poradi tvoite ^3 %i^1 levela", iLevSlot);
}
}
 
public client_disconnect(id) {
if(!is_user_connected(id)) return
remove_task(id);
g_speed[id] = 0;
g_round[id] = 0;
new szNum[55];
formatex(szNum, charsmax(szNum), "%i %i %i %i", iLevels[id], iKills[id],iPoints[id],cs_get_user_money(id));
new szName[32]
get_user_name(id, szName, 31)
fvault_set_data(g_vault_name, szName, szNum);
 
}
 
public fw_Death() {
        new id = read_data(1);
        new id2 = read_data(2);
	g_round[id2] = 0
        if(is_user_connected(id2)) {
        cs_reset_user_model(id2);
        set_user_rendering(id2);
        g_speed[id2] = 0;
        set_user_gravity(id2,1.0);
        }
        if(is_user_connected(id))
        {
                new szNum[55]
                formatex(szNum, charsmax(szNum), "%i %i %i %i", iLevels[id], iKills[id],iPoints[id],cs_get_user_money(id));
                new szName[32]
                get_user_name(id, szName, 31)
                fvault_set_data(g_vault_name, szName, szNum);
        }
        if(id <= gMaxPlayers) {
                if(is_user_connected(id)) {
                        iKills[id]++;
                        iPoints[id]++;
                        if(iLevels[id] >= iMax)
                        return;
                        set_hudmessage(255, 0, 0, -1.0, 0.62, 0, 6.0, 12.0);
                        if(iKills[id] == iKNum) {
                                iLevels[id]++;
                                iPoints[id] += 100;
                                iKills[id] = 0;
                                show_hudmessage(id, "[ Ti si na nivo %i ]", iLevels[id]);
                                if(bFade)
                                set_user_fade(id);
                        }
                        else show_hudmessage(id, "[ %i / %i Kills  / %i Points]", iKills[id], iKNum, iPoints[id]);
                }
        }
}


public hook_say(client) 
{ 
    new said[192]; 
    if( !IsValidMessage(said, charsmax(said)) || !IsValidMessage2(said) || said[0] == '@' || said[0] == '#' || said[0] == '#' || said[0] == '/' || equal(said, "") || said[0] == '^0' || !strlen(said)) {
		return PLUGIN_HANDLED_MAIN
	  }
     
    new name[32]; 
    get_user_name(client, name, sizeof(name) - 1); 
     
    new alive = is_user_alive(client); 
     
    new tag[9]; 
    if( get_user_team(client) == 3 ) 
    { 
        copy(tag, sizeof(tag) - 1, "*SPEC* "); 
    } 
    else if( !alive ) 
    { 
        copy(tag, sizeof(tag) - 1, "*DEAD* "); 
    } 
     


    new message[192], teamName[10]; 
    
    if(!(get_user_flags(client) & ADMIN_CHAT)) formatex(message, sizeof(message) - 1, "^x01%s^x04[ Level: %i ]^x03 %s^x01 :  %s",  tag,  iLevels[client], name, said); 
    else formatex(message, sizeof(message) - 1, "^x01%s^x04[ Level: %i ]^x03 %s^x01 :  ^x04%s",  tag,  iLevels[client], name, said); 
    
    trim(message)
    if (contain(message, "@") != -1 ) {
    return PLUGIN_HANDLED
    }

    for( new i = 1; i <= gMaxPlayers; i++ ) 
    { 
        if(is_user_alive(i) != alive ) continue 
        
        if(!(get_user_flags(client) & ADMIN_CHAT)) writeMessage(i, message)		// Writes the message on player's chat 
        else
        {
                get_user_team(i, teamName, 9)	// Stores user's team name to change back after sending the message		
                changeTeamInfo(i, "SPECTATOR")		// Changes user's team according to color choosen
                writeMessage(i, message)		// Writes the message on player's chat 
                changeTeamInfo(i, teamName)	// Changes user's team back to original
        }
    } 
     
   
 
    return PLUGIN_HANDLED_MAIN
} 

public hook_teamsay(client) 
{ 
    new said[192]; 
    if( !IsValidMessage(said, charsmax(said)) || !IsValidMessage2(said) || said[0] == '@' || said[0] == '#' || said[0] == '#' || said[0] == '/' || equal(said, "") || said[0] == '^0' || !strlen(said)) {
		return PLUGIN_HANDLED_MAIN
	  }
     
    new name[32]; 
    get_user_name(client, name, sizeof(name) - 1); 
     
    new alive = is_user_alive(client); 
     
    new CsTeams:team = cs_get_user_team(client); 
     


    new message[192], teamName[10]; 
    
    if(!(get_user_flags(client) & ADMIN_CHAT)) formatex(message, sizeof(message) - 1, "^x01%s^x04[ Level: %i ]^x03 %s^x01 :  %s", g_team_names[team], iLevels[client],name, said); 
    else formatex(message, sizeof(message) - 1, "^x01%s^x04[ Level: %i ]^x03 %s^x01 :  ^x04%s", g_team_names[team], iLevels[client],name, said); 
    
    if (contain(message, "@") != -1) {
    return PLUGIN_HANDLED
    }

    for( new i = 1; i <= gMaxPlayers; i++ ) 
    { 
        if(is_user_alive(i) != alive || get_user_team(i) != get_user_team(client) ) continue 
        
        if(!(get_user_flags(client) & ADMIN_CHAT)) writeMessage(i, message)		// Writes the message on player's chat 
        else
        {
                get_user_team(i, teamName, 9)	// Stores user's team name to change back after sending the message		
                changeTeamInfo(i, "SPECTATOR")		// Changes user's team according to color choosen
                writeMessage(i, message)		// Writes the message on player's chat 
                changeTeamInfo(i, teamName)	// Changes user's team back to original
        }
    } 
     
     
    return PLUGIN_HANDLED_MAIN
} 

 
stock set_user_fade(index) {
        message_begin(MSG_ONE_UNRELIABLE, g_msg_screenfade, _, index);
        write_short((1 << 12) * 1);
        write_short(floatround((1 << 12) * 0.1));
        write_short(0x0000);
        write_byte(0);
        write_byte(255);
        write_byte(255);
        write_byte(150);
        message_end();
}


public shopped(id) {
    new menu = menu_create( "\rSHOP - \yMENU!:", "menu_handler" );

    menu_additem( menu, "\yPOINTS \rSHOP", "", 0 );
    menu_additem( menu, "\ySNIPERS \rSHOP", "", 0 );

    menu_display( id, menu, 0 );
}


public menu_handler( id, menu, item )
 {
    switch( item )
    {
        case 0:
        {
            POINTS( id );
        }
        case 1:
        {
            SNIPERS( id );
        }
        case MENU_EXIT:
        {

        }
    }

    menu_destroy( menu );
    return PLUGIN_HANDLED;
 }

///////////////////////////////////////DEDIHOST ADDON/////////////////////////////////////////

public POINTS(id) {
    new menu = menu_create( "\rShop \wwith \rPoints", "menu_points" );
    
    menu_additem( menu, "\wInvis \r400 Points", "", 0 );
    menu_additem( menu, "\w155 HP \r100 Points", "", 0 );
    menu_additem( menu, "\wHE Grenade \r150 Points", "", 0 );
    menu_additem( menu, "\wSPEED \r400 Points", "", 0 );
    menu_additem( menu, "\wGravity \r200 Points", "", 0 );
    menu_additem( menu, "\wFrost Grenade \r200 Points", "", 0 );
    menu_additem( menu, "\wADRENALINE \r500 Points", "", 0 );

    menu_display( id, menu, 0 );
}

public SNIPERS(id) {
    new menu = menu_create( "\rSnipers Shop \wwith \yMoney", "menu_snipers" );
    
    menu_additem( menu, "\wAWP \r4000$", "", 0 );
    menu_additem( menu, "\wG3SG1 \r7000$", "", 0 );
    menu_additem( menu, "\wSG550 \r7000$", "", 0 );


    menu_display( id, menu, 0 );
}

public menu_points( id, menu, item )
{
    if(!(get_user_flags(id) & ADMIN_CHAT) && g_round[id] == 1)
    {
    ColorChat(id,GREEN,"Mojete da kopuvate samo po 1 item na smurt!");
    menu_destroy( menu );
    return PLUGIN_HANDLED;
   }
    
    switch( item )
    {
        case 0:
        {
         if(iPoints[id] < 400) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 50);
         iPoints[id] = iPoints[id] - 400;    
        }
        case 1:
        {
         if(iPoints[id] < 100) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         set_user_health(id, get_user_health(id) + 155);
         iPoints[id] = iPoints[id] - 100;       
        }
        case 2:
        {
         if(iPoints[id] < 150) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         give_item(id, "weapon_hegrenade");
         iPoints[id] = iPoints[id] - 150;               
        }
        case 3:
        {
         if(iPoints[id] < 400) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         g_speed[id] = 1;
         set_task(0.1, "speed", id + TASKID,_,_,"b");
         iPoints[id] = iPoints[id] - 400;               
        }
        case 4:
        {
         if(iPoints[id] < 200) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         set_user_gravity(id,0.4);
         iPoints[id] = iPoints[id] - 200;               
        }        
        case 5:
        {
         if(iPoints[id] < 200) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         give_frost_grenade(id)
         iPoints[id] = iPoints[id] - 200;     
        }
        case 6:
        {
         if(iPoints[id] < 500) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         set_user_health(id,255)
         give_item(id,"weapon_hegrenade");
         give_item(id,"weapon_flashbang");
         give_item(id,"weapon_flashbang");
         give_item(id,"weapon_smokegrenade");
         iPoints[id] = iPoints[id] - 500;               
        }
    }

    g_round[id] =1;
    menu_destroy( menu );
    return PLUGIN_HANDLED;
 }

public menu_snipers( id, menu, item )
{
    if(!(get_user_flags(id) & ADMIN_CHAT) && g_round[id] == 1)
    {
    ColorChat(id,GREEN,"Mojete da kopuvate samo po 1 item na smurt!");
    menu_destroy( menu );
    return PLUGIN_HANDLED;
   }
    switch( item )
    {
        case 0:
        {
            if(cs_get_user_money(id) < 4000) {ColorChat(id,GREEN,"Nqmash dostatucho pari!"); return PLUGIN_HANDLED;}
            give_item(id, "weapon_awp");
            cs_set_user_bpammo(id, CSW_AWP, 90);
            cs_set_user_money(id,cs_get_user_money(id) - 4000);
        }
        case 1:
        {
            if(cs_get_user_money(id) < 7000) {ColorChat(id,GREEN,"Nqmash dostatucho pari!"); return PLUGIN_HANDLED;}
            give_item(id, "weapon_g3sg1");
            cs_set_user_bpammo(id, CSW_G3SG1, 90);
            cs_set_user_money(id,cs_get_user_money(id) - 7000);
        }
        case 2:
        {
            if(cs_get_user_money(id) < 7000) {ColorChat(id,GREEN,"Nqmash dostatucho pari!"); return PLUGIN_HANDLED;}
            give_item(id, "weapon_sg550");
            cs_set_user_bpammo(id, CSW_SG550, 90);
            cs_set_user_money(id,cs_get_user_money(id) - 7000);
        }
        case MENU_EXIT:
        {

        }
    }

    g_round[id] =1;
    menu_destroy( menu );
    return PLUGIN_HANDLED;
}

public speed(TASK) {
new id = TASK - TASKID;
if(g_speed[id] == 1) {
set_user_maxspeed(id, 500.0);
}
}

bool:IsValidMessage( szMessage[ ], iLen )
{
	read_args( szMessage, iLen )
	remove_quotes( szMessage )
	
	new iPos, cChar
	while( 0 <= ( cChar = szMessage[ iPos++ ] ) <= 255 )
	{
		if( cChar != ' ' && cChar != '%')
		{
			return true
		}
	}
	
	return false
}

bool:IsValidMessage2(const said[])
{
    new i, c
    while( (c = said[i++]) != 0 )
    {
        if( c != ' ' )
        {
            return true
        }
    }
    return false
} 

public changeTeamInfo(player, team[])
{
	message_begin(MSG_ONE, teamInfo, _, player)	// Tells to to modify teamInfo (Which is responsable for which time player is)
	write_byte(player)				// Write byte needed
	write_string(team)				// Changes player's team
	message_end()					// Also Needed
}

public writeMessage(player, message[])
{
	message_begin(MSG_ONE, g_msgid_SayText, {0, 0, 0}, player)	// Tells to modify sayText (Which is responsable for writing colored messages)
	write_byte(player)					// Write byte needed
	write_string(message)					// Effectively write the message, finally, afterall
	message_end()						// Needed as always
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1026\\ f0\\ fs16 \n\\ par }
*/
 #392212  от OciXCrom™
 вт юни 07, 2016 7:51 pm
Аз лично не видях функция, която взима данните при влез на играча в сървъра. Опитай така, но нищо не обещам, тъй като частта за запазване на данните е доста зле.
Код: Избери всички
#include <amxmodx>
#include <colorchat>
#include <fvault>
#include <amxmisc>
#include <hamsandwich>
#include <fun>
#include <cstrike>
#include <frostnades>

new g_round[33] = 0;
new g_speed[33] = 0;
#define TASKID 1994
new iPoints[33];
new iMoney[33];
new g_Max;
new teamInfo
new gMaxPlayers, iLevels[33], iKills[33], g_msg_screenfade;
new bool:bPrefix, bool:bLogs, bool:bHud, gMenu, iKNum, iMax, bool:bFade, iLevHe, iLevSlot;
new bool:bBuy, bool:bSell, iPrice;
new const szgMenuItems[][] = { "Kupi Leveli", "Prodai Leveli", "\yList s igrachi", "\rInfo" };
new const gLogFile[] = "addons/amxmodx/configs/levels/LvlsAdmCmdsLogs.txt";
new const gDir[] = "addons/amxmodx/configs/levels/";


/*
         ==========================CVARS============================
        "levels_logs ^"1^" // da logva li admin komandite ot plugina",
        "levels_num_to_next ^"5^" // sled kolko ubiistva da dava sledvasht level",
        "levels_max_levels ^"5000^" // maksimalen broi leveli",
        "levels_chat_prefix ^"1^" //da ima li prefix pred nicka",
        "levels_hud_info ^"1^" // da ima li hud informaciq pod radara za levelite",
        "levels_fade ^"1^" // da ima li fade pri digane na nov level",
        "levels_he_lvl_num ^"1000^" // sled kolko levela da dava he granata pri spawn",
       
        "; za izkliu4vane ostavi stoinosta na max_levels cvar-a",
        "levels_slot_lvl_num ^"3000^" // sled kolko levela da dava reservation slot na igracha",
       
        "; za izkliu4vane ostavi stoinosta na max_levels cvar-a",
        "levels_buy ^"1^" // da moje li da se kupuvat leveli",
        "levels_sell ^"1^" // da moje li da se prodavat leveli",
        "levels_level_price ^"500^" // kolko da struva edin level v $"
*/
 
new const gLogFileText[][] = {
        "Log",
        "logvat se slednite komandi: amx_setlvl, amx_addlvl i amx_resetlvl",
        "====================================================================^n "
};

new const g_team_names[CsTeams][] =
{
    "(Spectator) ",
    "(Terrorist) ",
    "(Counter-Terrorist) ",
    "(Spectator) "
};
 
enum Cvars {
        LOGS, KNUM, MAX, CHAT, HUD,
        FADE, HE, SLOT, KUPOVINA, PRODAJA, CENA
}
 
new const CvarsNames[Cvars][] = {
        "levels_logs", "levels_num_to_next", "levels_max_levels", "levels_chat_prefix", "levels_hud_info",
        "levels_fade", "levels_he_lvl_num", "levels_slot_lvl_num", "levels_buy", "levels_sell", "levels_level_price"
};
 
new const CvarsAmmount[Cvars][] = {
        "1", "5", "5000", "1", "1",
        "1", "1000", "3000", "1", "1", "500"
};
 
new pCvars[Cvars];
new const g_vault_name[] = "Levels";
new g_msgid_SayText;
 
public plugin_init() {
        register_plugin("Levels", "1.1b", "DediHost/val4o0o0(rewrite)");
        //fvault_load(g_vault_name);
        g_msg_screenfade = get_user_msgid("ScreenFade");
        RegisterHam(Ham_Spawn, "player", "fw_PlSpawn", 1);
       
        for(new Cvars:i = LOGS; i < Cvars; i++)
                pCvars[i] = register_cvar(CvarsNames[i], CvarsAmmount[i]);
               
        register_cvar("Levels", "1", FCVAR_SPONLY | FCVAR_SERVER);
        set_task(0.5, "fw_CvarsCheck");
               
        gMaxPlayers = get_maxplayers();
        teamInfo = get_user_msgid("TeamInfo")
        register_event("DeathMsg", "fw_Death", "a");
       
        register_concmd("amx_setlvl", "fw_LvlSet", ADMIN_RCON, "<nick> <num> - setni level na igrach");
        register_concmd("amx_addlvl", "fw_LvlAdd", ADMIN_RCON, "<nick> <num> - dobavi level na igrach");
        register_concmd("amx_resetlvl", "fw_LvlReset", ADMIN_RCON, "<nick> - restartirai levelite na igrach");
        register_clcmd("say /levels", "fw_LevelsCmd");
        register_clcmd("say /shop", "shopped");
        register_clcmd("BROI_KUPUVANE_NA_LEVELI", "fw_BuyLvl");
        register_clcmd("BROI_PRODAJBA_NA_LEVELI", "fw_SellLvl");
        register_clcmd ("say", "hook_say")
        register_clcmd ("say_team", "hook_teamsay")
        g_msgid_SayText = get_user_msgid("SayText");
        g_Max = get_maxplayers();
        register_logevent("logevent_round_end", 2, "1=Round_End");
        register_event("TextMsg", "logevent_round_end", "a", "2=#Game_will_restart_in") 
        gMenu = menu_create("\rLevels Menu", "h_gMenu");
        for(new i = 0; i < sizeof szgMenuItems; i++)
                menu_additem(gMenu, szgMenuItems[i]);

}


public logevent_round_end(id)
{
    for( new i = 1 ; i <= g_Max ; i++ )
    {
        if( !is_user_connected(i) )
            continue;
             
        g_round[i] = 0;
    }
}
 
public plugin_precache() {
        if(!dir_exists(gDir))
                mkdir(gDir);
               
        if(!file_exists(gLogFile))
                for(new i = 0; i < sizeof gLogFileText; i++)
                        write_file(gLogFile, gLogFileText[i]);
}
 
public fw_CvarsCheck() {
        if(get_pcvar_num(pCvars[CHAT]) == 1)
                bPrefix = true;
        else bPrefix = false;
        if(get_pcvar_num(pCvars[LOGS]) == 1)
                bLogs = true;
        else bLogs = false;
        if(get_pcvar_num(pCvars[HUD]) == 1)
                bHud = true;
        else bHud = false;
        if(get_pcvar_num(pCvars[FADE]) == 1)
                bFade = true;
        else bFade = false;
        if(get_pcvar_num(pCvars[KUPOVINA]) == 1)
                bBuy = true;
        else bBuy = false;
        if(get_pcvar_num(pCvars[PRODAJA]) == 1)
                bSell = true;
        else bSell = false;
        iKNum = get_pcvar_num(pCvars[KNUM]);
        iMax = get_pcvar_num(pCvars[MAX]);
        iLevHe = get_pcvar_num(pCvars[HE]);
        iLevSlot = get_pcvar_num(pCvars[SLOT]);
        iPrice = get_pcvar_num(pCvars[CENA]);
}
 
public fw_BuyLvl(id) {
        new szFArg[35], szText[255];
        read_argv(1, szFArg, charsmax(szFArg));
        new iFArg = str_to_num(szFArg);
        if(iFArg <= 0)
                formatex(szText, charsmax(szText), "Nevaliden nomer na vpisvaneto");
        else {
                new iUserMoney = cs_get_user_money(id);
                new iCena = iPrice * iFArg;
                if(iUserMoney < iCena)
                        formatex(szText, charsmax(szText), "Ne razpolagash s dostatuchno pari za^3 %i^1 level. Trqbvat ti^3 %i", iFArg, iCena);
                else {
                        iLevels[id] += iFArg;
                        cs_set_user_money(id, iUserMoney - iCena);
                        formatex(szText, charsmax(szText), "Zakupi si^3 %i^1 levela za^3 %i^1$", iFArg, iCena);
                }
        }
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 %s", szText);
}
 
public fw_SellLvl(id) {
        new szFArg[35], szText[255];
        read_argv(1, szFArg, charsmax(szFArg));
        new iFArg = str_to_num(szFArg);
        if(iFArg <= 0)
                formatex(szText, charsmax(szText), "Pogreshen broi leveli");
        else {
                if(iLevels[id] < iFArg)
                        formatex(szText, charsmax(szText), "Nemas dovoljno levela, mozes da prodas najvise^3 %i^1 levela", iLevels[id]);
                else {
                        new iCena = iPrice * iFArg;
                        iLevels[id] -= iFArg;
                        cs_set_user_money(id, cs_get_user_money(id) + iCena);
                        formatex(szText, charsmax(szText), "Prodade si^3 %i^1 levela za^3 %i^1$", iFArg, iCena);
                }
        }
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 %s", szText);
}
 
public fw_PlSpawn(id) {
if(is_user_alive(id) && (iLevels[id] >= iLevHe)) {
give_item(id, "weapon_hegrenade");
}

if(is_user_alive(id)) {
new leveli[30], kilovi[30],points[33],money[60],szNum[55]
new szName[32]
get_user_name(id, szName, 31)
fvault_get_data(g_vault_name, szName, szNum, 101);
parse(szNum, leveli, charsmax(leveli), kilovi, charsmax(kilovi),points,charsmax(points),money,charsmax(money));
iLevels[id] = str_to_num(leveli);
iKills[id] = str_to_num(kilovi);
iPoints[id] = str_to_num(points);
iMoney[id] = str_to_num(money) + random_num(1000,3000);
}

set_task(0.5,"money",id)
}   

public money(id) {
if(is_user_connected(id)) {
if(iMoney[id] == 0) {
cs_set_user_money(id,800);
} else {
cs_set_user_money(id,iMoney[id]);
}
}
} 
               
 
public fw_LevelsCmd(id)
        menu_display(id, gMenu);
 
public h_gMenu(id, menu, item) {
        switch(item) {
                case MENU_EXIT: return PLUGIN_HANDLED;
                case 0: {
                        if(!bBuy)
                                ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Opciqta e izkliu4ena");
                        else {
                                client_cmd(id, "messagemode BROI_KUPUVANE_NA_LEVELI");
                                ColorChat(id, GREEN, "[Levels] Broi leveli za zakupuvane, vseki e na cena: %i", iPrice);
                        }
                }
                case 1: {
                        if(!bSell)
                                ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Opciqta e izkliu4ena");
                        else {
                                client_cmd(id, "messagemode BROI_PRODAJBA_NA_LEVELI");
                                ColorChat(id, GREEN, "[Levels] Broi leveli za prodajba, cena na level: %i", iPrice);
                        }
                }
                case 2: {
                        set_hudmessage(255, 0, 0, -1.0, 0.49, 0, 6.0, 12.0);
                        show_hudmessage(id, "Pogledni si konzolata");
                        new num, players[32], player;
                        get_players(players, num, "a");
                        console_print(id, "=============================================");
                        console_print(id, " ^nList s igrachite na servera^n ");
                        for(new i = 0; i < num; i++) {
                                player = players[i];
                                new szName[35];
                                get_user_name(player, szName, charsmax(szName));
                                console_print(id, "Igrach: %s | Levels: %i | Kills: %i | Points: %i", szName, iLevels[player], iKills[player],iPoints[player]);
                        }
                        console_print(id, " ^n=============================================");
                }
                case 3: {
                        set_hudmessage(255, 0, 0, -1.0, 0.49, 0, 6.0, 12.0);
                        show_hudmessage(id, "Pogledni si konzolata");
                        console_print(id, "============================================= ^n ");
                        console_print(id, "Posle %i kill-ova dobicete visi level", iKNum);
                        console_print(id, "Maksimalen broi leveli %i", iMax);
                        if(bPrefix)
                        console_print(id, "* Prefix v chata za kolichestvoto leveli na daden igrach");
                        if(bHud)
                        console_print(id, "* Statistika pod radara za vashite leveli i nujni ubiistva za novi takiva!");
                        if(bFade)
                        console_print(id, "* Fade na ekrana pri vidigane na level");
                        if(iLevHe <= iMax)
                        console_print(id, "Sled %i levela, igracha poluchava he granata pri rajdane!", iLevHe);
                        if(iLevSlot <= iMax)
                        console_print(id, "Sled %i levela, igracha poluchava rezerviran slot!", iLevSlot);
                        console_print(id, " ");
                        console_print(id, "Admin komandi: ^n ");
                        console_print(id, "amx_setlvl <nick> <num> - setva na igrach leveli");
                        console_print(id, "amx_addlvl <nick> <num> - dava na igrach leveli");
                        console_print(id, "amx_resetlvl <nick> - restartira na igrach leveli");
                        console_print(id, " ^n=============================================");
                }
        }
        return PLUGIN_HANDLED;
}
 
public fw_LvlSet(id, level, cid) {
        if(!cmd_access(id, level, cid, 3))
        return PLUGIN_HANDLED;
        new szFArg[35], szSArg[16];
        read_argv(1, szFArg, charsmax(szFArg));
        read_argv(2, szSArg, charsmax(szSArg));
        new iNum = str_to_num(szSArg);
        new gTarget = cmd_target(id, szFArg, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS | CMDTARGET_OBEY_IMMUNITY);
        if(!is_user_connected(gTarget) || iNum > iMax)
        return PLUGIN_HANDLED;
        new szPlName[35], szAdmName[35];
        iLevels[gTarget] = iNum;
        get_user_name(id, szAdmName, charsmax(szAdmName));
        get_user_name(gTarget, szPlName, charsmax(szPlName));
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Setnahte na Igrach^3 %s^1 broi leveli^3 %s", szPlName, iNum);
        ColorChat(gTarget, TEAM_COLOR, "^4[Levels]^1 Admin^3 %s^1 ti setna ^3 %s level", szAdmName, iNum);
        if(bLogs) {
                new szText[250];
                formatex(szText, charsmax(szText), "[amx_setlvl] Admin: %s | Igrach: %s | Levels: %i", szAdmName, szPlName, iNum);
                write_file(gLogFile, szText);
        }
        return PLUGIN_HANDLED;
}
 
public fw_LvlAdd(id, level, cid) {
        if(!cmd_access(id, level, cid, 3))
        return PLUGIN_HANDLED;
        new szFArg[35], szSArg[16];
        read_argv(1, szFArg, charsmax(szFArg));
        read_argv(2, szSArg, charsmax(szSArg));
        new iNum = str_to_num(szSArg);
        new gTarget = cmd_target(id, szFArg, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS | CMDTARGET_OBEY_IMMUNITY);
        if(!is_user_connected(gTarget) || ((iLevels[gTarget] + iNum) > iMax))
        return PLUGIN_HANDLED;
        new szPlName[35], szAdmName[35];
        iLevels[gTarget] += iNum;
        get_user_name(id, szAdmName, charsmax(szAdmName));
        get_user_name(gTarget, szPlName, charsmax(szPlName));
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Dobavihte na igrach^3 %s^4 %i^1 levela", szPlName, iNum);
        ColorChat(gTarget, TEAM_COLOR, "^4[Levels]^1 Admin^3 %s^1 ti dade ^3 %s^1 levela", szAdmName, iNum);
        if(bLogs) {
                new szText[250];
                formatex(szText, charsmax(szText), "[amx_addlvl] Admin: %s | Igrach: %s | Levels: %i", szAdmName, szPlName, iNum);
                write_file(gLogFile, szText);
        }
        return PLUGIN_HANDLED;
}
 
public fw_LvlReset(id, level, cid) {
        if(!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED;
        new szFArg[35];
        read_argv(1, szFArg, charsmax(szFArg));
        new gTarget = cmd_target(id, szFArg, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS | CMDTARGET_OBEY_IMMUNITY);
        if(!is_user_connected(gTarget))
        return PLUGIN_HANDLED;
        new szPlName[35], szAdmName[35];
        iLevels[gTarget] = 0;
        get_user_name(id, szAdmName, charsmax(szAdmName));
        get_user_name(gTarget, szPlName, charsmax(szPlName));
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Resnahte na igrach ^3 %s^1 levelite", szPlName);
        ColorChat(gTarget, TEAM_COLOR, "^4[Levels]^1 Admin^3 %s^1 ti restartira levelite!", szAdmName);
        if(bLogs) {
                new szText[250];
                formatex(szText, charsmax(szText), "[amx_resetlvl] Admin: %s | Igrach: %s", szAdmName, szPlName);
                write_file(gLogFile, szText);
        }
        return PLUGIN_HANDLED;
}
 
 
public client_putinserver(id) {
        new szNum[55], leveli[30], kilovi[30],points[33],money[60]
        new szName[32]
        get_user_name(id, szName, 31)
        fvault_get_data(g_vault_name, szName, szNum, 54)
        parse(szNum, leveli, charsmax(leveli), kilovi, charsmax(kilovi),points,charsmax(points));
        iLevels[id] = str_to_num(leveli);
        iKills[id] = str_to_num(kilovi);
        iPoints[id] = str_to_num(points);
        iMoney[id] = str_to_num(money);
        set_task(3.0, "fw_HudInfo", id);
        set_task(3.0, "fw_chatInfo", id);
        if(iLevels[id] >= iLevSlot) {
        server_cmd("amx_addadmin ^"%s^" ^"b^" ^"^" ^"id^"", szName);
        server_exec();
        }
}
 
 
public fw_HudInfo(id) {
        if(is_user_connected(id) && bHud) {
                set_hudmessage(0, 255, 0, 0.02, 0.17, 0, 6.0, 12.0);
                show_hudmessage(id, "[ Level: %i ] ^n[ Kills: %i / %i / Points: %i]", iLevels[id], iKills[id], iKNum, iPoints[id]);
                set_task(3.0, "fw_HudInfo", id);
               
        }
}

public fw_chatInfo(id) {
if(is_user_alive(id) && iLevels[id] >= iLevSlot) {
ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Chestito, poluchi rezerviran slot, poradi tvoite ^3 %i^1 levela", iLevSlot);
}
}
 
public client_disconnect(id) {
if(!is_user_connected(id)) return
remove_task(id);
g_speed[id] = 0;
g_round[id] = 0;
new szNum[55];
formatex(szNum, charsmax(szNum), "%i %i %i %i", iLevels[id], iKills[id],iPoints[id],cs_get_user_money(id));
new szName[32]
get_user_name(id, szName, 31)
fvault_set_data(g_vault_name, szName, szNum);
 
}
 
public fw_Death() {
        new id = read_data(1);
        new id2 = read_data(2);
   g_round[id2] = 0
        if(is_user_connected(id2)) {
        cs_reset_user_model(id2);
        set_user_rendering(id2);
        g_speed[id2] = 0;
        set_user_gravity(id2,1.0);
        }
        if(is_user_connected(id))
        {
                new szNum[55]
                formatex(szNum, charsmax(szNum), "%i %i %i %i", iLevels[id], iKills[id],iPoints[id],cs_get_user_money(id));
                new szName[32]
                get_user_name(id, szName, 31)
                fvault_set_data(g_vault_name, szName, szNum);
        }
        if(id <= gMaxPlayers) {
                if(is_user_connected(id)) {
                        iKills[id]++;
                        iPoints[id]++;
                        if(iLevels[id] >= iMax)
                        return;
                        set_hudmessage(255, 0, 0, -1.0, 0.62, 0, 6.0, 12.0);
                        if(iKills[id] == iKNum) {
                                iLevels[id]++;
                                iPoints[id] += 100;
                                iKills[id] = 0;
                                show_hudmessage(id, "[ Ti si na nivo %i ]", iLevels[id]);
                                if(bFade)
                                set_user_fade(id);
                        }
                        else show_hudmessage(id, "[ %i / %i Kills  / %i Points]", iKills[id], iKNum, iPoints[id]);
                }
        }
}


public hook_say(client)
{
    new said[192];
    if( !IsValidMessage(said, charsmax(said)) || !IsValidMessage2(said) || said[0] == '@' || said[0] == '#' || said[0] == '#' || said[0] == '/' || equal(said, "") || said[0] == '^0' || !strlen(said)) {
      return PLUGIN_HANDLED_MAIN
     }
     
    new name[32];
    get_user_name(client, name, sizeof(name) - 1);
     
    new alive = is_user_alive(client);
     
    new tag[9];
    if( get_user_team(client) == 3 )
    {
        copy(tag, sizeof(tag) - 1, "*SPEC* ");
    }
    else if( !alive )
    {
        copy(tag, sizeof(tag) - 1, "*DEAD* ");
    }
     


    new message[192], teamName[10];
   
    if(!(get_user_flags(client) & ADMIN_CHAT)) formatex(message, sizeof(message) - 1, "^x01%s^x04[ Level: %i ]^x03 %s^x01 :  %s",  tag,  iLevels[client], name, said);
    else formatex(message, sizeof(message) - 1, "^x01%s^x04[ Level: %i ]^x03 %s^x01 :  ^x04%s",  tag,  iLevels[client], name, said);
   
    trim(message)
    if (contain(message, "@") != -1 ) {
    return PLUGIN_HANDLED
    }

    for( new i = 1; i <= gMaxPlayers; i++ )
    {
        if(is_user_alive(i) != alive ) continue
       
        if(!(get_user_flags(client) & ADMIN_CHAT)) writeMessage(i, message)      // Writes the message on player's chat
        else
        {
                get_user_team(i, teamName, 9)   // Stores user's team name to change back after sending the message      
                changeTeamInfo(i, "SPECTATOR")      // Changes user's team according to color choosen
                writeMessage(i, message)      // Writes the message on player's chat
                changeTeamInfo(i, teamName)   // Changes user's team back to original
        }
    }
     
   
 
    return PLUGIN_HANDLED_MAIN
}

public hook_teamsay(client)
{
    new said[192];
    if( !IsValidMessage(said, charsmax(said)) || !IsValidMessage2(said) || said[0] == '@' || said[0] == '#' || said[0] == '#' || said[0] == '/' || equal(said, "") || said[0] == '^0' || !strlen(said)) {
      return PLUGIN_HANDLED_MAIN
     }
     
    new name[32];
    get_user_name(client, name, sizeof(name) - 1);
     
    new alive = is_user_alive(client);
     
    new CsTeams:team = cs_get_user_team(client);
     


    new message[192], teamName[10];
   
    if(!(get_user_flags(client) & ADMIN_CHAT)) formatex(message, sizeof(message) - 1, "^x01%s^x04[ Level: %i ]^x03 %s^x01 :  %s", g_team_names[team], iLevels[client],name, said);
    else formatex(message, sizeof(message) - 1, "^x01%s^x04[ Level: %i ]^x03 %s^x01 :  ^x04%s", g_team_names[team], iLevels[client],name, said);
   
    if (contain(message, "@") != -1) {
    return PLUGIN_HANDLED
    }

    for( new i = 1; i <= gMaxPlayers; i++ )
    {
        if(is_user_alive(i) != alive || get_user_team(i) != get_user_team(client) ) continue
       
        if(!(get_user_flags(client) & ADMIN_CHAT)) writeMessage(i, message)      // Writes the message on player's chat
        else
        {
                get_user_team(i, teamName, 9)   // Stores user's team name to change back after sending the message      
                changeTeamInfo(i, "SPECTATOR")      // Changes user's team according to color choosen
                writeMessage(i, message)      // Writes the message on player's chat
                changeTeamInfo(i, teamName)   // Changes user's team back to original
        }
    }
     
     
    return PLUGIN_HANDLED_MAIN
}

 
stock set_user_fade(index) {
        message_begin(MSG_ONE_UNRELIABLE, g_msg_screenfade, _, index);
        write_short((1 << 12) * 1);
        write_short(floatround((1 << 12) * 0.1));
        write_short(0x0000);
        write_byte(0);
        write_byte(255);
        write_byte(255);
        write_byte(150);
        message_end();
}


public shopped(id) {
    new menu = menu_create( "\rSHOP - \yMENU!:", "menu_handler" );

    menu_additem( menu, "\yPOINTS \rSHOP", "", 0 );
    menu_additem( menu, "\ySNIPERS \rSHOP", "", 0 );

    menu_display( id, menu, 0 );
}


public menu_handler( id, menu, item )
 {
    switch( item )
    {
        case 0:
        {
            POINTS( id );
        }
        case 1:
        {
            SNIPERS( id );
        }
        case MENU_EXIT:
        {

        }
    }

    menu_destroy( menu );
    return PLUGIN_HANDLED;
 }

///////////////////////////////////////DEDIHOST ADDON/////////////////////////////////////////

public POINTS(id) {
    new menu = menu_create( "\rShop \wwith \rPoints", "menu_points" );
   
    menu_additem( menu, "\wInvis \r400 Points", "", 0 );
    menu_additem( menu, "\w155 HP \r100 Points", "", 0 );
    menu_additem( menu, "\wHE Grenade \r150 Points", "", 0 );
    menu_additem( menu, "\wSPEED \r400 Points", "", 0 );
    menu_additem( menu, "\wGravity \r200 Points", "", 0 );
    menu_additem( menu, "\wFrost Grenade \r200 Points", "", 0 );
    menu_additem( menu, "\wADRENALINE \r500 Points", "", 0 );

    menu_display( id, menu, 0 );
}

public SNIPERS(id) {
    new menu = menu_create( "\rSnipers Shop \wwith \yMoney", "menu_snipers" );
   
    menu_additem( menu, "\wAWP \r4000$", "", 0 );
    menu_additem( menu, "\wG3SG1 \r7000$", "", 0 );
    menu_additem( menu, "\wSG550 \r7000$", "", 0 );


    menu_display( id, menu, 0 );
}

public menu_points( id, menu, item )
{
    if(!(get_user_flags(id) & ADMIN_CHAT) && g_round[id] == 1)
    {
    ColorChat(id,GREEN,"Mojete da kopuvate samo po 1 item na smurt!");
    menu_destroy( menu );
    return PLUGIN_HANDLED;
   }
   
    switch( item )
    {
        case 0:
        {
         if(iPoints[id] < 400) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 50);
         iPoints[id] = iPoints[id] - 400;   
        }
        case 1:
        {
         if(iPoints[id] < 100) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         set_user_health(id, get_user_health(id) + 155);
         iPoints[id] = iPoints[id] - 100;       
        }
        case 2:
        {
         if(iPoints[id] < 150) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         give_item(id, "weapon_hegrenade");
         iPoints[id] = iPoints[id] - 150;               
        }
        case 3:
        {
         if(iPoints[id] < 400) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         g_speed[id] = 1;
         set_task(0.1, "speed", id + TASKID,_,_,"b");
         iPoints[id] = iPoints[id] - 400;               
        }
        case 4:
        {
         if(iPoints[id] < 200) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         set_user_gravity(id,0.4);
         iPoints[id] = iPoints[id] - 200;               
        }       
        case 5:
        {
         if(iPoints[id] < 200) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         give_frost_grenade(id)
         iPoints[id] = iPoints[id] - 200;     
        }
        case 6:
        {
         if(iPoints[id] < 500) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         set_user_health(id,255)
         give_item(id,"weapon_hegrenade");
         give_item(id,"weapon_flashbang");
         give_item(id,"weapon_flashbang");
         give_item(id,"weapon_smokegrenade");
         iPoints[id] = iPoints[id] - 500;               
        }
    }

    g_round[id] =1;
    menu_destroy( menu );
    return PLUGIN_HANDLED;
 }

public menu_snipers( id, menu, item )
{
    if(!(get_user_flags(id) & ADMIN_CHAT) && g_round[id] == 1)
    {
    ColorChat(id,GREEN,"Mojete da kopuvate samo po 1 item na smurt!");
    menu_destroy( menu );
    return PLUGIN_HANDLED;
   }
    switch( item )
    {
        case 0:
        {
            if(cs_get_user_money(id) < 4000) {ColorChat(id,GREEN,"Nqmash dostatucho pari!"); return PLUGIN_HANDLED;}
            give_item(id, "weapon_awp");
            cs_set_user_bpammo(id, CSW_AWP, 90);
            cs_set_user_money(id,cs_get_user_money(id) - 4000);
        }
        case 1:
        {
            if(cs_get_user_money(id) < 7000) {ColorChat(id,GREEN,"Nqmash dostatucho pari!"); return PLUGIN_HANDLED;}
            give_item(id, "weapon_g3sg1");
            cs_set_user_bpammo(id, CSW_G3SG1, 90);
            cs_set_user_money(id,cs_get_user_money(id) - 7000);
        }
        case 2:
        {
            if(cs_get_user_money(id) < 7000) {ColorChat(id,GREEN,"Nqmash dostatucho pari!"); return PLUGIN_HANDLED;}
            give_item(id, "weapon_sg550");
            cs_set_user_bpammo(id, CSW_SG550, 90);
            cs_set_user_money(id,cs_get_user_money(id) - 7000);
        }
        case MENU_EXIT:
        {

        }
    }

    g_round[id] =1;
    menu_destroy( menu );
    return PLUGIN_HANDLED;
}

public speed(TASK) {
new id = TASK - TASKID;
if(g_speed[id] == 1) {
set_user_maxspeed(id, 500.0);
}
}

bool:IsValidMessage( szMessage[ ], iLen )
{
   read_args( szMessage, iLen )
   remove_quotes( szMessage )
   
   new iPos, cChar
   while( 0 <= ( cChar = szMessage[ iPos++ ] ) <= 255 )
   {
      if( cChar != ' ' && cChar != '%')
      {
         return true
      }
   }
   
   return false
}

bool:IsValidMessage2(const said[])
{
    new i, c
    while( (c = said[i++]) != 0 )
    {
        if( c != ' ' )
        {
            return true
        }
    }
    return false
}

public changeTeamInfo(player, team[])
{
   message_begin(MSG_ONE, teamInfo, _, player)   // Tells to to modify teamInfo (Which is responsable for which time player is)
   write_byte(player)            // Write byte needed
   write_string(team)            // Changes player's team
   message_end()               // Also Needed
}

public writeMessage(player, message[])
{
   message_begin(MSG_ONE, g_msgid_SayText, {0, 0, 0}, player)   // Tells to modify sayText (Which is responsable for writing colored messages)
   write_byte(player)               // Write byte needed
   write_string(message)               // Effectively write the message, finally, afterall
   message_end()                  // Needed as always
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1026\\ f0\\ fs16 \n\\ par }
*/
 
 #392215  от OciXCrom™
 вт юни 07, 2016 8:14 pm
Аз не виждам, че не се е компилирал. Тези грешки не правят никакъв проблем, просто не са правилно подредени "интервалите" във въпросните редове, тъй като не ползваме същата индентация, ако знаеш какво е това. Така или иначе, плъгинът е компилиран успешно.
 #392216  от Todorow93
 вт юни 07, 2016 8:38 pm
Сега ще го тествам да видим дали ще има оплаквания за рестартирани левели. Ако нещо не е наред ще пиша в темата.

Добавено преди 17 минути 22 секунди:
В момента системата не записва левелите по никнейм, тествах смених си името в сървъра и пак бях същия левел може ли да се направи да записва само по никнейм ?
 #392218  от OciXCrom™
 вт юни 07, 2016 8:49 pm
Тя е наравена да запазва по никнейм, няма друга опция, обаче както казах - крайно зле направен плъгин. Опитай така:
Код: Избери всички
#include <amxmodx>
#include <colorchat>
#include <fvault>
#include <amxmisc>
#include <hamsandwich>
#include <fun>
#include <cstrike>
#include <frostnades>

new g_round[33] = 0;
new g_speed[33] = 0;
#define TASKID 1994
new iPoints[33];
new iMoney[33];
new g_Max;
new teamInfo
new gMaxPlayers, iLevels[33], iKills[33], g_msg_screenfade;
new bool:bPrefix, bool:bLogs, bool:bHud, gMenu, iKNum, iMax, bool:bFade, iLevHe, iLevSlot;
new bool:bBuy, bool:bSell, iPrice;
new const szgMenuItems[][] = { "Kupi Leveli", "Prodai Leveli", "\yList s igrachi", "\rInfo" };
new const gLogFile[] = "addons/amxmodx/configs/levels/LvlsAdmCmdsLogs.txt";
new const gDir[] = "addons/amxmodx/configs/levels/";


/*
         ==========================CVARS============================
        "levels_logs ^"1^" // da logva li admin komandite ot plugina",
        "levels_num_to_next ^"5^" // sled kolko ubiistva da dava sledvasht level",
        "levels_max_levels ^"5000^" // maksimalen broi leveli",
        "levels_chat_prefix ^"1^" //da ima li prefix pred nicka",
        "levels_hud_info ^"1^" // da ima li hud informaciq pod radara za levelite",
        "levels_fade ^"1^" // da ima li fade pri digane na nov level",
        "levels_he_lvl_num ^"1000^" // sled kolko levela da dava he granata pri spawn",
       
        "; za izkliu4vane ostavi stoinosta na max_levels cvar-a",
        "levels_slot_lvl_num ^"3000^" // sled kolko levela da dava reservation slot na igracha",
       
        "; za izkliu4vane ostavi stoinosta na max_levels cvar-a",
        "levels_buy ^"1^" // da moje li da se kupuvat leveli",
        "levels_sell ^"1^" // da moje li da se prodavat leveli",
        "levels_level_price ^"500^" // kolko da struva edin level v $"
*/
 
new const gLogFileText[][] = {
        "Log",
        "logvat se slednite komandi: amx_setlvl, amx_addlvl i amx_resetlvl",
        "====================================================================^n "
};

new const g_team_names[CsTeams][] =
{
    "(Spectator) ",
    "(Terrorist) ",
    "(Counter-Terrorist) ",
    "(Spectator) "
};
 
enum Cvars {
        LOGS, KNUM, MAX, CHAT, HUD,
        FADE, HE, SLOT, KUPOVINA, PRODAJA, CENA
}
 
new const CvarsNames[Cvars][] = {
        "levels_logs", "levels_num_to_next", "levels_max_levels", "levels_chat_prefix", "levels_hud_info",
        "levels_fade", "levels_he_lvl_num", "levels_slot_lvl_num", "levels_buy", "levels_sell", "levels_level_price"
};
 
new const CvarsAmmount[Cvars][] = {
        "1", "5", "5000", "1", "1",
        "1", "1000", "3000", "1", "1", "500"
};
 
new pCvars[Cvars];
new const g_vault_name[] = "Levels";
new g_msgid_SayText;
 
public plugin_init() {
        register_plugin("Levels", "1.1b", "DediHost/val4o0o0(rewrite)");
        //fvault_load(g_vault_name);
        g_msg_screenfade = get_user_msgid("ScreenFade");
        RegisterHam(Ham_Spawn, "player", "fw_PlSpawn", 1);
       
        for(new Cvars:i = LOGS; i < Cvars; i++)
                pCvars[i] = register_cvar(CvarsNames[i], CvarsAmmount[i]);
               
        register_cvar("Levels", "1", FCVAR_SPONLY | FCVAR_SERVER);
        set_task(0.5, "fw_CvarsCheck");
               
        gMaxPlayers = get_maxplayers();
        teamInfo = get_user_msgid("TeamInfo")
        register_event("DeathMsg", "fw_Death", "a");
       
        register_concmd("amx_setlvl", "fw_LvlSet", ADMIN_RCON, "<nick> <num> - setni level na igrach");
        register_concmd("amx_addlvl", "fw_LvlAdd", ADMIN_RCON, "<nick> <num> - dobavi level na igrach");
        register_concmd("amx_resetlvl", "fw_LvlReset", ADMIN_RCON, "<nick> - restartirai levelite na igrach");
        register_clcmd("say /levels", "fw_LevelsCmd");
        register_clcmd("say /shop", "shopped");
        register_clcmd("BROI_KUPUVANE_NA_LEVELI", "fw_BuyLvl");
        register_clcmd("BROI_PRODAJBA_NA_LEVELI", "fw_SellLvl");
        register_clcmd ("say", "hook_say")
        register_clcmd ("say_team", "hook_teamsay")
        g_msgid_SayText = get_user_msgid("SayText");
        g_Max = get_maxplayers();
        register_logevent("logevent_round_end", 2, "1=Round_End");
        register_event("TextMsg", "logevent_round_end", "a", "2=#Game_will_restart_in") 
        gMenu = menu_create("\rLevels Menu", "h_gMenu");
        for(new i = 0; i < sizeof szgMenuItems; i++)
                menu_additem(gMenu, szgMenuItems[i]);

}


public logevent_round_end(id)
{
    for( new i = 1 ; i <= g_Max ; i++ )
    {
        if( !is_user_connected(i) )
            continue;
             
        g_round[i] = 0;
    }
}
 
public plugin_precache() {
        if(!dir_exists(gDir))
                mkdir(gDir);
               
        if(!file_exists(gLogFile))
                for(new i = 0; i < sizeof gLogFileText; i++)
                        write_file(gLogFile, gLogFileText[i]);
}
 
public fw_CvarsCheck() {
        if(get_pcvar_num(pCvars[CHAT]) == 1)
                bPrefix = true;
        else bPrefix = false;
        if(get_pcvar_num(pCvars[LOGS]) == 1)
                bLogs = true;
        else bLogs = false;
        if(get_pcvar_num(pCvars[HUD]) == 1)
                bHud = true;
        else bHud = false;
        if(get_pcvar_num(pCvars[FADE]) == 1)
                bFade = true;
        else bFade = false;
        if(get_pcvar_num(pCvars[KUPOVINA]) == 1)
                bBuy = true;
        else bBuy = false;
        if(get_pcvar_num(pCvars[PRODAJA]) == 1)
                bSell = true;
        else bSell = false;
        iKNum = get_pcvar_num(pCvars[KNUM]);
        iMax = get_pcvar_num(pCvars[MAX]);
        iLevHe = get_pcvar_num(pCvars[HE]);
        iLevSlot = get_pcvar_num(pCvars[SLOT]);
        iPrice = get_pcvar_num(pCvars[CENA]);
}
 
public fw_BuyLvl(id) {
        new szFArg[35], szText[255];
        read_argv(1, szFArg, charsmax(szFArg));
        new iFArg = str_to_num(szFArg);
        if(iFArg <= 0)
                formatex(szText, charsmax(szText), "Nevaliden nomer na vpisvaneto");
        else {
                new iUserMoney = cs_get_user_money(id);
                new iCena = iPrice * iFArg;
                if(iUserMoney < iCena)
                        formatex(szText, charsmax(szText), "Ne razpolagash s dostatuchno pari za^3 %i^1 level. Trqbvat ti^3 %i", iFArg, iCena);
                else {
                        iLevels[id] += iFArg;
                        cs_set_user_money(id, iUserMoney - iCena);
                        formatex(szText, charsmax(szText), "Zakupi si^3 %i^1 levela za^3 %i^1$", iFArg, iCena);
                }
        }
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 %s", szText);
}
 
public fw_SellLvl(id) {
        new szFArg[35], szText[255];
        read_argv(1, szFArg, charsmax(szFArg));
        new iFArg = str_to_num(szFArg);
        if(iFArg <= 0)
                formatex(szText, charsmax(szText), "Pogreshen broi leveli");
        else {
                if(iLevels[id] < iFArg)
                        formatex(szText, charsmax(szText), "Nemas dovoljno levela, mozes da prodas najvise^3 %i^1 levela", iLevels[id]);
                else {
                        new iCena = iPrice * iFArg;
                        iLevels[id] -= iFArg;
                        cs_set_user_money(id, cs_get_user_money(id) + iCena);
                        formatex(szText, charsmax(szText), "Prodade si^3 %i^1 levela za^3 %i^1$", iFArg, iCena);
                }
        }
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 %s", szText);
}
 
public fw_PlSpawn(id) {
if(is_user_alive(id) && (iLevels[id] >= iLevHe)) {
give_item(id, "weapon_hegrenade");
}

if(is_user_alive(id)) {
new leveli[30], kilovi[30],points[33],money[60],szNum[55]
new szName[32]
get_user_name(id, szName, 31)
fvault_get_data(g_vault_name, szName, szNum, 101);
parse(szNum, leveli, charsmax(leveli), kilovi, charsmax(kilovi),points,charsmax(points),money,charsmax(money));
iLevels[id] = str_to_num(leveli);
iKills[id] = str_to_num(kilovi);
iPoints[id] = str_to_num(points);
iMoney[id] = str_to_num(money) + random_num(1000,3000);
}

set_task(0.5,"money",id)
}   

public money(id) {
if(is_user_connected(id)) {
if(iMoney[id] == 0) {
cs_set_user_money(id,800);
} else {
cs_set_user_money(id,iMoney[id]);
}
}
} 
               
 
public fw_LevelsCmd(id)
        menu_display(id, gMenu);
 
public h_gMenu(id, menu, item) {
        switch(item) {
                case MENU_EXIT: return PLUGIN_HANDLED;
                case 0: {
                        if(!bBuy)
                                ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Opciqta e izkliu4ena");
                        else {
                                client_cmd(id, "messagemode BROI_KUPUVANE_NA_LEVELI");
                                ColorChat(id, GREEN, "[Levels] Broi leveli za zakupuvane, vseki e na cena: %i", iPrice);
                        }
                }
                case 1: {
                        if(!bSell)
                                ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Opciqta e izkliu4ena");
                        else {
                                client_cmd(id, "messagemode BROI_PRODAJBA_NA_LEVELI");
                                ColorChat(id, GREEN, "[Levels] Broi leveli za prodajba, cena na level: %i", iPrice);
                        }
                }
                case 2: {
                        set_hudmessage(255, 0, 0, -1.0, 0.49, 0, 6.0, 12.0);
                        show_hudmessage(id, "Pogledni si konzolata");
                        new num, players[32], player;
                        get_players(players, num, "a");
                        console_print(id, "=============================================");
                        console_print(id, " ^nList s igrachite na servera^n ");
                        for(new i = 0; i < num; i++) {
                                player = players[i];
                                new szName[35];
                                get_user_name(player, szName, charsmax(szName));
                                console_print(id, "Igrach: %s | Levels: %i | Kills: %i | Points: %i", szName, iLevels[player], iKills[player],iPoints[player]);
                        }
                        console_print(id, " ^n=============================================");
                }
                case 3: {
                        set_hudmessage(255, 0, 0, -1.0, 0.49, 0, 6.0, 12.0);
                        show_hudmessage(id, "Pogledni si konzolata");
                        console_print(id, "============================================= ^n ");
                        console_print(id, "Posle %i kill-ova dobicete visi level", iKNum);
                        console_print(id, "Maksimalen broi leveli %i", iMax);
                        if(bPrefix)
                        console_print(id, "* Prefix v chata za kolichestvoto leveli na daden igrach");
                        if(bHud)
                        console_print(id, "* Statistika pod radara za vashite leveli i nujni ubiistva za novi takiva!");
                        if(bFade)
                        console_print(id, "* Fade na ekrana pri vidigane na level");
                        if(iLevHe <= iMax)
                        console_print(id, "Sled %i levela, igracha poluchava he granata pri rajdane!", iLevHe);
                        if(iLevSlot <= iMax)
                        console_print(id, "Sled %i levela, igracha poluchava rezerviran slot!", iLevSlot);
                        console_print(id, " ");
                        console_print(id, "Admin komandi: ^n ");
                        console_print(id, "amx_setlvl <nick> <num> - setva na igrach leveli");
                        console_print(id, "amx_addlvl <nick> <num> - dava na igrach leveli");
                        console_print(id, "amx_resetlvl <nick> - restartira na igrach leveli");
                        console_print(id, " ^n=============================================");
                }
        }
        return PLUGIN_HANDLED;
}
 
public fw_LvlSet(id, level, cid) {
        if(!cmd_access(id, level, cid, 3))
        return PLUGIN_HANDLED;
        new szFArg[35], szSArg[16];
        read_argv(1, szFArg, charsmax(szFArg));
        read_argv(2, szSArg, charsmax(szSArg));
        new iNum = str_to_num(szSArg);
        new gTarget = cmd_target(id, szFArg, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS | CMDTARGET_OBEY_IMMUNITY);
        if(!is_user_connected(gTarget) || iNum > iMax)
        return PLUGIN_HANDLED;
        new szPlName[35], szAdmName[35];
        iLevels[gTarget] = iNum;
        get_user_name(id, szAdmName, charsmax(szAdmName));
        get_user_name(gTarget, szPlName, charsmax(szPlName));
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Setnahte na Igrach^3 %s^1 broi leveli^3 %s", szPlName, iNum);
        ColorChat(gTarget, TEAM_COLOR, "^4[Levels]^1 Admin^3 %s^1 ti setna ^3 %s level", szAdmName, iNum);
        if(bLogs) {
                new szText[250];
                formatex(szText, charsmax(szText), "[amx_setlvl] Admin: %s | Igrach: %s | Levels: %i", szAdmName, szPlName, iNum);
                write_file(gLogFile, szText);
        }
        return PLUGIN_HANDLED;
}
 
public fw_LvlAdd(id, level, cid) {
        if(!cmd_access(id, level, cid, 3))
        return PLUGIN_HANDLED;
        new szFArg[35], szSArg[16];
        read_argv(1, szFArg, charsmax(szFArg));
        read_argv(2, szSArg, charsmax(szSArg));
        new iNum = str_to_num(szSArg);
        new gTarget = cmd_target(id, szFArg, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS | CMDTARGET_OBEY_IMMUNITY);
        if(!is_user_connected(gTarget) || ((iLevels[gTarget] + iNum) > iMax))
        return PLUGIN_HANDLED;
        new szPlName[35], szAdmName[35];
        iLevels[gTarget] += iNum;
        get_user_name(id, szAdmName, charsmax(szAdmName));
        get_user_name(gTarget, szPlName, charsmax(szPlName));
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Dobavihte na igrach^3 %s^4 %i^1 levela", szPlName, iNum);
        ColorChat(gTarget, TEAM_COLOR, "^4[Levels]^1 Admin^3 %s^1 ti dade ^3 %s^1 levela", szAdmName, iNum);
        if(bLogs) {
                new szText[250];
                formatex(szText, charsmax(szText), "[amx_addlvl] Admin: %s | Igrach: %s | Levels: %i", szAdmName, szPlName, iNum);
                write_file(gLogFile, szText);
        }
        return PLUGIN_HANDLED;
}
 
public fw_LvlReset(id, level, cid) {
        if(!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED;
        new szFArg[35];
        read_argv(1, szFArg, charsmax(szFArg));
        new gTarget = cmd_target(id, szFArg, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS | CMDTARGET_OBEY_IMMUNITY);
        if(!is_user_connected(gTarget))
        return PLUGIN_HANDLED;
        new szPlName[35], szAdmName[35];
        iLevels[gTarget] = 0;
        get_user_name(id, szAdmName, charsmax(szAdmName));
        get_user_name(gTarget, szPlName, charsmax(szPlName));
        ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Resnahte na igrach ^3 %s^1 levelite", szPlName);
        ColorChat(gTarget, TEAM_COLOR, "^4[Levels]^1 Admin^3 %s^1 ti restartira levelite!", szAdmName);
        if(bLogs) {
                new szText[250];
                formatex(szText, charsmax(szText), "[amx_resetlvl] Admin: %s | Igrach: %s", szAdmName, szPlName);
                write_file(gLogFile, szText);
        }
        return PLUGIN_HANDLED;
}
 
 
public client_putinserver(id) {
        new szNum[55], leveli[30], kilovi[30],points[33],money[60]
        new szName[32]
        get_user_name(id, szName, 31)
        fvault_get_data(g_vault_name, szName, szNum, 54)
        parse(szNum, leveli, charsmax(leveli), kilovi, charsmax(kilovi),points,charsmax(points));
        iLevels[id] = str_to_num(leveli);
        iKills[id] = str_to_num(kilovi);
        iPoints[id] = str_to_num(points);
        iMoney[id] = str_to_num(money);
        set_task(3.0, "fw_HudInfo", id);
        set_task(3.0, "fw_chatInfo", id);
        if(iLevels[id] >= iLevSlot) {
        server_cmd("amx_addadmin ^"%s^" ^"b^" ^"^" ^"id^"", szName);
        server_exec();
        }
}
 
 
public fw_HudInfo(id) {
        if(is_user_connected(id) && bHud) {
                set_hudmessage(0, 255, 0, 0.02, 0.17, 0, 6.0, 12.0);
                show_hudmessage(id, "[ Level: %i ] ^n[ Kills: %i / %i / Points: %i]", iLevels[id], iKills[id], iKNum, iPoints[id]);
                set_task(3.0, "fw_HudInfo", id);
               
        }
}

public fw_chatInfo(id) {
if(is_user_alive(id) && iLevels[id] >= iLevSlot) {
ColorChat(id, TEAM_COLOR, "^4[Levels]^1 Chestito, poluchi rezerviran slot, poradi tvoite ^3 %i^1 levela", iLevSlot);
}
}
 
public client_disconnect(id) {
remove_task(id);
g_speed[id] = 0;
g_round[id] = 0;
new szNum[55];
formatex(szNum, charsmax(szNum), "%i %i %i %i", iLevels[id], iKills[id],iPoints[id],cs_get_user_money(id));
new szName[32]
get_user_name(id, szName, 31)
fvault_set_data(g_vault_name, szName, szNum);
 
}
 
public fw_Death() {
        new id = read_data(1);
        new id2 = read_data(2);
   g_round[id2] = 0
        if(is_user_connected(id2)) {
        cs_reset_user_model(id2);
        set_user_rendering(id2);
        g_speed[id2] = 0;
        set_user_gravity(id2,1.0);
        }
        if(is_user_connected(id))
        {
                new szNum[55]
                formatex(szNum, charsmax(szNum), "%i %i %i %i", iLevels[id], iKills[id],iPoints[id],cs_get_user_money(id));
                new szName[32]
                get_user_name(id, szName, 31)
                fvault_set_data(g_vault_name, szName, szNum);
        }
        if(id <= gMaxPlayers) {
                if(is_user_connected(id)) {
                        iKills[id]++;
                        iPoints[id]++;
                        if(iLevels[id] >= iMax)
                        return;
                        set_hudmessage(255, 0, 0, -1.0, 0.62, 0, 6.0, 12.0);
                        if(iKills[id] == iKNum) {
                                iLevels[id]++;
                                iPoints[id] += 100;
                                iKills[id] = 0;
                                show_hudmessage(id, "[ Ti si na nivo %i ]", iLevels[id]);
                                if(bFade)
                                set_user_fade(id);
                        }
                        else show_hudmessage(id, "[ %i / %i Kills  / %i Points]", iKills[id], iKNum, iPoints[id]);
                }
        }
}


public hook_say(client)
{
    new said[192];
    if( !IsValidMessage(said, charsmax(said)) || !IsValidMessage2(said) || said[0] == '@' || said[0] == '#' || said[0] == '#' || said[0] == '/' || equal(said, "") || said[0] == '^0' || !strlen(said)) {
      return PLUGIN_HANDLED_MAIN
     }
     
    new name[32];
    get_user_name(client, name, sizeof(name) - 1);
     
    new alive = is_user_alive(client);
     
    new tag[9];
    if( get_user_team(client) == 3 )
    {
        copy(tag, sizeof(tag) - 1, "*SPEC* ");
    }
    else if( !alive )
    {
        copy(tag, sizeof(tag) - 1, "*DEAD* ");
    }
     


    new message[192], teamName[10];
   
    if(!(get_user_flags(client) & ADMIN_CHAT)) formatex(message, sizeof(message) - 1, "^x01%s^x04[ Level: %i ]^x03 %s^x01 :  %s",  tag,  iLevels[client], name, said);
    else formatex(message, sizeof(message) - 1, "^x01%s^x04[ Level: %i ]^x03 %s^x01 :  ^x04%s",  tag,  iLevels[client], name, said);
   
    trim(message)
    if (contain(message, "@") != -1 ) {
    return PLUGIN_HANDLED
    }

    for( new i = 1; i <= gMaxPlayers; i++ )
    {
        if(is_user_alive(i) != alive ) continue
       
        if(!(get_user_flags(client) & ADMIN_CHAT)) writeMessage(i, message)      // Writes the message on player's chat
        else
        {
                get_user_team(i, teamName, 9)   // Stores user's team name to change back after sending the message      
                changeTeamInfo(i, "SPECTATOR")      // Changes user's team according to color choosen
                writeMessage(i, message)      // Writes the message on player's chat
                changeTeamInfo(i, teamName)   // Changes user's team back to original
        }
    }
     
   
 
    return PLUGIN_HANDLED_MAIN
}

public hook_teamsay(client)
{
    new said[192];
    if( !IsValidMessage(said, charsmax(said)) || !IsValidMessage2(said) || said[0] == '@' || said[0] == '#' || said[0] == '#' || said[0] == '/' || equal(said, "") || said[0] == '^0' || !strlen(said)) {
      return PLUGIN_HANDLED_MAIN
     }
     
    new name[32];
    get_user_name(client, name, sizeof(name) - 1);
     
    new alive = is_user_alive(client);
     
    new CsTeams:team = cs_get_user_team(client);
     


    new message[192], teamName[10];
   
    if(!(get_user_flags(client) & ADMIN_CHAT)) formatex(message, sizeof(message) - 1, "^x01%s^x04[ Level: %i ]^x03 %s^x01 :  %s", g_team_names[team], iLevels[client],name, said);
    else formatex(message, sizeof(message) - 1, "^x01%s^x04[ Level: %i ]^x03 %s^x01 :  ^x04%s", g_team_names[team], iLevels[client],name, said);
   
    if (contain(message, "@") != -1) {
    return PLUGIN_HANDLED
    }

    for( new i = 1; i <= gMaxPlayers; i++ )
    {
        if(is_user_alive(i) != alive || get_user_team(i) != get_user_team(client) ) continue
       
        if(!(get_user_flags(client) & ADMIN_CHAT)) writeMessage(i, message)      // Writes the message on player's chat
        else
        {
                get_user_team(i, teamName, 9)   // Stores user's team name to change back after sending the message      
                changeTeamInfo(i, "SPECTATOR")      // Changes user's team according to color choosen
                writeMessage(i, message)      // Writes the message on player's chat
                changeTeamInfo(i, teamName)   // Changes user's team back to original
        }
    }
     
     
    return PLUGIN_HANDLED_MAIN
}

 
stock set_user_fade(index) {
        message_begin(MSG_ONE_UNRELIABLE, g_msg_screenfade, _, index);
        write_short((1 << 12) * 1);
        write_short(floatround((1 << 12) * 0.1));
        write_short(0x0000);
        write_byte(0);
        write_byte(255);
        write_byte(255);
        write_byte(150);
        message_end();
}


public shopped(id) {
    new menu = menu_create( "\rSHOP - \yMENU!:", "menu_handler" );

    menu_additem( menu, "\yPOINTS \rSHOP", "", 0 );
    menu_additem( menu, "\ySNIPERS \rSHOP", "", 0 );

    menu_display( id, menu, 0 );
}


public menu_handler( id, menu, item )
 {
    switch( item )
    {
        case 0:
        {
            POINTS( id );
        }
        case 1:
        {
            SNIPERS( id );
        }
        case MENU_EXIT:
        {

        }
    }

    menu_destroy( menu );
    return PLUGIN_HANDLED;
 }

///////////////////////////////////////DEDIHOST ADDON/////////////////////////////////////////

public POINTS(id) {
    new menu = menu_create( "\rShop \wwith \rPoints", "menu_points" );
   
    menu_additem( menu, "\wInvis \r400 Points", "", 0 );
    menu_additem( menu, "\w155 HP \r100 Points", "", 0 );
    menu_additem( menu, "\wHE Grenade \r150 Points", "", 0 );
    menu_additem( menu, "\wSPEED \r400 Points", "", 0 );
    menu_additem( menu, "\wGravity \r200 Points", "", 0 );
    menu_additem( menu, "\wFrost Grenade \r200 Points", "", 0 );
    menu_additem( menu, "\wADRENALINE \r500 Points", "", 0 );

    menu_display( id, menu, 0 );
}

public SNIPERS(id) {
    new menu = menu_create( "\rSnipers Shop \wwith \yMoney", "menu_snipers" );
   
    menu_additem( menu, "\wAWP \r4000$", "", 0 );
    menu_additem( menu, "\wG3SG1 \r7000$", "", 0 );
    menu_additem( menu, "\wSG550 \r7000$", "", 0 );


    menu_display( id, menu, 0 );
}

public menu_points( id, menu, item )
{
    if(!(get_user_flags(id) & ADMIN_CHAT) && g_round[id] == 1)
    {
    ColorChat(id,GREEN,"Mojete da kopuvate samo po 1 item na smurt!");
    menu_destroy( menu );
    return PLUGIN_HANDLED;
   }
   
    switch( item )
    {
        case 0:
        {
         if(iPoints[id] < 400) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 50);
         iPoints[id] = iPoints[id] - 400;   
        }
        case 1:
        {
         if(iPoints[id] < 100) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         set_user_health(id, get_user_health(id) + 155);
         iPoints[id] = iPoints[id] - 100;       
        }
        case 2:
        {
         if(iPoints[id] < 150) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         give_item(id, "weapon_hegrenade");
         iPoints[id] = iPoints[id] - 150;               
        }
        case 3:
        {
         if(iPoints[id] < 400) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         g_speed[id] = 1;
         set_task(0.1, "speed", id + TASKID,_,_,"b");
         iPoints[id] = iPoints[id] - 400;               
        }
        case 4:
        {
         if(iPoints[id] < 200) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         set_user_gravity(id,0.4);
         iPoints[id] = iPoints[id] - 200;               
        }       
        case 5:
        {
         if(iPoints[id] < 200) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         give_frost_grenade(id)
         iPoints[id] = iPoints[id] - 200;     
        }
        case 6:
        {
         if(iPoints[id] < 500) {
         ColorChat(id,GREEN,"Nqmash dostatucho tochki!");
         return PLUGIN_HANDLED;
         }
         set_user_health(id,255)
         give_item(id,"weapon_hegrenade");
         give_item(id,"weapon_flashbang");
         give_item(id,"weapon_flashbang");
         give_item(id,"weapon_smokegrenade");
         iPoints[id] = iPoints[id] - 500;               
        }
    }

    g_round[id] =1;
    menu_destroy( menu );
    return PLUGIN_HANDLED;
 }

public menu_snipers( id, menu, item )
{
    if(!(get_user_flags(id) & ADMIN_CHAT) && g_round[id] == 1)
    {
    ColorChat(id,GREEN,"Mojete da kopuvate samo po 1 item na smurt!");
    menu_destroy( menu );
    return PLUGIN_HANDLED;
   }
    switch( item )
    {
        case 0:
        {
            if(cs_get_user_money(id) < 4000) {ColorChat(id,GREEN,"Nqmash dostatucho pari!"); return PLUGIN_HANDLED;}
            give_item(id, "weapon_awp");
            cs_set_user_bpammo(id, CSW_AWP, 90);
            cs_set_user_money(id,cs_get_user_money(id) - 4000);
        }
        case 1:
        {
            if(cs_get_user_money(id) < 7000) {ColorChat(id,GREEN,"Nqmash dostatucho pari!"); return PLUGIN_HANDLED;}
            give_item(id, "weapon_g3sg1");
            cs_set_user_bpammo(id, CSW_G3SG1, 90);
            cs_set_user_money(id,cs_get_user_money(id) - 7000);
        }
        case 2:
        {
            if(cs_get_user_money(id) < 7000) {ColorChat(id,GREEN,"Nqmash dostatucho pari!"); return PLUGIN_HANDLED;}
            give_item(id, "weapon_sg550");
            cs_set_user_bpammo(id, CSW_SG550, 90);
            cs_set_user_money(id,cs_get_user_money(id) - 7000);
        }
        case MENU_EXIT:
        {

        }
    }

    g_round[id] =1;
    menu_destroy( menu );
    return PLUGIN_HANDLED;
}

public speed(TASK) {
new id = TASK - TASKID;
if(g_speed[id] == 1) {
set_user_maxspeed(id, 500.0);
}
}

bool:IsValidMessage( szMessage[ ], iLen )
{
   read_args( szMessage, iLen )
   remove_quotes( szMessage )
   
   new iPos, cChar
   while( 0 <= ( cChar = szMessage[ iPos++ ] ) <= 255 )
   {
      if( cChar != ' ' && cChar != '%')
      {
         return true
      }
   }
   
   return false
}

bool:IsValidMessage2(const said[])
{
    new i, c
    while( (c = said[i++]) != 0 )
    {
        if( c != ' ' )
        {
            return true
        }
    }
    return false
}

public changeTeamInfo(player, team[])
{
   message_begin(MSG_ONE, teamInfo, _, player)   // Tells to to modify teamInfo (Which is responsable for which time player is)
   write_byte(player)            // Write byte needed
   write_string(team)            // Changes player's team
   message_end()               // Also Needed
}

public writeMessage(player, message[])
{
   message_begin(MSG_ONE, g_msgid_SayText, {0, 0, 0}, player)   // Tells to modify sayText (Which is responsable for writing colored messages)
   write_byte(player)               // Write byte needed
   write_string(message)               // Effectively write the message, finally, afterall
   message_end()                  // Needed as always
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1026\\ f0\\ fs16 \n\\ par }
*/
 
 #392221  от Todorow93
 вт юни 07, 2016 9:06 pm
Сега е по добре а може ли да се изключат някой опций като например купуване и продаване на левели и също ми направи впечатление ,че като дам на някой левели тези левели не му се запазват.
 #392227  от OciXCrom™
 вт юни 07, 2016 9:40 pm
Разгледай cvar-овете. Има и описание в кода даже.
 #392239  от Todorow93
 вт юни 07, 2016 11:42 pm
Да кварове има но когато дам на някой левели те не се запаметяват добавят му се левелите и след 3 - 4 мин пак си му връща стария левел