骑马与砍杀中文站论坛

 找回密码
 注册(Register!)

QQ登录

只需一步,快速开始

搜索
购买CDKEY 小黑盒加速器
查看: 4036|回复: 1

[转贴] 友伤自动处罚程序[网页可控]

[复制链接]

282

主题

4174

回帖

4612

积分

贵族[MOD作者]

圣剑MOD制作组[程序]

Rank: 7Rank: 7Rank: 7

UID
63912
第纳尔
5396
精华
6
互助
181
荣誉
177
贡献
245
魅力
717
注册时间
2008-1-13

原版正版勋章战团正版勋章骑士美德之正义勋章[杰出会员荣誉勋章]骑士荣誉之原版汉化勋章骑士荣誉之战团汉化勋章

鲜花(11) 鸡蛋(0)
发表于 2010-10-6 14:24:48 | 显示全部楼层 |阅读模式
原帖: http://forums.taleworlds.com/index.php/topic,133745.0.html
作者: Jerkuh

Teamkill Kick/Ban Server Script
With memory and outside game manager.

I developed this script for my clan leader. Not aspecialy for him but also for all the members, because there are sometimes people killing everything in their way, including their team mates.

The script I wrote kick’s the players after a certain amount of tk’s, the amount is adjustable.

It has 3 levels of trust. You start at level 3. When you reached the amount of tk’s you can make in this level of trust you get kicked. The same story with trust level 2 but when your in trust level 1 you get a timely ban from the server (the server standard).
When you have made serval tk's and lowerd a level, dont worry, after 24 hours making no tk the tk's will be erased and you will gain 1 level of trust if your not on level 3.

Also every time someone joins that still have some teamkills he get's a warning how many kills he can make before getting kicked or baned.
This is the same when he makes a kill.

Here is a screenshot of a warning message:
(点击展开 / 收起)


To add this script to your server you need to be familiar with the module system.
You need to be able to look through module_scripts and add material between scripts.

Also some knowledge of php scripting comes in handy with this system. Becouse everytime someone makes a tk this kill will be notified to an outside website. This website is build up in php and saves all the members that has entered your server in an array and saves it in an txt, so you don’t need anny MySql.

I am not planning to give webspace free so other servers can use this functionality. What I can do is give some tips and if there is a big question meaby their will be a free service that can help people.

Here is a screenshot of how the manager looks:
(点击展开 / 收起)


The first thing you need to do is add these pieces of code in module_scripts.py:

  #script_game_receive_url_response
  #response format should be like this:
  #  [a number or a string]|[another number or a string]|[yet another number or a string] ...
  # here is an example response:
  # 12|Player|100|another string|142|323542|34454|yet another string
  # INPUT: arg1 = num_integers, arg2 = num_strings
  # reg0, reg1, reg2, ... up to 128 registers contain the integer values
  # s0, s1, s2, ... up to 128 strings contain the string values
  ("game_receive_url_response",
    [
      #here is an example usage
##      (store_script_param, ":num_integers", 1),
##      (store_script_param, ":num_strings", 2),
##      (try_begin),
##        (gt, ":num_integers", 4),
##        (display_message, "@{reg0}, {reg1}, {reg2}, {reg3}, {reg4}"),
##      (try_end),
##      (try_begin),
##        (gt, ":num_strings", 4),
##        (display_message, "@{s0}, {s1}, {s2}, {s3}, {s4}"),
##      (try_end),
                ####################
                #Teamkill Script Begin #
                ####################
                (try_begin),
                  (multiplayer_is_server),
                  (try_begin),
                        (eq, reg1, 2),
                        (try_begin),
                          (eq, reg3, 1),
                          (kick_player, reg2),
                          (str_store_player_username, s0, reg2),
                          (server_add_message_to_log, "str_teamkill_kickban"),
                        (else_try),
                          (eq, reg3, 2),
                          (ban_player, reg2, 1, 0),
                          (str_store_player_username, s0, reg2),
                          (server_add_message_to_log, "str_teamkill_kickban"),
                        (try_end),
                        (try_begin),
                          (neq, reg5, 0),
                          (try_begin),
                            (eq, reg4, 1),
                            (multiplayer_send_string_to_player, reg2, multiplayer_event_show_server_message, "str_teamkill_warning_2"),
                          (else_try),
                            (eq, reg4, 2),
                            (multiplayer_send_string_to_player, reg2, multiplayer_event_show_server_message, "str_teamkill_warning_1"),
                          (else_try),
                            (eq, reg4, 3),
                            (multiplayer_send_string_to_player, reg2, multiplayer_event_show_server_message, "str_teamkill_warning_1"),
                          (try_end),
                        (try_end),
                  (else_try),
                        (eq, reg1, 1),
                        (try_begin),
                          (eq, reg3, 1),
                          (multiplayer_send_string_to_player, reg2, multiplayer_event_show_server_message, "str_teamkill_enter_warning_2"),
                        (else_try),
                          (eq, reg3, 2),
                          (multiplayer_send_string_to_player, reg2, multiplayer_event_show_server_message, "str_teamkill_enter_warning_1"),
                        (else_try),
                          (eq, reg3, 3),
                          (multiplayer_send_string_to_player, reg2, multiplayer_event_show_server_message, "str_teamkill_enter_warning_1"),
                        (try_end),
                  (try_end),
                (try_end),
                ###################
                # Teamkill Script End #
                ###################
      ]),
      
   
          
          
          
  
  #script_multiplayer_server_on_agent_killed_or_wounded_common
  # INPUT: arg1 = dead_agent_no, arg2 = killer_agent_no
  # OUTPUT: none
  ("multiplayer_server_on_agent_killed_or_wounded_common",
   [
     (store_script_param, ":dead_agent_no", 1),
     (store_script_param, ":killer_agent_no", 2),

     (call_script, "script_multiplayer_event_agent_killed_or_wounded", ":dead_agent_no", ":killer_agent_no"),
     #adding 1 score points to agent which kills enemy agent at server
     (try_begin),
       (multiplayer_is_server),
       (try_begin), #killing myself because of some reason (friend hit, fall, team change)
         (lt, ":killer_agent_no", 0),
         (ge, ":dead_agent_no", 0),
         (neg|agent_is_non_player, ":dead_agent_no"),
         (agent_get_player_id, ":dead_agent_player_id", ":dead_agent_no"),
         (player_is_active, ":dead_agent_player_id"),
         (player_get_score, ":dead_agent_player_score", ":dead_agent_player_id"),
         (val_add, ":dead_agent_player_score", -1),
         (player_set_score, ":dead_agent_player_id", ":dead_agent_player_score"),
       (else_try), #killing teammate
         (ge, ":killer_agent_no", 0),
         (ge, ":dead_agent_no", 0),
         (agent_get_team, ":killer_team_no", ":killer_agent_no"),
         (agent_get_team, ":dead_team_no", ":dead_agent_no"),
         (eq, ":killer_team_no", ":dead_team_no"),
         (neg|agent_is_non_player, ":killer_agent_no"),
         (agent_get_player_id, ":killer_agent_player_id", ":killer_agent_no"),
         (player_is_active, ":killer_agent_player_id"),
         (player_get_score, ":killer_agent_player_score", ":killer_agent_player_id"),
         (val_add, ":killer_agent_player_score", -1),
         (player_set_score, ":killer_agent_player_id", ":killer_agent_player_score"),
         #(player_get_kill_count, ":killer_agent_player_kill_count", ":killer_agent_player_id"),
         #(val_add, ":killer_agent_player_kill_count", -2),
         #(player_set_kill_count, ":killer_agent_player_id", ":killer_agent_player_kill_count"),
                #####################
                # Teamkill Script Begin #
                #####################
                 (player_get_unique_id, ":player_unique_id", ":killer_agent_player_id"),
                 (assign, reg0, ":killer_agent_player_id"),
                 (assign, reg1, ":player_unique_id"),
                 (server_add_message_to_log, "str_teamkill_kill"),
                 (send_message_to_url, "str_teamkill_kill"),
                ###################
                # Teamkill Script End #
                ###################
       (else_try), #killing enemy
         (ge, ":killer_agent_no", 0),
         (ge, ":dead_agent_no", 0),
         (agent_is_human, ":dead_agent_no"),
         (agent_is_human, ":killer_agent_no"),
         (try_begin),
           (eq, "$g_multiplayer_game_type", multiplayer_game_type_battle),
           (try_begin),
             (eq, "$g_battle_death_mode_started", 1),
             (neq, ":dead_agent_no", ":killer_agent_no"),
             (call_script, "script_calculate_new_death_waiting_time_at_death_mod"),
           (try_end),
         (try_end),
         (try_begin),
           (this_or_next|eq, "$g_multiplayer_game_type", multiplayer_game_type_battle),
           (eq, "$g_multiplayer_game_type", multiplayer_game_type_destroy),
           (agent_get_player_id, ":dead_player_no", ":dead_agent_no"),
           (try_begin),
             (ge, ":dead_player_no", 0),
             (player_is_active, ":dead_player_no"),
             (neg|agent_is_non_player, ":dead_agent_no"),         
             (try_for_agents, ":cur_agent"),
               (agent_is_non_player, ":cur_agent"),
               (agent_is_human, ":cur_agent"),
               (agent_is_alive, ":cur_agent"),
               (agent_get_group, ":agent_group", ":cur_agent"),
               (try_begin),
                 (eq, ":dead_player_no", ":agent_group"),
                 (agent_set_group, ":cur_agent", -1),                 
               (try_end),
             (try_end),
           (try_end),
         (try_end),
         (neg|agent_is_non_player, ":killer_agent_no"),
         (agent_get_player_id, ":killer_agent_player_id", ":killer_agent_no"),
         (player_is_active, ":killer_agent_player_id"),
         (player_get_score, ":killer_agent_player_score", ":killer_agent_player_id"),
         (agent_get_team, ":killer_agent_team", ":killer_agent_no"),
         (agent_get_team, ":dead_agent_team", ":dead_agent_no"),
         (try_begin),
           (neq, ":killer_agent_team", ":dead_agent_team"),
           (val_add, ":killer_agent_player_score", 1),
         (else_try),
           (val_add, ":killer_agent_player_score", -1),
         (try_end),
         (player_set_score, ":killer_agent_player_id", ":killer_agent_player_score"),
       (try_end),
     (try_end),

     (call_script, "script_add_kill_death_counts", ":killer_agent_no", ":dead_agent_no"),
     #money management
     (call_script, "script_money_management_after_agent_death", ":killer_agent_no", ":dead_agent_no"),
     ]),



  #script_multiplayer_server_player_joined_common
  # INPUT: arg1 = player_no
  # OUTPUT: none
  ("multiplayer_server_player_joined_common",
   [
     (store_script_param, ":player_no", 1),
     (try_begin),
       (this_or_next|player_is_active, ":player_no"),
       (eq, ":player_no", 0),
       (call_script, "script_multiplayer_init_player_slots", ":player_no"),
       (store_mission_timer_a, ":player_join_time"),
       (player_set_slot, ":player_no", slot_player_join_time, ":player_join_time"),
       (player_set_slot, ":player_no", slot_player_first_spawn, 1),
       #fight and destroy only
       (player_set_slot, ":player_no", slot_player_damage_given_to_target_1, 0),
       (player_set_slot, ":player_no", slot_player_damage_given_to_target_2, 0),
       #fight and destroy only end
       (try_begin),
         (multiplayer_is_server),
         (assign, ":initial_gold", multi_initial_gold_value),
         (val_mul, ":initial_gold", "$g_multiplayer_initial_gold_multiplier"),
         (val_div, ":initial_gold", 100),
         (player_set_gold, ":player_no", ":initial_gold"),
         (call_script, "script_multiplayer_send_initial_information", ":player_no"),
                #####################
                # Teamkill Script Begin #
                #####################
                 (player_get_unique_id, ":player_unique_id", ":player_no"),
                 (assign, reg0, ":player_no"),
                 (assign, reg1, ":player_unique_id"),
                 (str_store_player_username, s0, ":player_no"),
                 (server_add_message_to_log, "str_teamkill_join"),
                 (send_message_to_url, "str_teamkill_join"),
                ###################
                # Teamkill Script End #
                ###################
       (try_end),
     (try_end),
     ]),



