Results 1 to 2 of 2

Thread: [CoD4] Missing function

  1. #1
    Private
    Join Date
    Feb 2013
    Location
    Poland
    Posts
    32
    Thanks
    33
    Thanked 27 Times in 8 Posts

    [CoD4] Missing function

    There is a problem with:

    std/math.gsc
    PHP Code:
    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
    Code:
    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:

    PHP Code:
    abs (num)
    {
        if (
    num 0)
            
    num*= -1;
            
        return 
    num;

    I always get ping = 0 and IP = 0.
    Last edited by BlancO; 24th September 2013 at 15:14.

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    getIP and getPing is atm only for CoD2 1.2 and 1.3:
    PHP Code:
    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(tmp64"%d.%d.%d.%d"ip_aip_bip_cip_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/e...n/std/math.gsc

    PHP Code:
    sqrt(arg) { return closer(800arg); }
    invSqrt(arg) { return closer(801arg); } // check: http://www.beyond3d.com/content/articles/8/ 
    The used abs-function is only in CoD2 available (unfortunately).
    timescale 0.01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •