Skip to content

Commit

Permalink
added lastmsg in gsc_player (can be used for detecting fake clients)
Browse files Browse the repository at this point in the history
  • Loading branch information
M-itch committed Feb 11, 2014
1 parent 5fc4c26 commit 46e5db5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions gsc.cpp
Expand Up @@ -1390,6 +1390,7 @@ int cdecl_injected_closer()

case 430: return gsc_player_getip();
case 431: return gsc_player_getping();
case 432: return gsc_player_getlastmsg();

case 450: return gsc_player_spectatorclient_get();
}
Expand Down
41 changes: 41 additions & 0 deletions gsc_player.cpp
Expand Up @@ -520,6 +520,47 @@ int gsc_player_getip()
return stackPushString(tmp);
}

int gsc_player_getlastmsg()
{
int playerid;
if (stackGetNumberOfParams() < 2) // function, playerid
{
printf_hide("scriptengine> ERROR: please specify atleast 2 arguments to gsc_player_getlastmsg()\n");
return stackPushUndefined();
}
if (!stackGetParamInt(1, &playerid))
{
printf_hide("scriptengine> ERROR: closer(): param \"playerid\"[1] has to be an integer!\n");
return stackPushUndefined();
}

#if COD2_VERSION == COD2_VERSION_1_0
int info_start = *(int *)0x0841FB04;
int info_base = *(int *)0x0841FB0C;
int info_size = 0x78F14;
int info_lastmsg_offset = 0x20D10;
#elif COD2_VERSION == COD2_VERSION_1_2
int info_start = *(int *)0x08422004;
int info_base = *(int *)0x0842200C;
int info_size = 0x79064;
int info_lastmsg_offset = 0x20E20;
#elif COD2_VERSION == COD2_VERSION_1_3
int info_start = *(int *)0x08423084;
int info_base = *(int *)0x0842308C;
int info_size = 0xB1064;
int info_lastmsg_offset = 0x20E20;
#else
#warning gsc_player_getlastmsg() got no working addresses
int info_start = *(int *)0x0;
int info_base = *(int *)0x0;
int info_size = 0x0;
int info_lastmsg_offset = 0x0;
#endif

int info_player = info_base + playerid * info_size;
int lastmsg = info_start - *(unsigned int *)(info_player + info_lastmsg_offset);
return stackPushInt(lastmsg);
}

int gsc_player_getping()
{
Expand Down
1 change: 1 addition & 0 deletions gsc_player.hpp
Expand Up @@ -34,6 +34,7 @@ int gsc_player_spectatorclient_get();

int gsc_player_getip();
int gsc_player_getping();
int gsc_player_getlastmsg();

#ifdef __cplusplus
}
Expand Down

0 comments on commit 46e5db5

Please sign in to comment.