zfl1860 发表于 2010-1-9 15:07:54

求修改个礼包源码

每局开始空中出现一个礼包 撞到礼包的玩家会随机得到一个枪或者手雷
想改成第一局不出现礼包 因为第一局有大枪的话 其他人都是手枪
有枪的人加了 会出现2把枪 想改成有枪的人加不了/* AMX Mod X
*   New Round Gift
*
* (c) Copyright 2005 by VEN
*
* This file is provided as is (no warranties)
*
*   DESCRIPTION:
*       Every new round at the CT and T respawn randomly appears gift.
*
*   NOTE:
*       Gift wouldn't appear for team with only one player!
*
*   FEATURES:
*       Plugin make gift collection fun and interesting because:
*         - you don't know where is gift would appear
*         - you don't know what is inside
*         - sometimes you must run fast and even jump
*
*   MODULES:
*       - engine
*       - fun
*
*   CONFIGURATION:
*       Available items can be changed (GIFT_ITEM_NUM, GIFT_ITEM), default: vest, vesthelm, nades.
*
*       Gift model can be changed (GIFT_MODEL), default: "models/w_battery.mdl".
*
*       Plugin can be disabled by changing "amx_newround_gift" CVAR value to 0.
*/

#include <amxmodx>
#include <engine>
#include <fun>

#define MAX_PLAYERS 32

#define GIFT_ITEM_NUM 8
new const GIFT_ITEM[] = {
        "item_assaultsuit",
        "weapon_deagle",
        "weapon_awp",
        "weapon_ak47",
        "weapon_m4a1",
        "weapon_aug",
        "weapon_sg552",
        "weapon_hegrenade"
}

#define GIFT_MODEL "models/w_isotopebox.mdl"
#define GIFT_NAME "gift"

public plugin_init() {
        register_plugin("New Round Gift", "0.1", "VEN")
        register_logevent("logevent_round_start", 2, "0=World triggered", "1=Round_Start")
        register_event("RoundTime", "event_round_time", "bc")
        register_touch(GIFT_NAME, "player", "touch_gift")
        register_cvar("amx_newround_gift", "1")
}

public plugin_modules() {
        require_module("engine")
        require_module("fun")
}

public plugin_precache() {
        precache_model(GIFT_MODEL)
}

public logevent_round_start() {
        if (!get_cvar_num("amx_newround_gift"))
                return

        new pnum, origin, minor, maxor, bool:compare
        for (new i = 1; i <= MAX_PLAYERS; ++i) {
                if (!is_user_alive(i))
                        continue

                new team = get_user_team(i) - 1
                if (team != 0 && team != 1)
                        continue

                pnum++
                get_user_origin(i, origin)
                if (compare) {
                        for (new j = 0; j < 3; ++j) {
                                if (origin < minor)
                                        minor = origin
                                if (origin > maxor)
                                        maxor = origin
                        }
                }
                else {
                        minor = origin
                        maxor = origin
                        compare = true
                }
        }
        for (new i = 0; i < 2; ++i) {
                if (pnum < 2)
                        continue

                new gift = create_entity("info_target")
                if (!gift) {
                        log_amx("ERROR: Couldn't create gift entity!")
                        continue
                }

                entity_set_string(gift, EV_SZ_classname, GIFT_NAME)
                entity_set_int(gift, EV_INT_solid, SOLID_TRIGGER)

                new Float:gift_origin
                for (new j = 0; j < 3; ++j)
                        gift_origin = float(random_num(minor, maxor))
                gift_origin += 40
                entity_set_vector(gift, EV_VEC_origin, gift_origin)

                entity_set_model(gift, GIFT_MODEL)
        }
}

public touch_gift(gift, id) {
        new PlayerName, msg
        get_user_name( id, PlayerName, 31)
        give_item(id, GIFT_ITEM)
        remove_entity(gift)
        format(msg, 511, "^x04* 玩家:^x03%s^x04 打开了礼包,获得了一份神秘礼物!", PlayerName)
        client_color(0, id, msg)
}
public event_round_time() {
        if (read_data(1) == get_cvar_num("mp_freezetime")) {
                new gift = 0
                while ((gift = find_ent_by_class(gift, GIFT_NAME)))
                        remove_entity(gift)
        }
}

public client_color(playerid, colorid, msg[])
{
message_begin(playerid?MSG_ONE:MSG_ALL,get_user_msgid("SayText"),_,playerid)
write_byte(colorid)
write_string(msg)
message_end()
}

baili1258 发表于 2010-1-9 18:33:56

本帖最后由 baili1258 于 2010-1-9 19:04 编辑

/* AMX Mod X
*   New Round Gift
*
* (c) Copyright 2005 by VEN
*
* This file is provided as is (no warranties)
*
*   DESCRIPTION:
*       Every new round at the CT and T respawn randomly appears gift.
*
*   NOTE:
*       Gift wouldn't appear for team with only one player!
*
*   FEATURES:
*       Plugin make gift collection fun and interesting because:
*         - you don't know where is gift would appear
*         - you don't know what is inside
*         - sometimes you must run fast and even jump
*
*   MODULES:
*       - engine
*       - fun
*
*   CONFIGURATION:
*       Available items can be changed (GIFT_ITEM_NUM, GIFT_ITEM), default: vest, vesthelm, nades.
*
*       Gift model can be changed (GIFT_MODEL), default: "models/w_battery.mdl".
*
*       Plugin can be disabled by changing "amx_newround_gift" CVAR value to 0.
*/

#include <amxmodx>
#include <engine>
#include <fun>

#define MAX_PLAYERS 32

#define GIFT_ITEM_NUM 8
new const GIFT_ITEM[] = {
        "item_assaultsuit",
        "weapon_deagle",
        "weapon_awp",
        "weapon_ak47",
        "weapon_m4a1",
        "weapon_aug",
        "weapon_sg552",
        "weapon_hegrenade"
}
new g_roundcount
#define GIFT_MODEL "models/w_isotopebox.mdl"
#define GIFT_NAME "gift"

public plugin_init() {
        register_plugin("New Round Gift", "0.1", "VEN")
        register_logevent("logevent_round_start", 2, "0=World triggered", "1=Round_Start")
        register_event("TextMsg","eRestart","a","2&#Game_C","2&#Game_w")//刷新事件
        register_event("RoundTime", "event_round_time", "bc")
        register_touch(GIFT_NAME, "player", "touch_gift")
        register_cvar("amx_newround_gift", "1")
        g_roundcount=0
}

public plugin_modules() {
        require_module("engine")
        require_module("fun")
}

public plugin_precache() {
        precache_model(GIFT_MODEL)
}
public eRestart()
        g_roundcount = 0

public logevent_round_start() {
        g_roundcount++
               if (!get_cvar_num("amx_newround_gift") || g_roundcount == 1)
                return
       
        new pnum, origin, minor, maxor, bool:compare
        for (new i = 1; i <= MAX_PLAYERS; ++i) {
                if (!is_user_alive(i))
                        continue
               
                new team = get_user_team(i) - 1
                if (team != 0 & team != 1)
                        continue
               
                pnum++
                get_user_origin(i, origin)
                if (compare) {
                        for (new j = 0; j < 3; ++j) {
                                if (origin < minor)
                                        minor = origin
                                if (origin > maxor)
                                        maxor = origin
                        }
                }
                else {
                        minor = origin
                        maxor = origin
                        compare = true
                }
        }
        for (new i = 0; i < 2; ++i) {
                if (pnum < 2)
                        continue
               
                new gift = create_entity("info_target")
                if (!gift) {
                        log_amx("ERROR: Couldn't create gift entity!")
                        continue
                }
               
                entity_set_string(gift, EV_SZ_classname, GIFT_NAME)
                entity_set_int(gift, EV_INT_solid, SOLID_TRIGGER)
               
                new Float:gift_origin
                for (new j = 0; j < 3; ++j)
                        gift_origin = float(random_num(minor, maxor))
                gift_origin += 40
                entity_set_vector(gift, EV_VEC_origin, gift_origin)
               
                entity_set_model(gift, GIFT_MODEL)
        }
}

public touch_gift(gift, id) {
        new PlayerName, msg
        get_user_name( id, PlayerName, 31)
        give_item(id, GIFT_ITEM)
        remove_entity(gift)
        format(msg, 511, "^x04* 玩家:^x03%s^x04 打开了礼包,获得了一份神秘礼物!", PlayerName)
        client_color(0, id, msg)
}
public event_round_time() {
        if (read_data(1) == get_cvar_num("mp_freezetime")) {
                new gift = 0
                while ((gift = find_ent_by_class(gift, GIFT_NAME)))
                        remove_entity(gift)
        }
}

public client_color(playerid, colorid, msg[])
{
        message_begin(playerid?MSG_ONE:MSG_ALL,get_user_msgid("SayText"),_,playerid)
        write_byte(colorid)
        write_string(msg)
        message_end()
} 没测试
不行我再帮你看

zfl1860 发表于 2010-1-10 11:36:24

第一局不出现礼包了 但有枪的玩家还能加礼包 还会出现一个人两把大枪




baili1258 发表于 2010-1-10 15:43:41

你的服务器是不是没有设置freetime?

zfl1860 发表于 2010-1-13 17:08:41

是啊 2秒

zfl1860 发表于 2010-1-22 11:39:17

ding!!!!!!!!!!!!!!

coolmanlu 发表于 2010-2-22 22:17:44

看不懂!~
页: [1]
查看完整版本: 求修改个礼包源码