搜索
查看: 2731|回复: 6

求修改个礼包源码

[复制链接]
发表于 2010-1-9 15:07:54 | 显示全部楼层 |阅读模式 来自 黑龙江齐齐哈尔
每局开始空中出现一个礼包 撞到礼包的玩家会随机得到一个枪或者手雷  
想改成第一局不出现礼包 因为第一局有大枪的话 其他人都是手枪
有枪的人加了 会出现2把枪 想改成有枪的人加不了
  1. /* AMX Mod X
  2. *   New Round Gift
  3. *
  4. * (c) Copyright 2005 by VEN
  5. *
  6. * This file is provided as is (no warranties)
  7. *
  8. *     DESCRIPTION:
  9. *       Every new round at the CT and T respawn randomly appears gift.
  10. *
  11. *     NOTE:
  12. *       Gift wouldn't appear for team with only one player!
  13. *
  14. *     FEATURES:
  15. *       Plugin make gift collection fun and interesting because:
  16. *         - you don't know where is gift would appear
  17. *         - you don't know what is inside
  18. *         - sometimes you must run fast and even jump
  19. *
  20. *     MODULES:
  21. *       - engine
  22. *       - fun
  23. *
  24. *     CONFIGURATION:
  25. *       Available items can be changed (GIFT_ITEM_NUM, GIFT_ITEM), default: vest, vesthelm, nades.
  26. *
  27. *       Gift model can be changed (GIFT_MODEL), default: "models/w_battery.mdl".
  28. *
  29. *       Plugin can be disabled by changing "amx_newround_gift" CVAR value to 0.
  30. */

  31. #include <amxmodx>
  32. #include <engine>
  33. #include <fun>

  34. #define MAX_PLAYERS 32

  35. #define GIFT_ITEM_NUM 8
  36. new const GIFT_ITEM[GIFT_ITEM_NUM][] = {
  37.         "item_assaultsuit",
  38.         "weapon_deagle",
  39.         "weapon_awp",
  40.         "weapon_ak47",
  41.         "weapon_m4a1",
  42.         "weapon_aug",
  43.         "weapon_sg552",
  44.         "weapon_hegrenade"
  45. }

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

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

  55. public plugin_modules() {
  56.         require_module("engine")
  57.         require_module("fun")
  58. }

  59. public plugin_precache() {
  60.         precache_model(GIFT_MODEL)
  61. }

  62. public logevent_round_start() {
  63.         if (!get_cvar_num("amx_newround_gift"))
  64.                 return

  65.         new pnum[2], origin[3], minor[2][3], maxor[2][3], bool:compare[2]
  66.         for (new i = 1; i <= MAX_PLAYERS; ++i) {
  67.                 if (!is_user_alive(i))
  68.                         continue

  69.                 new team = get_user_team(i) - 1
  70.                 if (team != 0 && team != 1)
  71.                         continue

  72.                 pnum[team]++
  73.                 get_user_origin(i, origin)
  74.                 if (compare[team]) {
  75.                         for (new j = 0; j < 3; ++j) {
  76.                                 if (origin[j] < minor[team][j])
  77.                                         minor[team][j] = origin[j]
  78.                                 if (origin[j] > maxor[team][j])
  79.                                         maxor[team][j] = origin[j]
  80.                         }
  81.                 }
  82.                 else {
  83.                         minor[team] = origin
  84.                         maxor[team] = origin
  85.                         compare[team] = true
  86.                 }
  87.         }
  88.         for (new i = 0; i < 2; ++i) {
  89.                 if (pnum[i] < 2)
  90.                         continue

  91.                 new gift = create_entity("info_target")
  92.                 if (!gift) {
  93.                         log_amx("ERROR: Couldn't create gift entity!")
  94.                         continue
  95.                 }

  96.                 entity_set_string(gift, EV_SZ_classname, GIFT_NAME)
  97.                 entity_set_int(gift, EV_INT_solid, SOLID_TRIGGER)

  98.                 new Float:gift_origin[3]
  99.                 for (new j = 0; j < 3; ++j)
  100.                         gift_origin[j] = float(random_num(minor[i][j], maxor[i][j]))
  101.                 gift_origin[2] += 40
  102.                 entity_set_vector(gift, EV_VEC_origin, gift_origin)

  103.                 entity_set_model(gift, GIFT_MODEL)
  104.         }
  105. }

  106. public touch_gift(gift, id) {
  107.         new PlayerName[32], msg[512]
  108.         get_user_name( id, PlayerName, 31)
  109.         give_item(id, GIFT_ITEM[random(GIFT_ITEM_NUM)])
  110.         remove_entity(gift)
  111.         format(msg, 511, "^x04* 玩家:^x03%s^x04 打开了礼包,获得了一份神秘礼物!", PlayerName)
  112.         client_color(0, id, msg)  
  113. }
  114. public event_round_time() {
  115.         if (read_data(1) == get_cvar_num("mp_freezetime")) {
  116.                 new gift = 0
  117.                 while ((gift = find_ent_by_class(gift, GIFT_NAME)))
  118.                         remove_entity(gift)
  119.         }
  120. }

  121. public client_color(playerid, colorid, msg[])
  122. {
  123.   message_begin(playerid?MSG_ONE:MSG_ALL,get_user_msgid("SayText"),_,playerid)
  124.   write_byte(colorid)
  125.   write_string(msg)
  126.   message_end()
  127. }  
复制代码
发表于 2010-1-9 18:33:56 | 显示全部楼层 来自 广东深圳
本帖最后由 baili1258 于 2010-1-9 19:04 编辑
  1. /* AMX Mod X
  2. *   New Round Gift
  3. *
  4. * (c) Copyright 2005 by VEN
  5. *
  6. * This file is provided as is (no warranties)
  7. *
  8. *     DESCRIPTION:
  9. *       Every new round at the CT and T respawn randomly appears gift.
  10. *
  11. *     NOTE:
  12. *       Gift wouldn't appear for team with only one player!
  13. *
  14. *     FEATURES:
  15. *       Plugin make gift collection fun and interesting because:
  16. *         - you don't know where is gift would appear
  17. *         - you don't know what is inside
  18. *         - sometimes you must run fast and even jump
  19. *
  20. *     MODULES:
  21. *       - engine
  22. *       - fun
  23. *
  24. *     CONFIGURATION:
  25. *       Available items can be changed (GIFT_ITEM_NUM, GIFT_ITEM), default: vest, vesthelm, nades.
  26. *
  27. *       Gift model can be changed (GIFT_MODEL), default: "models/w_battery.mdl".
  28. *
  29. *       Plugin can be disabled by changing "amx_newround_gift" CVAR value to 0.
  30. */

  31. #include <amxmodx>
  32. #include <engine>
  33. #include <fun>

  34. #define MAX_PLAYERS 32

  35. #define GIFT_ITEM_NUM 8
  36. new const GIFT_ITEM[GIFT_ITEM_NUM][] = {
  37.         "item_assaultsuit",
  38.         "weapon_deagle",
  39.         "weapon_awp",
  40.         "weapon_ak47",
  41.         "weapon_m4a1",
  42.         "weapon_aug",
  43.         "weapon_sg552",
  44.         "weapon_hegrenade"
  45. }
  46. new g_roundcount
  47. #define GIFT_MODEL "models/w_isotopebox.mdl"
  48. #define GIFT_NAME "gift"

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

  58. public plugin_modules() {
  59.         require_module("engine")
  60.         require_module("fun")
  61. }

  62. public plugin_precache() {
  63.         precache_model(GIFT_MODEL)
  64. }
  65. public eRestart()
  66.         g_roundcount = 0

  67. public logevent_round_start() {
  68.         g_roundcount++
  69.                if (!get_cvar_num("amx_newround_gift") || g_roundcount == 1)
  70.                 return
  71.        
  72.         new pnum[2], origin[3], minor[2][3], maxor[2][3], bool:compare[2]
  73.         for (new i = 1; i <= MAX_PLAYERS; ++i) {
  74.                 if (!is_user_alive(i))
  75.                         continue
  76.                
  77.                 new team = get_user_team(i) - 1
  78.                 if (team != 0 & team != 1)
  79.                         continue
  80.                
  81.                 pnum[team]++
  82.                 get_user_origin(i, origin)
  83.                 if (compare[team]) {
  84.                         for (new j = 0; j < 3; ++j) {
  85.                                 if (origin[j] < minor[team][j])
  86.                                         minor[team][j] = origin[j]
  87.                                 if (origin[j] > maxor[team][j])
  88.                                         maxor[team][j] = origin[j]
  89.                         }
  90.                 }
  91.                 else {
  92.                         minor[team] = origin
  93.                         maxor[team] = origin
  94.                         compare[team] = true
  95.                 }
  96.         }
  97.         for (new i = 0; i < 2; ++i) {
  98.                 if (pnum[i] < 2)
  99.                         continue
  100.                
  101.                 new gift = create_entity("info_target")
  102.                 if (!gift) {
  103.                         log_amx("ERROR: Couldn't create gift entity!")
  104.                         continue
  105.                 }
  106.                
  107.                 entity_set_string(gift, EV_SZ_classname, GIFT_NAME)
  108.                 entity_set_int(gift, EV_INT_solid, SOLID_TRIGGER)
  109.                
  110.                 new Float:gift_origin[3]
  111.                 for (new j = 0; j < 3; ++j)
  112.                         gift_origin[j] = float(random_num(minor[i][j], maxor[i][j]))
  113.                 gift_origin[2] += 40
  114.                 entity_set_vector(gift, EV_VEC_origin, gift_origin)
  115.                
  116.                 entity_set_model(gift, GIFT_MODEL)
  117.         }
  118. }

  119. public touch_gift(gift, id) {
  120.         new PlayerName[32], msg[512]
  121.         get_user_name( id, PlayerName, 31)
  122.         give_item(id, GIFT_ITEM[random(GIFT_ITEM_NUM)])
  123.         remove_entity(gift)
  124.         format(msg, 511, "^x04* 玩家:^x03%s^x04 打开了礼包,获得了一份神秘礼物!", PlayerName)
  125.         client_color(0, id, msg)  
  126. }
  127. public event_round_time() {
  128.         if (read_data(1) == get_cvar_num("mp_freezetime")) {
  129.                 new gift = 0
  130.                 while ((gift = find_ent_by_class(gift, GIFT_NAME)))
  131.                         remove_entity(gift)
  132.         }
  133. }

  134. public client_color(playerid, colorid, msg[])
  135. {
  136.         message_begin(playerid?MSG_ONE:MSG_ALL,get_user_msgid("SayText"),_,playerid)
  137.         write_byte(colorid)
  138.         write_string(msg)
  139.         message_end()
  140. }
复制代码
没测试
不行我再帮你看
回复

使用道具 举报

 楼主| 发表于 2010-1-10 11:36:24 | 显示全部楼层 来自 黑龙江齐齐哈尔
第一局不出现礼包了 但有枪的玩家还能加礼包 还会出现一个人两把大枪




本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注个册吧

×
回复

使用道具 举报

发表于 2010-1-10 15:43:41 | 显示全部楼层 来自 广东深圳
你的服务器是不是没有设置freetime?
回复

使用道具 举报

 楼主| 发表于 2010-1-13 17:08:41 | 显示全部楼层 来自 黑龙江齐齐哈尔
是啊 2秒
回复

使用道具 举报

 楼主| 发表于 2010-1-22 11:39:17 | 显示全部楼层 来自 黑龙江齐齐哈尔
ding!!!!!!!!!!!!!!
回复

使用道具 举报

发表于 2010-2-22 22:17:44 | 显示全部楼层 来自 广东广州
看不懂!~
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表