From 993680a39e5c63ef0b370c7f80fa932ede993870 Mon Sep 17 00:00:00 2001 From: "admin@omencraft.com" Date: Thu, 10 Nov 2011 18:28:21 +0000 Subject: Can now set gamemode via lua. git-svn-id: http://mc-server.googlecode.com/svn/trunk@89 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cPlayer.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source/cPlayer.cpp') diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp index 706886d88..8238f327c 100644 --- a/source/cPlayer.cpp +++ b/source/cPlayer.cpp @@ -28,6 +28,7 @@ #include "packets/cPacket_DestroyEntity.h" #include "packets/cPacket_Metadata.h" #include "packets/cPacket_Chat.h" +#include "packets/cPacket_NewInvalidState.h" #include "Vector3d.h" #include "Vector3f.h" @@ -423,7 +424,20 @@ void cPlayer::SetLastBlockActionCnt( int a_LastBlockActionCnt ) void cPlayer::SetGameMode( int a_GameMode ) { - m_GameMode = a_GameMode; + if ( (a_GameMode < 2) && (a_GameMode >= 0) ) { + if (m_GameMode != a_GameMode) { + m_GameMode = a_GameMode; + cPacket_NewInvalidState GameModePacket; + GameModePacket.m_Reason = 3; //GameModeChange + GameModePacket.m_GameMode = (char)a_GameMode; //GameModeChange + m_ClientHandle->Send ( GameModePacket ); + } + } +} + +void cPlayer::LoginSetGameMode( int a_GameMode ) +{ + m_GameMode = a_GameMode; } void cPlayer::SetIP( std::string a_IP ) -- cgit v1.2.3