Jak zrobić osobny shoutbox w każdym klanie?


(Bartoszka312) #1

Witam!

Wczoraj ściągnąłem sobie silnik gry via www.

Jest tam możliwość założenia przez graczy swojej własnej koalicji

I właśnie o tą koalicję mi chodzi, gdyż chciałbym aby każda koalicja miała swój osobny shoutbox.

W moim silniki za koalicje odpowiadają dwa pliki:

coalition.php

<?php

$msg = '';

require_once('functions/ClanMgr.php');

$ClanMgr = new ClanMgr;


if(!empty($_POST['new_clan_name']) && ($player['clan_id'] == 0)){

	$msg = $ClanMgr->clan_add($config,$player, $_POST['new_clan_name']);

	reload('coalition');

} elseif(!empty($_GET['master_drop_user']) && ($player['clan_id'] != 0)){

	$msg = $ClanMgr->clan_master_drop_user($config,$player,$_GET['master_drop_user']);

	reload('coalition');

} elseif(!empty($_GET['clan_drop_user'])){

	$msg = $ClanMgr->clan_drop_user($config,$player);

	reload('coalition');

} elseif(!empty($_GET['master_del_clan']) && ($player['clan_id'] != 0)){

	$msg = $ClanMgr->clan_del($config,$player);

	reload('coalition');

} elseif(!empty($_GET['master_accept']) && ($player['clan_id'] != 0)){

	$msg = $ClanMgr->clan_accept($config,$player,$_GET['master_accept']);

	reload('coalition&type=3');

} elseif(!empty($_GET['master_decline']) && ($player['clan_id'] != 0)){

	$msg = $ClanMgr->clan_decline($config,$player,$_GET['master_decline']);

	reload('coalition&type=3');

} elseif(!empty($_GET['clan_propose'])){

	$msg = $ClanMgr->clan_propose($config,$_GET['clan_propose'],$player);

	reload('coalition&type=2');

} elseif(!empty($_GET['clan_del_propose'])){

	$ClanMgr->clan_del_propose($config,$_GET['clan_del_propose'],$player);

	reload('coalition&type=2');

}


//uprawnienia usera

$can = one("select cu_status from clans_user where cu_c_id = ".$player['clan_id']." and cu_user = ".$player['user']);


if(empty($can)) $can =0;


?>

| Załóż klan | Klan | Szukaj | Podania | Zgłoszenia |

