mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-04-30 03:09:22 +02:00
Fix #303 SQL error when joining a guild when your already in another guild
This commit is contained in:
parent
32bbecd266
commit
44839d9cdb
@ -371,7 +371,8 @@ function guild_player_join($cid, $gid) {
|
|||||||
// Add to guild if rank id was found:
|
// Add to guild if rank id was found:
|
||||||
if ($rid != false) {
|
if ($rid != false) {
|
||||||
// Remove the invite:
|
// Remove the invite:
|
||||||
guild_remove_invitation($cid, $gid);
|
//guild_remove_invitation($cid, $gid);
|
||||||
|
guild_remove_all_invitations($cid);
|
||||||
// Add to guild:
|
// Add to guild:
|
||||||
mysql_update("UPDATE `players` SET `rank_id`='$rid' WHERE `id`=$cid");
|
mysql_update("UPDATE `players` SET `rank_id`='$rid' WHERE `id`=$cid");
|
||||||
$status = true;
|
$status = true;
|
||||||
@ -383,7 +384,8 @@ function guild_player_join($cid, $gid) {
|
|||||||
if ($guildrank !== false) {
|
if ($guildrank !== false) {
|
||||||
$rid = $guildrank['id'];
|
$rid = $guildrank['id'];
|
||||||
// Remove invite
|
// Remove invite
|
||||||
guild_remove_invitation($cid, $gid);
|
//guild_remove_invitation($cid, $gid);
|
||||||
|
guild_remove_all_invitations($cid);
|
||||||
// Add to guild
|
// Add to guild
|
||||||
mysql_insert("INSERT INTO `guild_membership` (`player_id`, `guild_id`, `rank_id`, `nick`) VALUES ('$cid', '$gid', '$rid', '');");
|
mysql_insert("INSERT INTO `guild_membership` (`player_id`, `guild_id`, `rank_id`, `nick`) VALUES ('$cid', '$gid', '$rid', '');");
|
||||||
// Return success
|
// Return success
|
||||||
@ -400,6 +402,12 @@ function guild_remove_invitation($cid, $gid) {
|
|||||||
mysql_delete("DELETE FROM `guild_invites` WHERE `player_id`='$cid' AND `guild_id`='$gid';");
|
mysql_delete("DELETE FROM `guild_invites` WHERE `player_id`='$cid' AND `guild_id`='$gid';");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove ALL invitations
|
||||||
|
function guild_remove_all_invitations($cid) {
|
||||||
|
$cid = (int)$cid;
|
||||||
|
mysql_delete("DELETE FROM `guild_invites` WHERE `player_id`='$cid';");
|
||||||
|
}
|
||||||
|
|
||||||
// Invite character to guild
|
// Invite character to guild
|
||||||
function guild_invite_player($cid, $gid) {
|
function guild_invite_player($cid, $gid) {
|
||||||
$cid = (int)$cid;
|
$cid = (int)$cid;
|
||||||
|
20
guilds.php
20
guilds.php
@ -171,7 +171,7 @@ if (user_logged_in() === true) {
|
|||||||
<?php
|
<?php
|
||||||
} else { // GUILD OVERVIEW
|
} else { // GUILD OVERVIEW
|
||||||
$guild = get_guild_data($_GET['name']);
|
$guild = get_guild_data($_GET['name']);
|
||||||
$gid = $guild['id'];
|
$gid = (int)$guild['id'];
|
||||||
if ($gid === false) {
|
if ($gid === false) {
|
||||||
header('Location: guilds.php');
|
header('Location: guilds.php');
|
||||||
exit();
|
exit();
|
||||||
@ -358,16 +358,24 @@ if (user_logged_in() === true) {
|
|||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
if (!empty($_POST['joinguild'])) {
|
if (!empty($_POST['joinguild'])) {
|
||||||
//
|
$joining_player_id = (int)$_POST['joinguild'];
|
||||||
|
// Join a guild
|
||||||
foreach ($inv_data as $inv) {
|
foreach ($inv_data as $inv) {
|
||||||
if ($inv['player_id'] == $_POST['joinguild']) {
|
if ((int)$inv['player_id'] == $joining_player_id) {
|
||||||
if ($config['ServerEngine'] !== 'TFS_10') $chardata = user_character_data($_POST['joinguild'], 'online');
|
if ($config['ServerEngine'] !== 'TFS_10') $chardata = user_character_data($joining_player_id, 'online');
|
||||||
else $chardata['online'] = (user_is_online_10($_POST['joinguild'])) ? 1 : 0;
|
else $chardata['online'] = (user_is_online_10($joining_player_id)) ? 1 : 0;
|
||||||
if ($chardata['online'] == 0) {
|
if ($chardata['online'] == 0) {
|
||||||
if (guild_player_join($_POST['joinguild'], $gid)) {
|
// Ensure player is not already a member of another guild
|
||||||
|
if (get_character_guild_rank($joining_player_id) === false) {
|
||||||
|
if (guild_player_join($joining_player_id, (int)$gid)) {
|
||||||
header('Location: guilds.php?name='. $_GET['name']);
|
header('Location: guilds.php?name='. $_GET['name']);
|
||||||
exit();
|
exit();
|
||||||
} else echo '<font color="red" size="4">Failed to find guild position representing member.</font>';
|
} else echo '<font color="red" size="4">Failed to find guild position representing member.</font>';
|
||||||
|
} else {
|
||||||
|
$already_guild = get_player_guild_data($joining_player_id);
|
||||||
|
$already_guild_name = get_guild_name($already_guild['guild_id']);
|
||||||
|
echo "<font color='red' size='4'>You are already <strong>{$already_guild['rank_name']}</strong> of another guild: <strong><a href='guilds.php?name={$already_guild_name}'>{$already_guild_name}</a></strong>.<br>You need to leave that guild first before you can join another one.</font>";
|
||||||
|
}
|
||||||
} else echo '<font color="red" size="4">Character must be offline before joining guild.</font>';
|
} else echo '<font color="red" size="4">Character must be offline before joining guild.</font>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user