mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-07-06 11:40:16 +02:00
Toggle guild nick feature in config.php
Fix #407 TFS 1.3 has a potential unresolved crash bug related to guild nicks. You can check out the details here: https://github.com/otland/forgottenserver/issues/2561#issuecomment-633101435
This commit is contained in:
parent
31c233d559
commit
5a80034915
@ -620,6 +620,11 @@
|
||||
// Do you need to have premium account to create a guild?
|
||||
$config['guild_require_premium'] = true;
|
||||
|
||||
// There is a TFS 1.3 bug related to guild nicks
|
||||
// https://github.com/otland/forgottenserver/issues/2561
|
||||
// So if your using TFS 1.x, you might need to disable guild nicks until the crash has been fixed.
|
||||
$config['guild_allow_nicknames'] = true;
|
||||
|
||||
$config['guildwar_enabled'] = false;
|
||||
|
||||
// Use htaccess rewrite? (basically this makes website.com/username work instead of website.com/characterprofile.php?name=username
|
||||
|
@ -436,7 +436,7 @@ function update_player_guildnick($cid, $nick) {
|
||||
|
||||
mysql_update("UPDATE `players` SET `guildnick`='$nick' WHERE `id`=$cid");
|
||||
} else {
|
||||
mysql_update("UPDATE `players` SET `guildnick`= NULL WHERE `id`=$cid");
|
||||
mysql_update("UPDATE `players` SET `guildnick`='' WHERE `id`=$cid");
|
||||
}
|
||||
}
|
||||
function update_player_guildnick_10($cid, $nick) {
|
||||
@ -445,7 +445,7 @@ function update_player_guildnick_10($cid, $nick) {
|
||||
if (!empty($nick)) {
|
||||
mysql_update("UPDATE `guild_membership` SET `nick`='$nick' WHERE `player_id`=$cid");
|
||||
} else {
|
||||
mysql_update("UPDATE `guild_membership` SET `nick`= NULL WHERE `player_id`=$cid");
|
||||
mysql_update("UPDATE `guild_membership` SET `nick`='' WHERE `player_id`=$cid");
|
||||
}
|
||||
}
|
||||
|
||||
|
80
guilds.php
80
guilds.php
@ -400,22 +400,24 @@ if ($highest_access >= 2) {
|
||||
|
||||
// Change Guild Nick
|
||||
if (!empty($_POST['player_guildnick'])) {
|
||||
$p_cid = user_character_id($_POST['player_guildnick']);
|
||||
$p_guild = get_player_guild_data($p_cid);
|
||||
if (preg_match("/^[a-zA-Z_ ]+$/", $_POST['guildnick']) || empty($_POST['guildnick'])) {
|
||||
// Only allow normal symbols as guild nick
|
||||
$p_nick = sanitize($_POST['guildnick']);
|
||||
if ($p_guild['guild_id'] == $gid) {
|
||||
if ($config['ServerEngine'] !== 'TFS_10') $chardata = user_character_data($p_cid, 'online');
|
||||
else $chardata['online'] = (user_is_online_10($p_cid)) ? 1 : 0;
|
||||
if ($chardata['online'] == 0) {
|
||||
if ($config['ServerEngine'] !== 'TFS_10') update_player_guildnick($p_cid, $p_nick);
|
||||
else update_player_guildnick_10($p_cid, $p_nick);
|
||||
header('Location: guilds.php?name='. $_GET['name']);
|
||||
exit();
|
||||
} else echo '<font color="red" size="4">Character not offline.</font>';
|
||||
}
|
||||
} else echo '<font color="red" size="4">Character guild nick may only contain a-z, A-Z and spaces.</font>';
|
||||
if ($config['guild_allow_nicknames']) {
|
||||
$p_cid = user_character_id($_POST['player_guildnick']);
|
||||
$p_guild = get_player_guild_data($p_cid);
|
||||
if (preg_match("/^[a-zA-Z_ ]+$/", $_POST['guildnick']) || empty($_POST['guildnick'])) {
|
||||
// Only allow normal symbols as guild nick
|
||||
$p_nick = sanitize($_POST['guildnick']);
|
||||
if ($p_guild['guild_id'] == $gid) {
|
||||
if ($config['ServerEngine'] !== 'TFS_10') $chardata = user_character_data($p_cid, 'online');
|
||||
else $chardata['online'] = (user_is_online_10($p_cid)) ? 1 : 0;
|
||||
if ($chardata['online'] == 0) {
|
||||
if ($config['ServerEngine'] !== 'TFS_10') update_player_guildnick($p_cid, $p_nick);
|
||||
else update_player_guildnick_10($p_cid, $p_nick);
|
||||
header('Location: guilds.php?name='. $_GET['name']);
|
||||
exit();
|
||||
} else echo '<font color="red" size="4">Character not offline.</font>';
|
||||
}
|
||||
} else echo '<font color="red" size="4">Character guild nick may only contain a-z, A-Z and spaces.</font>';
|
||||
} else echo '<font color="red" size="4">Change guild nickname feature has been disabled.</font>';
|
||||
}
|
||||
|
||||
// Promote character to guild position
|
||||
@ -696,32 +698,34 @@ if ($highest_access >= 2) {
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
<!-- FORMS TO CHANGE GUILD NICK -->
|
||||
<form action="" method="post">
|
||||
<ul>
|
||||
<li>
|
||||
Change Guild Nick:<br>
|
||||
<select name="player_guildnick">
|
||||
<?php
|
||||
//$gid = get_guild_id($_GET['name']);
|
||||
//$players = get_guild_players($gid);
|
||||
<?php if ($config['guild_allow_nicknames']): ?>
|
||||
<!-- FORMS TO CHANGE GUILD NICK -->
|
||||
<form action="" method="post">
|
||||
<ul>
|
||||
<li>
|
||||
Change Guild Nick:<br>
|
||||
<select name="player_guildnick">
|
||||
<?php
|
||||
//$gid = get_guild_id($_GET['name']);
|
||||
//$players = get_guild_players($gid);
|
||||
|
||||
foreach ($players as $player) {
|
||||
if ($player['rank_level'] != 3) {
|
||||
echo '<option value="'. $player['name'] .'">'. $player['name'] .'</option>';
|
||||
} else {
|
||||
if ($highest_access == 3) {
|
||||
foreach ($players as $player) {
|
||||
if ($player['rank_level'] != 3) {
|
||||
echo '<option value="'. $player['name'] .'">'. $player['name'] .'</option>';
|
||||
} else {
|
||||
if ($highest_access == 3) {
|
||||
echo '<option value="'. $player['name'] .'">'. $player['name'] .'</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input type="text" name="guildnick" maxlength="15" placeholder="leave blank to erase">
|
||||
<input type="submit" value="Change Nick">
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
?>
|
||||
</select>
|
||||
<input type="text" name="guildnick" maxlength="15" placeholder="leave blank to erase">
|
||||
<input type="submit" value="Change Nick">
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<!-- END FORMS TO CHANGE GUILD NICK -->
|
||||
<?php if ($members > 1) { ?>
|
||||
<!-- FORMS TO PROMOTE CHARACTER-->
|
||||
|
Loading…
x
Reference in New Issue
Block a user