廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 2806 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   
龍心
個人文章 個人相簿 個人日記 個人地圖
初露鋒芒
級別: 初露鋒芒 該用戶目前不上站
推文 x0 鮮花 x2
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[插件] 等級系統>>>>BY Crazy_Eric<<<<

圖 1.



【插件資訊】

插件來源:網路資源轉載提供會員參考 http://bbs.mychat.tw/re...id=986261
使用指令:自行編譯及參考 http://bbs.mychat.tw/re...id=986261
安裝路徑:addons\amxmodx\plugins

【插件介紹】

複製程式
new g_vault;
new g_msg;
new g_points[33];
new g_xp[33];
new g_lv[33];
new CKXB;
new CKPB;
new TKXB;
new TKPB;
new RequiredXP[10001];


replace_all(String:string[], len, String:what[], String:with[])
{
    new pos = 0;
    new var1 = contain(string, what);
    pos = var1;
    if (var1 == -1)
    {
        return 0;
    }
    new total = 0;
    new with_len = strlen(with);
    new diff = strlen(what) - with_len;
    new total_len = strlen(string);
    new temp_pos = 0;
    while (replace(string[pos], len - pos, what, with))
    {
        pos = with_len + pos;
        total_len -= diff;
        if (pos >= total_len)
        {
            return total;
        }
        else
        {
            temp_pos = contain(string[pos], what);
            if (temp_pos == -1)
            {
                return total;
            }
            else
            {
                pos = temp_pos + pos;
                total++;
            }
            return total;
        }
        return total;
    }
    return total;
}




cmd_access(id, level, cid, num)
{
    !!! Removed Phi
    new has_access = 0;
    new var1;
    if (is_dedicated_server())
    {
        var1 = 0;
    }
    else
    {
        var1 = 1;
    }
    if (var1 == id)
    {
        has_access = 1;
    }
    else
    {
        if (level == 16777216)
        {
            if (is_user_admin(id))
            {
                has_access = 1;
            }
        }
        if (level & get_user_flags(id, 0))
        {
            has_access = 1;
        }
        if (level)
        {
        }
        else
        {
            has_access = 1;
        }
    }
    if (has_access)
    {
        if (num > read_argc())
        {
            new hcmd[32];
            new hinfo[128];
            new hflag = 0;
            get_concmd(cid, hcmd, 31, hflag, hinfo, 127, level, -1);
            console_print(id, "%L:  %s %s", id, "USAGE", hcmd, hinfo);
            return 0;
        }
        return 1;
    }
    console_print(id, "%L", id, "NO_ACC_COM");
    return 0;
}


cmd_target(id, String:arg[], flags)
{
    !!! Removed Phi
    new player = find_player("bl", arg);
    if (player)
    {
        if (find_player("blj", arg) != player)
        {
            console_print(id, "%L", id, "MORE_CL_MATCHT");
            return 0;
        }
    }
    else
    {
        if (var4 && arg[0] == 35 && arg[1])
        {
            player = find_player("k", str_to_num(arg[1]));
        }
    }
    if (!player)
    {
        console_print(id, "%L", id, "CL_NOT_FOUND");
        return 0;
    }
    if (flags & 1)
    {
        if (get_user_flags(player, 0) & 1 && flags & 2)
        {
            new imname[32];
            get_user_name(player, imname, 31);
            console_print(id, "%L", id, "CLIENT_IMM", imname);
            return 0;
        }
    }
    if (flags & 4)
    {
        if (!is_user_alive(player))
        {
            new imname[32];
            get_user_name(player, imname, 31);
            console_print(id, "%L", id, "CANT_PERF_DEAD", imname);
            return 0;
        }
    }
    if (flags & 8)
    {
        if (is_user_bot(player))
        {
            new imname[32];
            get_user_name(player, imname, 31);
            console_print(id, "%L", id, "CANT_PERF_BOT", imname);
            return 0;
        }
    }
    return player;
}


public plugin_init()
{
    register_cvar("Rcolour", "100", 0, 0.00);
    register_cvar("Gcolour", "0", 0, 0.00);
    register_cvar("Bcolour", "200", 0, 0.00);
    register_plugin("lv_system", "1.0", "Crazy_Eric");
    register_clcmd("cy_xp", "cmd_xp", 4096, "Usage: cy_xp <name> <+/-/=> <amount>");
    register_clcmd("cy_point", "cmd_point", 4096, "Usage: cy_point <name> <+/-/=> <amount>");
    register_clcmd("cy_lv", "cmd_lv", 4096, "Usage: cy_lv <name> <+/-/=> <amount>");
    CKXB = register_cvar("CT_KillXPBonus", "15", 0, 0.00);
    CKPB = register_cvar("CT_KillPointsBonus", "10", 0, 0.00);
    TKXB = register_cvar("T_KillXPBonus", "25", 0, 0.00);
    TKPB = register_cvar("T_KillPointsBonus", "10", 0, 0.00);
    register_clcmd("say /save", "Save", -1, "");
    register_forward(FM_PlayerPreThink, "prethink", 0);
    g_msg = CreateHudSyncObj(0);
    g_vault = nvault_open("XPSystem");
    register_event("DeathMsg", "Death", "a", "");
    set_task(0.50, "ShowHud", 0, "", 0, "b", 0);
    new a = 0;
    a = 0;
    while (a < 10001)
    {
        RequiredXP[a] = a + 1 * a + 1 * 100;
        a++;
    }
    return 0;
}


public prethink(id)
{
    new var2 = g_lv[id][0][0];
    new var1;
    if (10000 >= var2)
    {
        new var3 = g_xp[id][0][0];
        if (RequiredXP[g_lv[id][0][0]][0][0] <= var3)
        {
            new var4 = g_lv;
            var4[id]++;
            client_printcolor(id, "/g【等級系統】恭喜你的等級升級");
            var1 = var4;
        }
        var1 = var3;
    }
    else
    {
        var1 = var2;
    }
    return 0;
}


public cmd_xp(id, level, cid)
{
    new name[15];
    new symbol[5];
    new amount[50];
    if (!cmd_access(id, level, cid, 4))
    {
        return 1;
    }
    read_argv(1, name, 14);
    read_argv(2, symbol, 4);
    read_argv(3, amount, 14);
    new target = cmd_target(id, name, 2);
    if (!target)
    {
        client_print(id, print_console, "Player not found");
        return 1;
    }
    if (!(strcmp(symbol, "+", 0)))
    {
        new var1 = g_xp[target];
        var1 = str_to_num(amount) + var1[0][0];
    }
    if (!(strcmp(symbol, "-", 0)))
    {
        new var2 = g_xp[target];
        var2 = var2[0][0] - str_to_num(amount);
    }
    if (!(strcmp(symbol, "=", 0)))
    {
        g_xp[target] = str_to_num(amount);
    }
    return 1;
}


public cmd_point(id, level, cid)
{
    new name[15];
    new symbol[5];
    new amount[50];
    if (!cmd_access(id, level, cid, 4))
    {
        return 1;
    }
    read_argv(1, name, 14);
    read_argv(2, symbol, 4);
    read_argv(3, amount, 14);
    new target = cmd_target(id, name, 2);
    if (!target)
    {
        client_print(id, print_console, "Player not found");
        return 1;
    }
    if (!(strcmp(symbol, "+", 0)))
    {
        new var1 = g_points[target];
        var1 = str_to_num(amount) + var1[0][0];
    }
    if (!(strcmp(symbol, "-", 0)))
    {
        new var2 = g_points[target];
        var2 = var2[0][0] - str_to_num(amount);
    }
    if (!(strcmp(symbol, "=", 0)))
    {
        g_points[target] = str_to_num(amount);
    }
    return 1;
}


public cmd_lv(id, level, cid)
{
    !!! Removed Phi
    new name[15];
    new symbol[5];
    new amount[50];
    if (!cmd_access(id, level, cid, 4))
    {
        return 1;
    }
    read_argv(1, name, 14);
    read_argv(2, symbol, 4);
    read_argv(3, amount, 14);
    new target = cmd_target(id, name, 2);
    if (!target)
    {
        client_print(id, print_console, "Player not found");
        return 1;
    }
    if (!(strcmp(symbol, "+", 0)))
    {
        new var1 = g_xp[target];
        var1 = RequiredXP[str_to_num(amount) + g_lv[target][0][0] - 1][0][0] - RequiredXP[g_lv[target][0][0] - 1][0][0] + var1[0][0];
    }
    if (!(strcmp(symbol, "-", 0)))
    {
        new var2 = g_xp[target];
        var2 = var2[0][0] - RequiredXP[g_lv[target][0][0] - 1][0][0] - RequiredXP[g_lv[target][0][0] - str_to_num(amount) - 1][0][0];
        new var3 = g_lv[target];
        var3 = var3[0][0] - str_to_num(amount);
    }
    if (!(strcmp(symbol, "=", 0)))
    {
        if (str_to_num(amount))
        {
            g_xp[target] = RequiredXP[str_to_num(amount) - 1][0][0];
            g_lv[target] = str_to_num(amount);
        }
        g_xp[target] = 0;
        g_lv[target] = 0;
    }
    return 1;
}


