-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
313 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
// -- Images -- | ||
|
||
int ImageCreate(char* location, int pos); | ||
// location is ; scriptfiles/images/x.img | ||
|
||
int ImageDestroy(int ID); | ||
int ImageSetColor(int id, unsigned int color); | ||
int ImageSetPos(int id, int pos); | ||
int ImageUpdate(int id, char* location); | ||
|
||
// -- Hud -- | ||
int ToggleHUDComponent(int componentid, bool toggle); | ||
int ToggleHUDComponentForPlayer(int playerid, int componentid, bool toggle); | ||
|
||
// -- Client -- | ||
// int GCI(int playerid); | ||
// | ||
int TakePlayerScreenshot(int playerid); | ||
int ToggleClientCommand(int playerid, char* command, bool toggle); | ||
int IsPlayerDisconnected(char* szName); | ||
/* | ||
native SetPlayerGravity(playerid, Float:gravity); | ||
native Float:GetGravity(); | ||
*/ | ||
|
||
// -- Vehicles -- | ||
int setPlayerVehicleComponent(struct vehicle_info *pComponent); | ||
{ | ||
// ... | ||
} | ||
|
||
|
||
// forward OnClientBanned(playerid, serialid); | ||
int CGameMode::OnClientBanned(cell playerid, cell clientid) | ||
{ | ||
CHECK_INIT(); | ||
|
||
int idx; | ||
cell ret = 0; | ||
|
||
if (!amx_FindPublic(&m_amx, "OnClientBanned", &idx)) | ||
{ | ||
amx_Push(&m_amx, amx_ftoc( clientid ) ); | ||
amx_Push(&m_amx, playerid); | ||
amx_Exec(&m_amx, &ret, idx); | ||
} | ||
return (int)ret; | ||
} | ||
// forward OnPlayerPushKey(playerid, key); | ||
// Support all keys | ||
int CGameMode::OnPlayerPushKey(cell playerid, cell key) | ||
{ | ||
CHECK_INIT(); | ||
|
||
int idx; | ||
cell ret = 0; | ||
|
||
if (!amx_FindPublic(&m_amx, "OnPlayerPushKey", &idx)) | ||
{ | ||
amx_Push(&m_amx, amx_ftoc( keys ) ); | ||
amx_Push(&m_amx, amx_ftoc( playerid ) ); | ||
amx_Exec(&m_amx, &ret, idx); | ||
} | ||
return (int)ret; | ||
} | ||
// | ||
|
||
// forward OnVehicleCrashVehicle(pveh, iveh); | ||
int CGameMode::OnVehicleCrashVehicle(cell pveh, cell iveh) | ||
{ | ||
CHECK_INIT(); | ||
|
||
int idx; | ||
cell ret = 0; | ||
|
||
if (!amx_FindPublic(&m_amx, "OnVehicleCrashVehicle", &idx)) | ||
{ | ||
amx_Push(&m_amx, pveh); | ||
amx_Push(&m_amx, iveh); | ||
amx_Exec(&m_amx, &ret, idx); | ||
} | ||
return (int)ret; | ||
} | ||
|
||
/* | ||
int CGameMode::OnPlayerCheatDetect(cell playerid, cell cheatID) | ||
*/ | ||
|
||
// -- passenger 'G' bug fix -- | ||
|
||
void CPlayer::StorePassengerFullSyncData(PASSENGER_SYNC_DATA *ppsSync) | ||
{ | ||
m_VehicleID = ppsSync->VehicleID; | ||
|
||
CFilterScripts * pFilterScripts = pNetGame->GetFilterScripts(); | ||
CGameMode * pGameMode = pNetGame->GetGameMode(); | ||
|
||
memcpy(&m_psSync,ppsSync,sizeof(PASSENGER_SYNC_DATA)); | ||
UpdatePosition(m_psSync.vecPos.X,m_psSync.vecPos.Y,m_psSync.vecPos.Z); | ||
|
||
m_fHealth = (float)m_psSync.bytePlayerHealth; | ||
m_fArmour = (float)m_psSync.bytePlayerArmour; | ||
|
||
m_psSync.byteCurrentWeapon = CheckWeapon(m_psSync.byteCurrentWeapon); | ||
|
||
m_byteUpdateFromNetwork = UPDATE_TYPE_PASSENGER; | ||
|
||
/* | ||
HERE... | ||
*/ | ||
/* void CRemotePlayer::StorePassengerFullSyncData(PASSENGER_SYNC_DATA *ppsSync) | ||
{ | ||
if(GetTickCount() < m_dwWaitForEntryExitAnims) return; | ||
memcpy(&m_psSync,ppsSync,sizeof(PASSENGER_SYNC_DATA)); | ||
m_VehicleID = ppsSync->VehicleID; | ||
m_byteSeatID = ppsSync->byteSeatFlags & 127; | ||
m_pCurrentVehicle = pNetGame->GetVehiclePool()->GetAt(m_VehicleID); | ||
m_fReportedHealth = (float)ppsSync->bytePlayerHealth; | ||
m_fReportedArmour = (float)ppsSync->bytePlayerArmour; | ||
m_byteUpdateFromNetwork = UPDATE_TYPE_PASSENGER; | ||
SetState(PLAYER_STATE_PASSENGER); | ||
}*/ | ||
|
||
/// | ||
/* | ||
if( pNetGame->GetGameState() == GAMESTATE_CONNECTED && | ||
!pNetGame->GetRakClient()->IsConnected() ) { | ||
break; | ||
}*/ | ||
/////////////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
|
||
namespace Network | ||
{ | ||
static CRakClient* pRakClient; | ||
static bool bInitialized; | ||
static bool bConnected; | ||
static bool bServerHasPlugin; | ||
static std::string strAddress; | ||
static unsigned short usPort; | ||
|
||
void Initialize(std::string address, unsigned short port) | ||
{ | ||
bInitialized = false; | ||
|
||
strAddress = address; | ||
usPort = port; | ||
|
||
pRakClient = new CRakClient(); | ||
bConnected = false; | ||
bServerHasPlugin = false; | ||
|
||
if (pRakClient->Startup() != RakNet::StartupResult::RAKNET_STARTED) | ||
return; | ||
|
||
bInitialized = true; | ||
} | ||
|
||
bool IsInitialized() | ||
{ | ||
return bInitialized; | ||
} | ||
|
||
void Connect() | ||
{ | ||
if (IsInitialized()) | ||
pRakClient->Connect(strAddress.c_str(), usPort, NULL); | ||
|
||
} | ||
|
||
bool IsConnected() | ||
{ | ||
return bConnected; | ||
} | ||
|
||
bool ServerHasPlugin() | ||
{ | ||
return bServerHasPlugin; | ||
} | ||
|
||
void Process() | ||
{ | ||
if (!IsInitialized()) | ||
return; | ||
|
||
RakNet::Packet* pPacket; | ||
|
||
while ((pPacket = pRakClient->Receive())) | ||
{ | ||
if (!pPacket->length) | ||
return; | ||
|
||
RakNet::BitStream bitStream(&pPacket->data[1], pPacket->length - 1, false); | ||
|
||
CLog::Write("Received packet: %i, local: %i, size: %d byte(s)", pPacket->data[0], pPacket->wasGeneratedLocally, bitStream.GetNumberOfBytesUsed()); | ||
|
||
switch (pPacket->data[0]) | ||
{ | ||
case ePacketType::PACKET_PLAYER_REGISTERED: | ||
{ | ||
bConnected = true; | ||
bServerHasPlugin = true; | ||
CRPCCallback::Initialize(); | ||
|
||
break; | ||
} | ||
case ePacketType::PACKET_RPC: | ||
{ | ||
unsigned short usRpcId; | ||
|
||
if (bitStream.Read<unsigned short>(usRpcId)) | ||
CRPC::Process(usRpcId, bitStream); | ||
|
||
break; | ||
} | ||
case ePacketType::PACKET_CONNECTION_REJECTED: | ||
case ePacketType::PACKET_PLAYER_PROPER_DISCONNECT: | ||
{ | ||
bServerHasPlugin = false; | ||
|
||
break; | ||
} | ||
case ID_DISCONNECTION_NOTIFICATION: | ||
case ID_CONNECTION_LOST: | ||
{ | ||
bConnected = false; | ||
|
||
if (ServerHasPlugin()) | ||
Connect(); | ||
|
||
break; | ||
} | ||
default: | ||
break; | ||
|
||
} | ||
|
||
pRakClient->DeallocatePacket(pPacket); | ||
CLog::bytesReceived += bitStream.GetNumberOfBytesUsed(); | ||
} | ||
|
||
} | ||
|
||
unsigned int Send(Network::ePacketType packetType, RakNet::BitStream* pBitStream, PacketPriority priority, PacketReliability reliability, char cOrderingChannel) | ||
{ | ||
if (!IsConnected()) | ||
return 0; | ||
|
||
CLog::Write("Sent packet: %i, size: %i byte(s)", packetType, pBitStream->GetNumberOfBytesUsed()); | ||
CLog::bytesSent += pBitStream->GetNumberOfBytesUsed(); | ||
|
||
return pRakClient->Send(packetType, *pRakClient->GetRemoteAddress(), pBitStream, priority, reliability, cOrderingChannel); | ||
} | ||
|
||
unsigned int SendRPC(unsigned short usRPCId, RakNet::BitStream* pBitStream, PacketPriority priority, PacketReliability reliability, char cOrderingChannel) | ||
{ | ||
if (!IsConnected()) | ||
return 0; | ||
|
||
CLog::Write("Sent packet: %i, size: %i byte(s)", usRPCId, pBitStream->GetNumberOfBytesUsed()); | ||
CLog::bytesSent += pBitStream->GetNumberOfBytesUsed(); | ||
|
||
return pRakClient->SendRPC(usRPCId, *pRakClient->GetRemoteAddress(), pBitStream, priority, reliability, cOrderingChannel); | ||
} | ||
|
||
CRakClient* GetRakClient() | ||
{ | ||
return pRakClient; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace SAMP.Client.Data.Queries.Implementations | ||
{ | ||
public class ServerListQuery : IServerListQuery | ||
{ | ||
readonly string _versionString = "0.3.8"; | ||
|
||
readonly string _hostedActionUrl; | ||
readonly string _allActionUrl; | ||
|
||
public ServerListQuery() | ||
{ | ||
_hostedActionUrl = String.Format("{0}/official", _versionString); // official samp servers | ||
_allActionUrl = String.Format("{0}/servers", _versionString); // internet tab servers | ||
} | ||
|
||
public List<Models.Server> All() | ||
{ | ||
return AllEnumerable().ToList(); | ||
} | ||
|
||
private IEnumerable<Models.Server> AllEnumerable() | ||
{ | ||
using (var httpClient = new HttpClient { BaseAddress = new Uri("http://lists.sa-mp.com") }) | ||
{ | ||
httpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/3.0 (compatible; SA:MP //)"); | ||
|
||
var allServers = GetAllTask(httpClient); | ||
var hostedServers = GetHostedTask(httpClient).Result.ToList(); | ||
|
||
foreach (var server in allServers.Result) | ||
{ | ||
var hostedServer= hostedServers.FirstOrDefault(x => x.Equals(server)); | ||
server.IsHosted = hostedServer != null; | ||
hostedServers.Remove(hostedServer); | ||
yield return server; | ||
} | ||
} | ||
} |