Now you done that you can add this peace of code at the end of strings_module.py:
  #####################
  # Teamkill Script Begin #
  #####################
  ("teamkill_join", "http://www.somewhere.com/teamkill.php?action=join&id={reg0}&uid={reg1}&name={s0}"),
  ("teamkill_kill", "http://www.somewhere.com/teamkill.php?action=kill&id={reg0}&uid={reg1}"),

  ("teamkill_kickban", "becouse he made serverval teamkills."),
  
  ("teamkill_enter_warning_1", "Warning! Becouse your teamkilling behaviore we will be forced to kick you from the server if you make {reg4} teamkill(s) within 24 hours from your last teamkill!"),
  ("teamkill_enter_warning_2", "Warning! Becouse your teamkilling behaviore we will ban you for 30 minutes if you make {reg4} teamkill(s) within 24 hours from your last teamkill!"),
  ("teamkill_warning_1", "Warning! If you make {reg5} teamkill(s) within 24 hours from now we will kick you from the server!"),
  ("teamkill_warning_2", "Warning! If you make {reg5} teamkill(s) within 24 hours from now we will ban you from the server for 30 minutes!"),
  ###################
  # Teamkill Script End #
  ###################


When you’re ready you can change the http://www.somewhere.com/ part of the teamkill_join and teamkill_kill string into your own url where you are going to store the php file.