[/code] oraz funkcja: ClanMgr.php
[code] <?php class ClanMgr{ public function clan_add($config,$player,$name){ $name = real_string($name); $can = one("select bu_lvl from buildings_user where bu_b_id = 12 and bu_p_id = ".$player['planet']); if(!empty($can) && ($can >= 3)){ if($player['clan_id']> 0){ $msg = "już jesteś w klanie"; } else { $isunique = one("select count(*) from clans where c_name = '".$name."'"); if($isunique == 1){ $msg = "nazwa zajęta"; } else { query("insert into clans(c_name) value('".$name."') "); $clan_id = one("select last_insert_id() from clans"); query("insert into clans_user(cu_c_id, cu_user, cu_status) value ($clan_id,".$player['user'].",2)"); query("update users set clan_id = $clan_id where user = ".$player['user']); $msg = "założono koalicję ".$name; } } } else { $msg = "nie posiadasz Ambasady na odpowiednim poziomie"; } return $msg; } public function clan_del($config,$player){ if($player['clan_id']== 0){ $msg = 'nie jesteś w koalicji'; } else { $can = one("select cu_status from clans_user where cu_c_id = ".$player['clan_id']." and cu_user = ".$player['user']); if($can != 2 ){ $msg = 'nie jesteś władcą koalicji'; } else { $users = one("select count(*) from clans_user where cu_c_id = ".$player['clan_id']." and cu_status > 0"); if($users > 1){ $msg = 'w koalicji są gracze, należy najpierw usunąć graczy'; } else { query("delete from clans where c_id = ".$player['clan_id']); query("delete from clans_user where cu_c_id = ".$player['clan_id']); query("update users set clan_id = 0 where user =".$player['user']); $msg = 'usunięto koalicję'; } } } return $msg; } public function clan_propose ($config,$clan,$player){ $clan = real_string($clan); if($player['clan_id']> 0){ $msg = 'jesteś już w koalicji'; } else { $clan_id = one("select c_id from clans where c_name = '".$clan."'"); if(empty($clan_id)){ $msg = 'taki sojusz nie istnieje'; } else { $check = one("select count(*) from clans_user where cu_c_id = $clan_id and cu_status = 0 and cu_user = ".$player['user']); if ($check > 0){ $msg = 'już złożyłeś podanie do tej koalicji'; } else { query("insert into clans_user(cu_c_id, cu_user) value ($clan_id,".$player['user'].")"); $msg = 'złożono podanie do koalicji'; } } } return $msg; } public function clan_del_propose ($config,$propose,$player){ $propose = (int)$propose; query("delete from clans_user where cu_user = ".$player['user']." and cu_status = 0 and cu_id =".$propose); } public function clan_accept($config,$player,$propose){ $propose = (int)$propose; if($player['clan_id']== 0){ $msg = "nie jesteś w koalicji"; } else { $ismaster = one("select cu_status from clans_user where cu_c_id = ".$player['clan_id']." and cu_user = ".$player['user']." limit 1"); if($ismaster != 2){ $msg = "nie masz uprawnień"; } else { $can = one("select cu_user from clans_user where cu_id = $propose and cu_status = 0"); if(empty($can)){ $msg = "nie ma takiego podania"; } else { query("update users set clan_id = ".$player['clan_id']." where user = $can"); query("update clans_user set cu_status = 1 where cu_user = $can and cu_id = $propose"); query("delete from clans_user where cu_status = 0 and cu_user = $can"); $msg = "dodano gracza do koalicji"; } } } return $msg; } public function clan_decline($config,$player,$propose){ $propose = (int)$propose; if($player['clan_id']== 0){ $msg = "nie jesteś w koalicji"; } else { $ismaster = one("select cu_status from clans_user where cu_c_id = ".$player['clan_id']." and cu_user = ".$player['user']." limit 1"); if($ismaster != 2){ $msg = "nie masz uprawnień"; } else { $can = one("select cu_user from clans_user where cu_id = $propose and cu_status = 0"); if(empty($can)){ $msg = "nie ma takiego podania"; } else { query("delete from clans_user where cu_status = 0 and cu_user = $can and cu_c_id =".$player['clan_id']); $msg = "odrzucono podanie"; } } } return $msg; } public function clan_master_drop_user($config,$player,$who){ $who = (int)$who; if($player['clan_id']== 0){ $msg = "nie jesteś w koalicji"; } else { $ismaster = one("select cu_status from clans_user where cu_c_id = ".$player['clan_id']." and cu_user = ".$player['user']." limit 1"); if($ismaster != 2){ $msg = "nie masz uprawnień"; } else { $can = one("select cu_id from clans_user where cu_user = $who and cu_status = 1 and cu_c_id=".$player['clan_id']); if(empty($can)){ $msg = "nie ma takiego gracza w koalicji lub próbujesz usunąć siebie"; } else { query("delete from clans_user where cu_status = 1 and cu_id = $can "); query("update users set clan_id = 0 where user =".$who); $msg = "wyrzucono gracza z koalicji"; } } } return $msg; } public function clan_drop_user($config,$player){ if($player['clan_id']== 0){ $msg = "nie jesteś w koalicji"; } else { query("delete from clans_user where cu_status = 1 and cu_user = ".$player['user']); query("update users set clan_id = 0 where user =".$player['user']); $msg = "odszedłeś z koalicji"; } return $msg; } public function clan_mass_msg($player, $text){ $text = real_string($text); query("insert into messages (m_from, m_to, m_type, m_text, m_date) select ".$player['user'].",user,1,'".$text."', now() from users where clan_id = ".$player['clan_id']." "); return "wiadomość wysłano"; } } ?>

Gdzie ja mam wstawić kod tego shoutboxa?? #-o

Proszę o wszelką pomoc!!