Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: isTouching()

  1. #11
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Here is disablePickup()

    Usage example:
    PHP Code:
    self disablePickup(true); 
    Also make sure to set disablePickup(bool) on player connect so it will reset properly.

    Installation
    Open gsc.cpp, CTRL + F and search for "resetNextReliableTime". Then add the following on a new line;
    PHP Code:
    {"disablepickup"         gsc_player_disable_pickup     0}, 
    Open gsc_player.hpp, CTRL + F and search for "void gsc_player_resetNextReliableTime(int id);". Then add the following on a new line;
    PHP Code:
    void gsc_player_disable_pickup(int id); 
    Open gsc_player.cpp, CTRL + F and search for "// entity functions". Then add the following on a new line;
    PHP Code:
    void gsc_player_disable_pickup(int id)
    {
        
    int disable;
        
        if ( ! 
    stackGetParams("i", &disable)) {
            
    printf("scriptengine> ERROR: gsc_player_allow_pickup(): param \"disable\"[1] has to be an integer!\n");
            
    stackPushUndefined();
            return;
        }
        
        
    extern int disable_player_pickup[64];
        
        if(
    disable)
            
    disable_player_pickup[id] = (1);
        else
            
    disable_player_pickup[id] = (0);

    Open libcod.cpp, CTRL + F and search for "int hook_RemoteCommandTime(void)". Then add the following function before "int hook_RemoteCommandTime(void)";
    PHP Code:
    int disable_player_pickup[64] = {0};
    int clientaddress_to_num(int client);

    cHook *hook_disable_pickup;
    int disable_pickup(int a1int a2int a3)
    {
        
    int addrtyperet 0;
        
    int clientnum clientaddress_to_num(a2);
        
    extern int playerinfo_baseplayerinfo_size;
        if(*(
    int*)(*(int*)playerinfo_base clientnum playerinfo_size) == && !disable_player_pickup[clientnum])
        {
            
    hook_disable_pickup->unhook();
            
    signed int (*sig)(int a1int a2int a3);
            *(
    int *)&sig hook_disable_pickup->from;
            
    ret sig(a1a2a3);
            
    hook_disable_pickup->hook();
        }
        return 
    ret;

    Also while in libcod.cpp, add search and add the following new lines depending on your version;

    1.0;
    Search for "cracking_hook_call(0x080707C3, (int)Scr_GetCustomMethod);"

    Add the following on a new line;
    PHP Code:
                hook_disable_pickup = new cHook(0x080DCC7A, (int)disable_pickup);
                
    hook_disable_pickup->hook(); 
    1.2;
    Search for "cracking_hook_call(0x08070D3F, (int)Scr_GetCustomMethod);"

    Add the following on a new line;
    PHP Code:
                hook_disable_pickup = new cHook(0x080DF25A, (int)disable_pickup);
                
    hook_disable_pickup->hook(); 
    1.3;
    Search for "cracking_hook_call(0x08070E0B, (int)Scr_GetCustomMethod);"

    Add the following on a new line;
    PHP Code:
                hook_disable_pickup = new cHook(0x080DF39E, (int)disable_pickup);
                
    hook_disable_pickup->hook(); 
    Compile your version and you are done.

  2. The Following User Says Thank You to filthy_freak_ For This Useful Post:

    Mitch (19th June 2015)

  3. #12
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    The above function only disables weapon pickup and doesn't disable turrets, bomb planting etc.

  4. #13
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    As requested, I have added disablePickup(bool) to libcod for download.
    Attached Files Attached Files

  5. The Following 3 Users Say Thank You to filthy_freak_ For This Useful Post:

    kung foo man (18th June 2015),Mitch (19th June 2015),Ni3ls (18th June 2015)

  6. #14
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    I just noticed an unused variable in int disablePickup(int a1, int a2, int a3).

    Replace
    PHP Code:
    int addrtyperet 0
    With
    PHP Code:
    int ret 0

  7. The Following User Says Thank You to filthy_freak_ For This Useful Post:

    Mitch (24th June 2015)

  8. #15
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by filthy_freak_ View Post
    The above function only disables weapon pickup and doesn't disable turrets, bomb planting etc.
    The code doesn't work correctly, because a2 isn't a client address but a gentity address.
    You need to replace 'clientaddress_to_num' with 'gentityaddress_to_num' to get a valid client number.

    Edit: the function uses a different a2 variable. So i was wrong. See: http://killtube.org/showthread.php?2...ll=1#post12093
    Last edited by Mitch; 30th June 2015 at 15:31.

  9. The Following User Says Thank You to Mitch For This Useful Post:

    filthy_freak_ (30th June 2015)

  10. #16
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by Mitch View Post
    The code doesn't work correctly, because a2 isn't a client address but a gentity address.
    You need to replace 'clientaddress_to_num' with 'gentityaddress_to_num' to get a valid client number.
    Are you sure? This is what my log returns;
    Code:
    clientaddress_to_num = 0, gentityaddress_to_num = 1024
    PHP Code:
        int clientnum clientaddress_to_num(a2);
        
    int clientnum2 gentityaddress_to_num(a2);
        
    printf("clientaddress_to_num = %i, gentityaddress_to_num = %i\n"clientnumclientnum2); 

  11. #17
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by filthy_freak_ View Post
    Are you sure? This is what my log returns;
    Code:
    clientaddress_to_num = 0, gentityaddress_to_num = 1024
    PHP Code:
        int clientnum clientaddress_to_num(a2);
        
    int clientnum2 gentityaddress_to_num(a2);
        
    printf("clientaddress_to_num = %i, gentityaddress_to_num = %i\n"clientnumclientnum2); 
    Maybe it is a difference between 1.0 and 1.3 (= where i tested it).

    Edit: In 1.3 i get this:
    Code:
    clientaddress_to_num = -55, gentityaddress_to_num = 0
    Last edited by Mitch; 30th June 2015 at 15:12.

  12. The Following User Says Thank You to Mitch For This Useful Post:

    filthy_freak_ (30th June 2015)

  13. #18
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Remove post
    Last edited by filthy_freak_; 30th June 2015 at 15:27. Reason: Nevermind

  14. #19
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by filthy_freak_ View Post
    EDIT:

    Found the problem.

    Didn't post the correct addresses for 1.2 and 1.3

    Here are the correct addresses:
    1.2
    PHP Code:
                hook_delete_weapon = new cHook(0x08105E9E, (int)delete_weapon);
                
    hook_delete_weapon->hook(); 
    1.3
    PHP Code:
                hook_delete_weapon = new cHook(0x08105FFA, (int)delete_weapon);
                
    hook_delete_weapon->hook(); 
    I will update the above post with the fix. Triple edit: Seems like I can't =(
    I'm using a function one level higher.

    My function (gentity):
    PHP Code:
    sub_8105CAC(signed int sint a2int a3
    Your function (client):
    PHP Code:
    result sub_80DF39E(s, *(_DWORD *)(a2 344), a3); 
    Edit: i committed my version. https://github.com/M-itch/libcod/com...6f7f20d91a895f
    Last edited by Mitch; 30th June 2015 at 15:37.

  15. #20
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by Mitch View Post
    Maybe it is a difference between 1.0 and 1.3 (= where i tested it).

    Edit: In 1.3 i get this:
    Code:
    clientaddress_to_num = -55, gentityaddress_to_num = 0
    Are you sure you have set
    PHP Code:
                hook_disable_pickup = new cHook(0x080DF39E, (int)disable_pickup);
                
    hook_disable_pickup->hook(); 
    correctly?

    EDIT: Going by your previous post, seems like you didn't.

    By the way, the use of sub_80DF39E over sub_8105CAC is intentional. Using sub_80DF39E will only disable weapon pickup whereas sub_8105CAC will disable everything with a Use (f) dialogue. Hence why the custom function is called disablePickup and not disableUse.
    Last edited by filthy_freak_; 30th June 2015 at 15:41.

Posting Permissions

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