weapon_detach_addon with scopes?

Posts: 33
Joined: 12 Jun 2017, 23:44

weapon_detach_addon with scopes?

Postby sLoPpYdOtBiGhOlE » 22 Dec 2017, 07:50

I'm updating my Unload All Weapons addon for CoC 1.5 R6..
Adding 3 more options to detach Scopes, Silencers, Grenade Launchers.

I added the option to detaches silencers and they detach fine with weapon_detach_addon function.

Then I tried the same method for Scopes, attaining the wepon attached scope name successfully.
Then passing the scope name to the weapon_detach_addon function, but nothing happens.
No error or crashes am I missing something?
Here's a snippet of the scope code I'm testing the following in an iterate_inventory function:

Code: Select all

   if (itm:weapon_scope_status() == 2 and itm:weapon_is_scope()) then
      local ini, v = system_ini(), nil
      v = ini:r_string(itm:section(),"scopes_sect")
      if (v and v ~= "") then
         printf("scopes_sect: %s", v)
         v = alun_utils.str_explode(v,",")
         if (v) then
            printf("scope index: %s", itm:weapon_get_scope())
            v = v[itm:weapon_get_scope() + 1]
            if (v and v ~= "") then
               printf("scopes_sect index name: %s", v)
               v = ini:r_string(v,"scope_name")
               if (v and v ~= "") then
                  printf("scope_name: %s ", v)

printf spits the correct info to the console so it definitely reaches itm:weapon_addon_detach(v)

Edit: weapon_addon_detach works fine with the grenade launchers as well..
hmm, if I could only work out what I'm doing wrong with scopes...

Edit again:
I tried moving the weapon_addon_detach funtion outside of the iteration function..
Thought maybe calling it in the iteration function may cause grief..
Silencers and Launchers detach without issue, still no success with scopes...

Surely there has to be a working example of detaching scope in a script somewhere?

I looked through the dxr_sights.script and even tried those methods without success either.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests