Exara
There is NO Guarantee that these work, they are just a beta version and i will be fixing them at my own pace.
____________________________________________________________________________________________________________________________________
Last Updated 8/1/14 // 01/08/14 (I think i did that right >.>)
Current Features
Planned Features
Source Code (if you need help leave reply)
PHP Source Code (credit to The_Dragon for these great PHP part of scripts (With my modifications) click here for his tutorial
____________________________________________________________________________________________________________________________________
Last Updated 8/1/14 // 01/08/14 (I think i did that right >.>)
v1.0 Initial release, coming with all the current scripts. (PHP, Module Scripts were Released)
v1.1 Few Bug fixes for left out code (Loading for with PHP was Updated, Module Scripts were updated)
v1.1 Few Bug fixes for left out code (Loading for with PHP was Updated, Module Scripts were updated)
Current Features
- Item Saving & Loading
- Position Saving & Loading
- Armor Saving & Loading
- Food Saving & Loading
- Kills & Death Saving & Loading
- Faction Saving & Loading (currently being worked on)
- Troop Saving & Loading
Planned Features
- Banks
- Bank Caps (can be increased)
- Custom Housing
Source Code (if you need help leave reply)
I have replaced and added a few parts of the source code so first find game_receive_url_response and add
And after that theres a new script line to add after the ]), of the above scripts
please do not forget to change (str_store_string, s20, "@(put security password here)<--- This
Now find cf_save_player_exit (i think the names pretty self explanitory), replace that with
After you do all of this find cf_player_store_inactive and replace it with
Code:
("game_receive_url_response", # called by the game when a response is received from a web server, if used
[(store_script_param, ":integer_count", 1),
(store_script_param, ":string_count", 2),
(assign, "$g_name_server_enabled", 1),
(try_begin),
(ge, ":integer_count", 1),
(assign, ":return_code", reg0),
(try_begin), # negative return codes are internal or configuration errors, not requiring action
(lt, ":return_code", 0),
(server_add_message_to_log, "str_name_server_error_code_reg0"),
(else_try), # return code 0 is success, don't kick the player
(eq, ":return_code", 0),
(this_or_next|lt, ":integer_count", 4), # admin permissions not received
(eq, reg3, -1), # admin permissions not set
(else_try),
(ge, ":integer_count", 3),
(ge, ":string_count", 1),
(assign, ":player_id", reg1),
(assign, ":unique_id", reg2),
(player_is_active, ":player_id"),
(player_get_unique_id, ":player_unique_id", ":player_id"),
(eq, ":player_unique_id", ":unique_id"),
(try_begin), # positive return codes are for rejecting the player
(gt, ":return_code", 0),
(try_begin),
(eq, ":return_code", 4),
(assign, ":rejection_string_id", "str_kicked_not_registered"),
(else_try),
(eq, ":return_code", 3),
(assign, ":rejection_string_id", "str_kicked_using_invalid_name"),
(else_try),
(eq, ":return_code", 2),
(assign, ":rejection_string_id", "str_kicked_using_other_clan_tag"),
(else_try),
(assign, ":rejection_string_id", "str_kicked_using_other_players_name"),
(try_end),
(multiplayer_send_2_int_to_player, ":player_id", server_event_preset_message, ":rejection_string_id", preset_message_error|preset_message_log),
(store_mission_timer_a, ":time"), # kick the player after a short delay to try ensure they see the rejection message
(val_add, ":time", name_server_kick_delay_interval),
(player_set_slot, ":player_id", slot_player_kick_at_time, ":time"),
(str_store_string, s10, ":rejection_string_id"),
(server_add_message_to_log, "str_name_server_log_s10"),
(try_end),
(try_begin), # admin permissions were received
(ge, ":integer_count", 4),
(player_is_admin, ":player_id"),
(assign, ":admin_permissions", reg3),
(val_max, ":admin_permissions", 0),
(call_script, "script_player_set_admin_permissions", ":player_id", ":admin_permissions"),
(multiplayer_send_int_to_player, ":player_id", server_event_admin_set_permissions, ":admin_permissions"),
(try_end),
(else_try),
(server_add_message_to_log, "str_name_server_invalid_response"),
(try_end),
(try_begin),
(eq, ":integer_count", 0),
(eq, ":string_count", 1),
(display_message, s0),#error will display in console window
(else_try),
(gt, ":integer_count", 0),#just in case
(assign, ":event", reg0),
(try_begin),
(eq, ":event", -1),#could not connect to mysql server
(display_message, "@Could not connect to the database!"),
(else_try),
(eq, ":event", 1),#Loads Items and Sets them
(try_begin),
### Gets Username and Agent ID ###
(player_get_unique_id, ":uid", ":unique_id"),
(eq, ":uid", ":unique_id"),
(player_get_agent_id, ":agent_id", ":uid"),
### Assigns everything it received from the URL ###
(assign, ":uid", reg0),
(assign, ":head", reg1),
(assign, ":body", reg2),
(assign, ":foot", reg3),
(assign, ":gloves", reg4),
(assign, ":item0", reg5),
(assign, ":item1", reg6),
(assign, ":item2", reg7),
(assign, ":item3", reg8),
(assign, ":kills", reg9),
(assign, ":deaths", reg10),
(assign, ":CoordinateX", reg11),
(assign, ":CoordinateY", reg12),
(assign, ":CoordinateZ", reg13),
(assign, ":food", reg14),
(assign, ":hp", reg15),
(assign, ":gold", reg3),
### Sets Players Gold ###
(player_is_active, ":local_id"),
(player_set_gold, ":local_id", ":gold"),
### Makes sure the Agent is Active. ###
(agent_is_active, ":agent_id"),
### Loads Players Kills & Deaths ###
(player_set_death_count, ":uid", ":deaths"),
(player_set_kill_count, ":uid", ":kills"),
### Loads Players Gear ###
(call_script, "script_change_armor", ":agent_id", ":head"),
(call_script, "script_change_armor", ":agent_id", ":body"),
(call_script, "script_change_armor", ":agent_id", ":foot"),
(call_script, "script_change_armor", ":agent_id", ":gloves"),
### Loads Players Items ###
(player_set_slot, ":uid", ek_item_0, ":item0"),
(player_set_slot, ":uid", ek_item_1, ":item1"),
(player_set_slot, ":uid", ek_item_2, ":item2"),
(player_set_slot, ":uid", ek_item_3, ":item3"),
### Loads Players Position ###
(position_set_x, pos1, ":CoordinateX"),
(position_set_y, pos1, "::CoordinateY"),
(position_set_z, pos1, ":CoordinateZ"),
(set_spawn_position, pos1)
### Loads Players Food ###
(player_set_slot, ":uid", ek_food, ":food"),
### Loads Players HP(Health/Hit Points) ###
(agent_set_hit_points,":agent_id" , ":hp",1),
(try_end),
(try_end),
(try_end),
(try_end),
(try_end),
]),
And after that theres a new script line to add after the ]), of the above scripts
please do not forget to change (str_store_string, s20, "@(put security password here)<--- This
Code:
("load",
[(store_script_param, ":event", 1),
(player_get_unique_id, reg1, reg0),
(str_store_player_username, s0, reg0),
(str_store_string, s20, "@(put security password here)"),
(send_message_to_url, "@http://127.0.0.1/(change1).php?unique_id={reg1}&local_id={reg0}&event=2&name={s0}&security={s20)"),
]),
Now find cf_save_player_exit (i think the names pretty self explanitory), replace that with
Code:
("cf_save_player_exit", # server: when a player disconnects, save attributes to the inactive players list
[(store_script_param, ":player_id", 1), # must be valid
(player_get_agent_id, ":agent_id", ":player_id"),
(neq, ":agent_id", -1),
(player_get_unique_id, ":unique_id", ":player_id"),
(try_begin),
(assigh, ":unique_id", reg10),
(player_get_slot, ":item0", ":unique_id", ek_item_0),
(player_get_slot, ":item1", ":unique_id", ek_item_1),
(player_get_slot, ":item2", ":unique_id", ek_item_2),
(player_get_slot, ":item3", ":unique_id", ek_item_3),
(player_get_slot, ":head", ":unique_id", ek_head),
(player_get_slot, ":body", ":unique_id", ek_body),
(player_get_slot, ":foot", ":unique_id", ek_foot),
(player_get_slot, ":gloves", ":unique_id", ek_gloves),
(player_get_slot, ":food", ":unique_id", ek_food),
(player_get_slot, ":horse", ":unique_id", ek_horse),
(position_get_x, ":CoordinateX", ":unique_id"),
(position_get_y, ":CoordinateY", ":unique_id"),
(position_get_z, ":CoordinateZ", ":unique_id"),
(player_get_kill_count, ":kills", ":unique_id"),
(player_get_death_count, ":deaths", ":unique_id"),
(assign, ":item0", reg0),
(assign, ":item1", reg1),
(assign, ":item2", reg2),
(assign, ":item3", reg3),
(assign, ":head", reg4),
(assign, ":body", reg5),
(assign, ":foot", reg6),
(assign, ":gloves", reg7),
(assign, ":food", reg8),
(assign, ":horse", reg9),
(assign, ":CoordinateX", reg11),
(assign, ":CoordinateY", reg12),
(assign, ":CoordinateZ", reg13),
(assign, ":kills", reg14),
(assign, ":deaths", reg15),
(player_get_gold, reg16),
(str_store_string, s20, "@(put security password here)"),
(send_message_to_url, "@http://127.0.0.1/save.php?unique_id={reg10}&item0={reg0}&item1={reg1}&item2={reg2}&item3={reg3}&head={reg4}&body={reg5}&foot={reg6}&gloves={reg7}&food={reg8}&horse={reg9}&x={reg11}&y={reg12}&z={reg13}&kills={reg14}&deaths={reg15}&gold={reg16}&security={s20}"),
(try_end),
(player_get_troop_id, ":troop_id", ":player_id"),
(is_between, ":troop_id", playable_troops_begin, playable_troops_end),
(player_get_unique_id, ":player_unique_id", ":player_id"),
(troop_get_slot, ":inactive_array_size", "trp_inactive_players_array", slot_player_array_size),
(assign, ":loop_end", ":inactive_array_size"),
(assign, ":inactive_index", slot_player_array_begin),
(try_for_range, ":unused", 0, ":loop_end"),
(this_or_next|troop_slot_eq, "trp_inactive_players_array", ":inactive_index", 0),
(troop_slot_eq, "trp_inactive_players_array", ":inactive_index", ":player_unique_id"),
(assign, ":loop_end", -1),
(else_try),
(val_add, ":inactive_index", player_array_entry_size),
(try_end),
(try_begin),
(call_script, "script_cf_player_store_inactive", ":player_id", ":inactive_index"),
(troop_set_slot, "trp_inactive_players_array", ":inactive_index", ":player_unique_id"),
(player_set_slot, ":player_id", slot_player_inactive_index, ":inactive_index"),
(neq, ":loop_end", -1),
(val_add, ":inactive_array_size", 1),
(troop_set_slot, "trp_inactive_players_array", slot_player_array_size, ":inactive_array_size"),
(try_end),
(assign, ":loop_end", factions_end),
(try_for_range, ":faction_id", castle_factions_begin, ":loop_end"),
(faction_get_slot, ":lord_player_uid", ":faction_id", slot_faction_lord_player_uid),
(eq, ":lord_player_uid", ":player_unique_id"),
(assign, ":loop_end", -1),
(store_mission_timer_a, ":current_time"),
(faction_set_slot, ":faction_id", slot_faction_lord_last_seen_time, ":current_time"),
(try_end),
]),
After you do all of this find cf_player_store_inactive and replace it with
Code:
("cf_player_store_inactive", # server: store player attributes starting at a specified index in a list
[(store_script_param, ":player_id", 1), # must be valid
(store_script_param, ":inactive_index", 2),
(player_get_troop_id, ":troop_id", ":player_id"),
(is_between, ":troop_id", playable_troops_begin, playable_troops_end),
(try_begin),
(neq, "$g_game_type", "mt_permanent_death"),
(player_get_slot, ":faction_id", ":player_id", slot_player_faction_id),
(player_get_gold, ":gold_value", ":player_id"),
(else_try),
(assign, ":troop_id", playable_troops_begin),
(assign, ":faction_id", factions_begin),
(assign, ":gold_value", 0),
(assign, ":troop_id", reg16),
(assign, ":faction_id", reg17),
(player_get_unique_id, ":unique_id", ":player_id"),
(assign, ":unique_id", reg10),
(send_message_to_url, "@http://127.0.0.1/save.php?unique_id={reg10}&troop={reg16}&faction={reg17}"),
(try_end),
(store_add, ":temp_index", ":inactive_index", player_array_troop_id),
(troop_set_slot, "trp_inactive_players_array", ":temp_index", ":troop_id"),
(store_add, ":temp_index", ":inactive_index", player_array_faction_id),
(troop_set_slot, "trp_inactive_players_array", ":temp_index", ":faction_id"),
(store_add, ":temp_index", ":inactive_index", player_array_gold_value),
(troop_set_slot, "trp_inactive_players_array", ":temp_index", ":gold_value"),
(player_get_slot, ":outlaw_rating", ":player_id", slot_player_outlaw_rating),
(store_add, ":temp_index", ":inactive_index", player_array_outlaw_rating),
(troop_set_slot, "trp_inactive_players_array", ":temp_index", ":outlaw_rating"),
]),
PHP Source Code (credit to The_Dragon for these great PHP part of scripts (With my modifications) click here for his tutorial
This is (change1) in the scripts so you can have the .php file name you want.
This is save.php which ofc, saves
Code:
<?php
header_remove();
function set_content_length($output)
{
header("Content-Length: ".strlen($output));
return $output;
}
ob_start("set_content_length");
//the above part is for fixing a warband reading headers error
if(isset($_GET['event']) && isset($_GET['unique_id']) && isset($_GET['local_id'])&& isset($_GET['name'])&& isset($_GET['security']) && $_GET['security'] == '(change this for security)')
{
$unique_id=$_GET["unique_id"];
$local_id=$_GET["local_id"];//for feedback only
$name=$_GET["name"];
$db_handle = mysqli_connect("ip(usually localhost)", "root", "password", "database") or die("|-1");
if($db_handle)
if($_GET['event'] == 1)//loads players gold
{
$sql_result = mysqli_query($db_handle, "SELECT Gold FROM playerdata WHERE Unique_Id = '$unique_id'" );
$result = mysqli_fetch_row($sql_result);
if(!isSet($result)) {//the player is not in the database, so we will insert it
mysqli_query($db_handle, "INSERT INTO playerdata (Unique_Id,Name,Gold) VALUES($unique_id, '$name', 5000)");
echo "4|$unique_id|$local_id|5000|";//and we will echo gold as 0
}else{
$fetch = mysqli_query($db_handle, "SELECT Gold FROM playerdata WHERE Unique_Id = '$unique_id'" );
$row = mysqli_fetch_array($fetch);
echo "4|$unique_id|$local_id|$row[Gold]|";
}
} else if($_GET['event'] == 2)//loads players everything
{
$fetch = mysqli_query($db_handle, "SELECT Item0, Item1, Item2, Item3, Head, Body, Gloves, Foot, Troop, CoordinateX, CoordinateY, CoordinateZ, Horse, Kills, Deaths, Food FROM playerdata WHERE Unique_Id = '$unique_id'" );
$row = mysqli_fetch_assoc($fetch);
echo "1|$unique_id|$local_id|$row[Item0]|$row[Item1]|$row[Item2]|$row[Item3]|$row[Head]|$row[Body]|$row[Gloves]|$row[Foot]|$row[Troop]|$row[CoordinateX]|$row[CoordinateY]|$row[CoordinateZ]|$row[Horse]|$row[Faction]|$row[Kills]|$row[Deaths]|$row[Food]|";
if(!isSet($result)) {//the player is not in the database, so we will insert it
mysqli_query($db_handle, "INSERT INTO playerdata (Item0, Item1, Item2, Item3, Head, Body, Gloves, Foot, Troop, CoordinateX, CoordinateY, CoordinateZ, Horse, Kills, Deaths, Food) VALUES($unique_id, '$name', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50)");
echo "1|$unique_id|$local_id|$row[Item0]|$row[Item1]|$row[Item2]|$row[Item3]|$row[Head]|$row[Body]|$row[Gloves]|$row[Foot]|$row[Troop]|$row[CoordinateX]|$row[CoordinateY]|$row[CoordinateZ]|$row[Horse]|$row[Faction]|$row[Kills]|$row[Deaths]|$row[Food]|";
}else{
$fetch = mysqli_query($db_handle, "SELECT Item0, Item1, Item2, Item3, Head, Body, Gloves, Foot, Troop, CoordinateX, CoordinateY, CoordinateZ, Horse, Kills, Deaths, Food FROM playerdata WHERE Unique_Id = '$unique_id'" );
$row = mysqli_fetch_assoc($fetch);
echo "1|$unique_id|$local_id|$row[Item0]|$row[Item1]|$row[Item2]|$row[Item3]|$row[Head]|$row[Body]|$row[Gloves]|$row[Foot]|$row[Troop]|$row[CoordinateX]|$row[CoordinateY]|$row[CoordinateZ]|$row[Horse]|$row[Faction]|$row[Kills]|$row[Deaths]|$row[Food]|";
}
}
mysqli_close($db_handle);
}
?>
This is save.php which ofc, saves
Code:
<?php
header_remove();
function set_content_length($output)
{
header("Content-Length: ".strlen($output));
return $output;
}
ob_start("set_content_length");
//the above part is for fixing a warband reading headers error
if(isset($_GET['event']) && isset($_GET['unique_id']) && isset($_GET['name'])&& isset($_GET['security']) && $_GET['security'] == '(change this for security)')
{
$unique_id=$_GET["unique_id"];
$db_handle = mysqli_connect("ip(usually localhost)", "root", "password", "database") or die("|-1");
if($db_handle)
if($_GET['event'] == 1){//Saves Item, Armor, Horse and Food to Database
$item0=$_GET['item0'];
$item1=$_GET['item1'];
$item2=$_GET['item2'];
$item3=$_GET['item3'];
$head=$_GET['head'];
$body=$_GET['body'];
$gloves=$_GET['gloves'];
$foot=$_GET['foot'];
$horse=$_GET['horse'];
$food=$_GET['food'];
$x=$_GET['x'];
$y=$_GET['y'];
$z=$_GET['z'];
$kills=$_GET['kills'];
$deaths=$_GET['deaths'];
$hp=$_GET['hp']
mysqli_query($db_handle, "UPDATE playerdata SET head = '$head', body = '$body', gloves = '$gloves', foot = '$foot', offline = 1,item0 = '$item0', item1 = '$item1', item2 = '$item2', item3 = '$item3', horse = '$horse', food = '$food', CoordinateX = '$x', CoordinateY = '$y', CoordinateZ = '$z', kills = '$kills', deaths = '$deaths', hp = '$hp' WHERE Unique_Id = '$unique_id'");
}
}else if($_GET['event'] == 2){//Saves Armor to Database
$faction=$_GET['faction'];
$troop=$_GET['troop'];
mysqli_query($db_handle, "UPDATE playerdata SET faction = '$faction', troop ='$troop' WHERE Unique_Id = '$unique_id'");
}
mysqli_close($db_handle);
}
?>
Code:
CREATE TABLE IF NOT EXISTS `playerdata` (
`Unique_Id` int(11) NOT NULL,
`Name` text NOT NULL,
`Id` int(11) NOT NULL,
`Gold` int(11) NOT NULL,
`Bank` int(11) NOT NULL,
`Troop` int(11) NOT NULL,
`Head` int(11) NOT NULL,
`Body` int(11) NOT NULL,
`Gloves` int(11) NOT NULL,
`Foot` int(11) NOT NULL,
`CombatLog` int(11) NOT NULL,
`Item0` int(11) NOT NULL,
`Item1` int(11) NOT NULL,
`Item2` int(11) NOT NULL,
`Item3` int(11) NOT NULL,
`CoordinateX` int(11) NOT NULL,
`CoordinateY` int(11) NOT NULL,
`CoordinateZ` int(11) NOT NULL,
`Horse` int(11) NOT NULL,
`Hp` int(11) NOT NULL,
`Faction` int(11) NOT NULL,
`Food` int(11) NOT NULL,
`Online` int(11) NOT NULL,
`Offline` int(11) NOT NULL,
`Kills` int(11) NOT NULL,
`Deaths` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;