Skip to content

Commit

Permalink
- Fixed linux raknet structures
Browse files Browse the repository at this point in the history
- Fixed linux raknet structures
- Added ShowPlayerForPlayer, HidePlayerForPlayer
- Added forplayer parameter to SendBulletData
  • Loading branch information
kurta999 committed Jul 7, 2014
1 parent 8a04be6 commit da03471
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 96 deletions.
23 changes: 21 additions & 2 deletions Addresses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DWORD CAddress::FUNC_Logprintf_03ZR3 = 0x00487460;
#else
DWORD CAddress::FUNC_Logprintf_03Z = 0x080A7440;
DWORD CAddress::FUNC_Logprintf_03ZR2_2 = 0x080A77D0;
DWORD CAddress::FUNC_Logprintf_03ZR3 = 0x080A77D0;
DWORD CAddress::FUNC_Logprintf_03ZR3 = 0x080A78E0;
#endif

// Pointers
Expand Down Expand Up @@ -84,6 +84,7 @@ void CAddress::Initialize(eSAMPVersion sampVersion)

FUNC_CConsole_AddStringVariable = 0x0809F590;
FUNC_CConsole_SetStringVariable = 0x0809EDB0;
FUNC_CConsole_SetIntVariable = 0x0809ED10;
FUNC_CConsole_ModifyVariableFlags = 0x0809EE60;

FUNC_CFilterscripts_LoadFilterscript = 0x0809FDB0;
Expand All @@ -100,6 +101,7 @@ void CAddress::Initialize(eSAMPVersion sampVersion)

FUNC_CConsole_AddStringVariable = 0x809F760;
FUNC_CConsole_SetStringVariable = 0x809F000;
FUNC_CConsole_SetIntVariable = 0x809EEE0;
FUNC_CConsole_ModifyVariableFlags = 0x809F030;

FUNC_CFilterscripts_LoadFilterscript = 0x0809FF80;
Expand All @@ -109,7 +111,24 @@ void CAddress::Initialize(eSAMPVersion sampVersion)
FUNC_ContainsInvalidChars = 0x080D2F50;
ADDR_RECEIVE_HOOKPOS = 0x80645D6;
break;
}
}
case SAMP_VERSION_03Z_R3:
{
VAR_pRestartWaitTime = 0x8150B60;

FUNC_CConsole_AddStringVariable = 0x809F760;
FUNC_CConsole_SetStringVariable = 0x809F000;
FUNC_CConsole_SetIntVariable = 0x809EEE0;
FUNC_CConsole_ModifyVariableFlags = 0x809F030;

FUNC_CFilterscripts_LoadFilterscript = 0x0809FF80; // done
FUNC_CFilterscripts_UnLoadFilterscript = 0x080A03B0; // done

ADDR_CNetGame_GMX_GangZoneDelete = NULL;
FUNC_ContainsInvalidChars = 0x080D2F50;
ADDR_RECEIVE_HOOKPOS = 0x80645D6;
break;
}
}
#endif

Expand Down
1 change: 1 addition & 0 deletions CServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ BYTE CServer::GetWeather(void)
return m_byteWeather;
}

// forward OnPlayerPauseStateChange(playerid, pausestate);
void CServer::OnPlayerPauseStateChange(int playerid, bool afkstate)
{
//logprintf("OnPlayerPauseStateChange %d - %d", playerid, afkstate);
Expand Down
4 changes: 2 additions & 2 deletions RPCs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ int RPC_FlashGangZone = 0x79;
int RPC_StopFlashGangZone = 0x55;
int RPC_UpdateScoresPingsIPs = 0x9B;
int RPC_RemovePlayerAttachedObject = 0x71;

void UpdateScoresPingsIPs(RPCParameters *rpcParams);
int RPC_WorldPlayerAdd = 32;
int RPC_WorldPlayerRemove = 163;

void UpdateScoresPingsIPs(RPCParameters *rpcParams)
{
Expand Down
2 changes: 2 additions & 0 deletions RPCs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ extern int RPC_FlashGangZone;
extern int RPC_StopFlashGangZone;
extern int RPC_UpdateScoresPingsIPs;
extern int RPC_RemovePlayerAttachedObject;
extern int RPC_WorldPlayerAdd;
extern int RPC_WorldPlayerRemove;

void InitRPCs();

Expand Down
78 changes: 66 additions & 12 deletions Scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,6 @@ static cell AMX_NATIVE_CALL n_GetFilterScriptName(AMX *amx, cell *params)
return set_amxstring(amx, params[2], pNetGame->pFilterScriptPool->m_szFilterScriptName[id], params[3]);
}

#define CON_VARFLAG_DEBUG 1
#define CON_VARFLAG_READONLY 2
#define CON_VARFLAG_RULE 4

// native AddServerRule(name[], value[], flags = CON_VARFLAG_RULE);
static cell AMX_NATIVE_CALL n_AddServerRule(AMX *amx, cell *params)
{
Expand Down Expand Up @@ -665,6 +661,7 @@ static cell AMX_NATIVE_CALL n_ModifyFlag(AMX *amx, cell *params)
return 0;
}

// native IsValidNickName(name[]);
static cell AMX_NATIVE_CALL n_IsValidNickName(AMX *amx, cell *params)
{
// If unknown server version
Expand Down Expand Up @@ -693,7 +690,7 @@ static cell AMX_NATIVE_CALL n_AllowNickNameCharacter(AMX *amx, cell *params)

char character = (char)params[1];

// Enable %s is disabled for security
// Enable %s is disallowed
if(character == '%') return 0;

if(params[2])
Expand Down Expand Up @@ -1427,18 +1424,24 @@ static cell AMX_NATIVE_CALL n_GetPlayerSpectateType( AMX* amx, cell* params )
return pNetGame->pPlayerPool->pPlayer[playerid]->byteSpectateType;
}

// native SendBulletData(sender, hitid, hittype, Float:fHitOriginX, Float:fHitOriginY, Float:fHitOriginZ, Float:fHitTargetX, Float:fHitTargetY, Float:fHitTargetZ, Float:fCenterOfHitX, Float:fCenterOfHitY, Float:fCenterOfHitZ);
// native SendBulletData(sender, hitid, hittype, Float:fHitOriginX, Float:fHitOriginY, Float:fHitOriginZ, Float:fHitTargetX, Float:fHitTargetY, Float:fHitTargetZ, Float:fCenterOfHitX, Float:fCenterOfHitY, Float:fCenterOfHitZ, forplayerid = -1);
static cell AMX_NATIVE_CALL n_SendBulletData( AMX* amx, cell* params )
{
// If unknown server version
if(!pServer)
return 0;

CHECK_PARAMS(12, "SendBulletData");
CHECK_PARAMS(13, "SendBulletData");

int playerid = (int)params[1];
int forplayerid = (int)params[12];
if(!IsPlayerConnected(playerid)) return 0;

if(forplayerid != -1)
{
if(!IsPlayerConnected(forplayerid)) return 0;
}

BULLET_SYNC_DATA bulletSync;
bulletSync.byteHitType = (BYTE)params[3];
bulletSync.wHitID = (WORD)params[2];
Expand All @@ -1450,12 +1453,61 @@ static cell AMX_NATIVE_CALL n_SendBulletData( AMX* amx, cell* params )
bs.Write((BYTE)ID_BULLET_SYNC);
bs.Write((WORD)playerid);
bs.Write((char*)&bulletSync, sizeof(BULLET_SYNC_DATA));
pRakServer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, UNASSIGNED_PLAYER_ID, true);

if(forplayerid == -1)
{
pRakServer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, UNASSIGNED_PLAYER_ID, true);
}
else
{
pRakServer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, pRakServer->GetPlayerIDFromIndex(forplayerid), false);
}
return 1;
}

