Location: PHPKode > projects > PhpBlock > A9.8/script/message/sendmessage.php
<?php
global $URL_TO_SEND_MESSAGE;
//To include in a module file
include_once $PATH_TO_CODE."/script/connect.php";
include_once $PATH_TO_CODE."/script/fonction.php";
include_once $PATH_TO_CODE."/script/player.class.php";
include_once $PATH_TO_CODE."/script/block.class.php";
include_once $PATH_TO_CODE."/script/message/playermessage.class.php";

getSessionPlayerId($locPlayerId);
global $gloObjectManager;
$locPlayer = $gloObjectManager->getPlayer($locPlayerId);
initLanguageWithPlayer($locPlayer);

$locSendTargetPlayerId=getGetPost("to");
if($locSendTargetPlayerId > 0) {
    $locMessage = getGetPost("message");
    if(strlen($locMessage) > 0) {
        $locSendTargetPlayer = $gloObjectManager->getPlayer($locSendTargetPlayerId);
        if($locSendTargetPlayer) {
        	$locMessageSub = substr($locMessage, 0, 50);
            echo "send: '$locMessageSub' to: '$locSendTargetPlayer->playerName'";
            PlayerMessage::getInstance()->addPlayerMessage($locPlayerId, $locSendTargetPlayerId, $locMessage);
            commit();
        }
    }
    exit(0);
}

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<script language="javascript">
function sendMessageToPlayer(parToPlayer, parMessage) {
    if(parMessage.length > 0) {
        $('#messageMessage').val("");
        $.post("<?php echo $URL_TO_SEND_MESSAGE?>",
        { to: parToPlayer, message: parMessage},
        function(data){
            addPlayerInfo(data);
        } );
    }
}
function replyToPlayer(parToPlayerId, parMessage) {
	$("#messageMessage").val(parMessage);
	$('#messageToPlayer').val(parToPlayerId);
}
</script>
<body>
<form method="POST" onSubmit="sendMessageToPlayer($('#messageToPlayer').val(), $('#messageMessage').val()); return false;">
    <textarea cols="80" rows="4" id="messageMessage">Write here your message</textarea><br>
    Send this message to <select name="toPlayer" id="messageToPlayer">
<?php
echoOptionsWithPlayerNameAndPlayerId($locPlayerId);
?>
    </select>
    <input type="submit" value="send"/>
</form>
</body>
</html>
Return current item: PhpBlock