PDA

View Full Version : [CoD4] Missing function



BlancO
24th September 2013, 15:05
There is a problem with:

std/math.gsc


intsqrt(input)
{
output = 0;
while(output * output < input)
output++;
if(maps\mp\_utility::abs(input - output * output) > maps\mp\_utility::abs(input - (output - 1) * (output - 1)))
output--;
return output;
}


console_log.mp


Error:
******* script compile error *******
Error: unknown function: (file 'std/math.gsc', line 69)
if(maps\mp\_utility::abs(input - output * output) > maps\mp\_utility::abs(input - (output - 1) * (output - 1)))
*
************************************
dvar set cl_paused 0
dvar set com_errorMessage script compile error
unknown function
if(maps\mp\_utility::abs(input - output * output) > maps\mp\_utility::abs(input - (output - 1) * (output - 1)))
(see console for details)

********************
ERROR: script compile error
unknown function
if(maps\mp\_utility::abs(input - output * output) > maps\mp\_utility::abs(input - (output - 1) * (output - 1)))
(see console for details)

********************


If this is proper abs function:



abs (num)
{
if (num < 0)
num*= -1;

return num;
}


I always get ping = 0 and IP = 0.

kung foo man
24th September 2013, 17:04
getIP and getPing is atm only for CoD2 1.2 and 1.3:


int gsc_player_getip()
{
int playerid;
if (stackGetNumberOfParams() < 2) // function, playerid
{
printf_hide("scriptengine> ERROR: please specify atleast 2 arguments to gsc_player_getip()\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_3
int info_base = *(int *)0x0842308C;
int info_size = 0xB1064;
int info_ip_offset = 0x6E6D8;
int info_port_offset = 0x6E6B4;
#elif COD2_VERSION == COD2_VERSION_1_2
int info_base = *(int *)0x0842200C;
int info_size = 0x79064;
int info_ip_offset = 0x6E6D8;
int info_port_offset = 0x6E6B4;
#else
#warning gsc_player_getip() got no working addresses
int info_base = *(int *)0x0;
int info_size = 0x0;
int info_ip_offset = 0x0;
int info_port_offset = 0x0;
return stackReturnUndefined();
#endif

int info_player = info_base + playerid * info_size;

int ip_a = *(unsigned char *)(info_player + info_ip_offset + 0);
int ip_b = *(unsigned char *)(info_player + info_ip_offset + 1); // dafuq, its +1 but in IDA its +4 step :S
int ip_c = *(unsigned char *)(info_player + info_ip_offset + 2);
int ip_d = *(unsigned char *)(info_player + info_ip_offset + 3);
//int port = *(unsigned char *)(info_player + info_ip_offset + 16);

char tmp[64];
snprintf(tmp, 64, "%d.%d.%d.%d", ip_a, ip_b, ip_c, ip_d);
//snprintf(tmp, 64, "%d.%d.%d.%d:%d", ip_a, ip_b, ip_c, ip_d, port);

return stackPushString(tmp);
}


Don't use that "bruteforce" sqrt, there is a real one: http://killtube.org/downloads/cod2/exampleserver/main/std/math.gsc



sqrt(arg) { return closer(800, arg); }
invSqrt(arg) { return closer(801, arg); } // check: http://www.beyond3d.com/content/articles/8/


The used abs-function is only in CoD2 available (unfortunately).