- 好友
- 22
- 在线时间
- 7893 小时
- 最后登录
- 2012-7-27
贵族[MOD作者]
圣剑MOD制作组[程序]
- UID
- 63912
- 第纳尔
- 5396
- 精华
- 6
- 互助
- 181
- 荣誉
- 177
- 贡献
- 245
- 魅力
- 717
- 注册时间
- 2008-1-13
鲜花( 11) 鸡蛋( 0)
|
原帖: 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:
<?php
$gCode = "testing";
$gFirstKick = 5;
$gSecondKick = 2;
$gBan = 2;
date_default_timezone_set('UTC');
if ($_GET['action'] == "kill" and $_GET['id'] and $_GET['uid']) {
$pId = $_GET['id'];
$pUid = $_GET['uid'];
$aRead = unserialize(file_get_contents("teamkills.txt"));
if ($aRead[$pUid]['last_kill'] >= date("U")+86400 and $aRead[$pUid]['trust'] == 1) {
$aRead[$pUid]['trust'] = 2;
$aRead[$pUid]['teamkills'] = 0;
} elseif ($aRead[$pUid]['last_kill'] >= date("U")+172800 and $aRead[$pUid]['trust'] == 2) {
$aRead[$pUid]['trust'] = 3;
$aRead[$pUid]['teamkills'] = 0;
}
$aRead[$pUid]['last_kill'] = date("U");
$aRead[$pUid]['teamkills'] += 1;
if ($aRead[$pUid]['trust'] == 3 and $aRead[$pUid]['teamkills'] >= $gFirstKick) {
echo "1|2|$pId|1|";
$aRead[$pUid]['teamkills'] = 0;
$aRead[$pUid]['trust'] = 2;
} elseif ($aRead[$pUid]['trust'] == 2 and $aRead[$pUid]['teamkills'] >= $gSecondKick) {
echo "|1|2|$pId|1|";
$aRead[$pUid]['teamkills'] = 0;
$aRead[$pUid]['trust'] = 1;
} elseif ($aRead[$pUid]['trust'] == 1 and $aRead[$pUid]['teamkills'] >= $gBan) {
echo "|1|2|$pId|2|";
$aRead[$pUid]['teamkills'] = 0;
} elseif ($aRead[$pUid]['trust'] == 3) {
echo "|1|2|$pId|0|".$aRead[$pUid]['trust']."|".($gFirstKick-$aRead[$pUid]['teamkills'])."|";
} elseif ($aRead[$pUid]['trust'] == 2) {
echo "|1|2|$pId|0|".$aRead[$pUid]['trust']."|".($gSecondKick-$aRead[$pUid]['teamkills'])."|";
} else {
echo "|1|2|$pId|0|".$aRead[$pUid]['trust']."|".($gBan-$aRead[$pUid]['teamkills'])."|";
}
file_put_contents("teamkills.txt", serialize($aRead));
} elseif ($_GET['action'] == "join" and $_GET['id'] and $_GET['uid'] and is_string($_GET['name'])) {
$pId = $_GET['id'];
$pUid = $_GET['uid'];
$pName = $_GET['name'];
$aRead = unserialize(file_get_contents("teamkills.txt"));
$aRead[$pUid]['id'] = $pId;
$aRead[$pUid]['name'] = $pName;
if (empty($aRead[$pUid]['teamkills'])) {
$aRead[$pUid]['teamkills'] = 0;
}
if (empty($aRead[$pUid]['trust'])) {
$aRead[$pUid]['trust'] = 3;
}
if (!empty($aRead[$pUid]['last_kill']) and $aRead[$pUid]['last_kill'] >= date("U")+86400 and $aRead[$pUid]['trust'] == 1) {
$aRead[$pUid]['trust'] = 2;
$aRead[$pUid]['teamkills'] = 0;
} elseif (!empty($aRead[$pUid]['last_kill']) and $aRead[$pUid]['last_kill'] >= date("U")+172800 and $aRead[$pUid]['trust'] == 2) {
$aRead[$pUid]['trust'] = 3;
$aRead[$pUid]['teamkills'] = 0;
} else {
$aRead[$pUid]['last_kill'] = 0;
}
if (!$aRead[$pUid]['teamkills'] == 0 and $aRead[$pUid]['trust'] == 3) {
echo "1|1|$pId|".$aRead[$pUid]['trust']."|".($gFirstKick-$aRead[$pUid]['teamkills'])."|";
} elseif ($aRead[$pUid]['trust'] == 2) {
echo "1|1|$pId|".$aRead[$pUid]['trust']."|".($gSecondKick-$aRead[$pUid]['teamkills'])."|";
} elseif ($aRead[$pUid]['trust'] == 1) {
echo "1|1|$pId|".$aRead[$pUid]['trust']."|".($gBan-$aRead[$pUid]['teamkills'])."|";
} else {
echo "1|3|";
}
file_put_contents("teamkills.txt", serialize($aRead));
} elseif ($_GET['action'] == "list" and $_GET['code'] == $gCode) {
$aRead = unserialize(file_get_contents("teamkills.txt"));
if ($_GET['rcode']) {
foreach ($aRead as $aPlayerID => $aPlayer){
if ($_GET['rcode'] == md5($aPlayerID)) {
$aRead[$aPlayerID]['trust'] = 3;
$aRead[$aPlayerID]['teamkills'] = 0;
$aRead[$aPlayerID]['last_kill'] = 0;
}
}
}
reset($aRead);
echo "<table border='1'>";
echo "<tr>";
echo "<td>Unique ID</td>";
echo "<td>Last Used Player ID</td>";
echo "<td>Last Used Player Username</td>";
echo "<td>Teamkills within 24 hours</td>";
echo "<td>Trust Level</td>";
echo "<td>Time Of Last Team Kill/Join</td>";
echo "<td>Days between Last Team Kill/Join</td>";
echo "<td>Reset</td>";
echo "<tr>";
foreach ($aRead as $aPlayerID => $aPlayer) {
$iRCode = md5($aPlayerID);
echo "<tr><td>".$aPlayerID."</td>";
foreach ($aPlayer as $aContent) {
echo "<td>".$aContent."</td>";
}
$cDate = date("U");
$cSom = round(((date("U")-$aContent)/86400), 1);
echo "<td>";
echo $cDate;
echo "-";
echo $aContent;
echo "=";
echo $cDate-$aContent;
echo "/86400=";
echo $cSom;
echo "</td>";
echo "<td><a href='?action=list&code=$gCode&rcode=$iRCode'>X</a></td>";
echo "</tr>";
}
echo "</table>";
file_put_contents("teamkills.txt", serialize($aRead));
}
?>
|
At the top of this script you will find these variables:- $gCode = "testing";
- $gFirstKick = 5;
- $gSecondKick = 2;
- $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. |
|