// Scoreboard manipulation
// native ShowPlayerForPlayer(forplayerid, playerid);
static cell AMX_NATIVE_CALL n_ShowPlayerForPlayer( AMX* amx, cell* params )
{
// If unknown server version
if(!pServer)
return 0;

CHECK_PARAMS(2, "ShowPlayerForPlayer");

int forplayerid = (int)params[1];
if(!IsPlayerConnected(forplayerid)) return 0;

int playerid = (int)params[2];
if(!IsPlayerConnected(playerid)) return 0;

RakNet::BitStream bs;
bs.Write((WORD)playerid);
pRakServer->RPC(&RPC_WorldPlayerAdd, &bs, HIGH_PRIORITY, RELIABLE_ORDERED, 2, pRakServer->GetPlayerIDFromIndex(forplayerid), 0, 0);
return 1;
}

// native HidePlayerForPlayer(forplayerid, playerid);
static cell AMX_NATIVE_CALL n_HidePlayerForPlayer( AMX* amx, cell* params )
{
// If unknown server version
if(!pServer)
return 0;

CHECK_PARAMS(2, "HidePlayerForPlayer");

int forplayerid = (int)params[1];
if(!IsPlayerConnected(forplayerid)) return 0;

int playerid = (int)params[2];
if(!IsPlayerConnected(playerid)) return 0;

RakNet::BitStream bs;
bs.Write((WORD)playerid);
pRakServer->RPC(&RPC_WorldPlayerRemove, &bs, HIGH_PRIORITY, RELIABLE_ORDERED, 2, pRakServer->GetPlayerIDFromIndex(forplayerid), 0, 0);
return 1;
}

// Scoreboard manipulation
// native TogglePlayerScoresPingsUpdate(playerid, bool:toggle);
static cell AMX_NATIVE_CALL n_TogglePlayerScoresPingsUpdate(AMX *amx, cell *params)
{
Expand Down Expand Up @@ -4661,8 +4713,8 @@ AMX_NATIVE_INFO YSINatives [] =
// Generic
{"SetModeRestartTime", n_SetModeRestartTime},
{"GetModeRestartTime", n_GetModeRestartTime},
{"SetMaxPlayers", n_SetMaxPlayers},
{"SetMaxNPCs", n_SetMaxNPCs},
{"SetMaxPlayers", n_SetMaxPlayers}, // R8
{"SetMaxNPCs", n_SetMaxNPCs}, // R8

{"SetPlayerAdmin", n_SetPlayerAdmin},
{"LoadFilterScript", n_LoadFilterScript},
Expand Down Expand Up @@ -4712,6 +4764,8 @@ AMX_NATIVE_INFO YSINatives [] =
{ "GetPlayerWorldBounds", n_GetPlayerWorldBounds }, // R5
{ "IsPlayerInModShop", n_IsPlayerInModShop }, // R4
{ "SendBulletData", n_SendBulletData }, // R6
{ "ShowPlayerForPlayer", n_ShowPlayerForPlayer }, // R8
{ "HidePlayerForPlayer", n_HidePlayerForPlayer }, // R8

// Special things from syncdata
{ "GetPlayerSirenState", n_GetPlayerSirenState },
Expand Down
Loading

0 comments on commit da03471

Please sign in to comment.