public Death()
{
    new attacker = read_data(1);
    new victim = read_data(2);
    if (victim != attacker)
    {
        if (cs_get_user_team(attacker, 0) == 2)
        {
            new var1 = g_xp[attacker];
            var1 = get_pcvar_num(CKXB) + var1[0][0];
            new var2 = g_points[attacker];
            var2 = get_pcvar_num(CKPB) + var2[0][0];
        }
        if (cs_get_user_team(attacker, 0) == 1)
        {
            new var3 = g_xp[attacker];
            var3 = get_pcvar_num(TKXB) + var3[0][0];
            new var4 = g_points[attacker];
            var4 = get_pcvar_num(TKPB) + var4[0][0];
        }
        Save(attacker);
    }
    return 0;
}


public plugin_natives()
{
    register_native("get_user_points", "native_get_user_points", 1);
    register_native("set_user_points", "native_set_user_points", 1);
    register_native("get_user_level", "native_get_user_level", 1);
    register_native("set_user_level", "native_set_user_level", 1);
    register_native("get_user_xp", "native_get_user_xp", 1);
    register_native("set_user_xp", "native_set_user_xp", 1);
    return 0;
}


public native_get_user_xp(id)
{
    return g_xp[id][0][0];
}


public native_set_user_xp(id, amount)
{
    g_xp[id] = amount;
    return 0;
}


public native_get_user_level(id)
{
    return g_lv[id][0][0];
}


public native_set_user_level(id, amount)
{
    g_lv[id] = amount;
    return 0;
}


public native_get_user_points(id)
{
    return g_points[id][0][0];
}


public native_set_user_points(id, amount)
{
    g_points[id] = amount;
    return 0;
}


public ShowHud()
{
    new id = 0;
    while (id <= 31)
    {
        new name[33][33];
        name[0] = 43672;
        get_user_name(id, name[id], 32);
        new r = get_cvar_num("Rcolour");
        new g = get_cvar_num("Gcolour");
        new b = get_cvar_num("Bcolour");
        set_hudmessage(0, 255, 0, 0.40, 0.75, 0, 0.00, 999999.00, 0.10, 0.20, 4);
        ShowSyncHudMsg(id, g_msg, 43900, name[id], g_lv[id], get_user_health(id), g_points[id], g_xp[id], RequiredXP[g_lv[id][0][0]]);
        id++;
    }
    return 0;
}


public Save(id)
{
    new name[33];
    new vaultkey[64];
    new vaultdata[512];
    client_print(id, print_chat, "");
    get_user_name(id, name, 32);
    format(vaultkey, 63, "%s-Mod", name);
    format(vaultdata, 511, "%i#%i#%i#%i#", g_lv[id], g_xp[id], g_points[id]);
    nvault_set(g_vault, vaultkey, vaultdata);
    return 0;
}


public Load(id)
{
    new name[33];
    new vaultkey[64];
    new vaultdata[512];
    new LV[33];
    new XP[33];
    new Points[33];
    get_user_name(id, name, 32);
    format(vaultkey, 63, "%s-Mod", name);
    format(vaultdata, 511, "%i#%i#%i#%i#", g_lv[id], g_xp[id], g_points[id]);
    nvault_get(g_vault, vaultkey, vaultdata, 511);
    replace_all(vaultdata, 511, "#", " ");
    parse(vaultdata, LV, 32, XP, 32, Points, 32);
    g_lv[id] = str_to_num(LV);
    g_xp[id] = str_to_num(XP);
    g_points[id] = str_to_num(Points);
    return 0;
}


public client_putinserver(id)
{
    Load(id);
    return 0;
}


public client_disconnect(id)
{
    Save(id);
    return 0;
}


client_printcolor(id, String:input[])
{
    new count = 1;
    new players[32];
    static msg[1024];
    vformat(msg, 1023, input, 3);
    replace_all(msg, 1023, "/g", "\4");
    replace_all(msg, 1023, "/y", "\1");
    replace_all(msg, 1023, "/ctr", "\3");
    if (id)
    {
        players[0] = id;
    }
    else
    {
        get_players(players, count, "ch", "");
    }
    new i = 0;
    while (i < count)
    {
        if (is_user_connected(players[i]))
        {
            message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), 48588, players[i]);
            write_byte(players[i]);
            write_string("");
            message_end();
            i++;
        }
        i++;
    }
    return 0;
}




獻花 x0 回到頂端 [樓 主] From:香港特別行政區 | Posted:2017-09-06 23:03 |

首頁  發表文章 發表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.095392 second(s),query:15 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言