You need to name the php file: “teamkill.php” and add this code in it:

(点击展开 / 收起)


At the top of this script you will find these variables:
  1.         $gCode = "testing";
  2.         $gFirstKick = 5;
  3.         $gSecondKick = 2;
  4.         $gBan = 2;
复制代码
You can change them to whatever comforts you.
The first one is the code. With this code you can access the manager.
You can access the manager by going to the teamkill.php online where you store it and put after teamkill.php this line "?action=list&code=testing".
The underlined peace is the code you need to enter.

The other variables are the amount of tk's by level.
$gFirstKick is for the first trust level, level 3.
$gSecondKick for the second and $gBan for the last one.

You can always ask me for questions when i didnt make somthing clear enough.
Have fun with it.


圣剑第一章

论坛问答指南
MOD制作最简入门
联机MOD场景地图制作
汉化是一种自豪的苦力


虽然圆桌骑士公会的头衔被某人摘掉了,我们还是其中的一员,始终信奉自由、平等与公正。

282

主题

4174

回帖

4612

积分

贵族[MOD作者]

圣剑MOD制作组[程序]

Rank: 7Rank: 7Rank: 7

UID
63912
第纳尔
5396
精华
6
互助
181
荣誉
177
贡献
245
魅力
717
注册时间
2008-1-13

原版正版勋章战团正版勋章骑士美德之正义勋章[杰出会员荣誉勋章]骑士荣誉之原版汉化勋章骑士荣誉之战团汉化勋章

鲜花(11) 鸡蛋(0)
 楼主| 发表于 2010-10-6 14:26:22 | 显示全部楼层
实际上这是一个战团存取网络数据的典型例子,   希望对大家有所启发。


圣剑第一章

论坛问答指南
MOD制作最简入门
联机MOD场景地图制作
汉化是一种自豪的苦力


虽然圆桌骑士公会的头衔被某人摘掉了,我们还是其中的一员,始终信奉自由、平等与公正。
您需要登录后才可以回帖 登录 | 注册(Register!)

本版积分规则

Archiver|手机版|小黑屋|骑马与砍杀中文站

GMT+8, 2024-11-19 10:46 , Processed in 0.128157 second(s), 19 queries , Gzip On, MemCached On.

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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