Log in to reply
 

C# get closest prop



  • @meimeiriver Hm maybe this will work:

    if (Function.Call<bool>(Hash.DOES_OBJECT_OF_TYPE_EXIST_AT_COORDS, -558.1558f, 4444.424f, 35.65982f, 1.0f, -1071622219, 0))
    {
    returnedProp = Function.Call<Prop>(Hash.GET_CLOSEST_OBJECT_OF_TYPE, -558.1558f, 4444.424f, 35.65982f, 1.0f, -1071622219, 0, 0, 1); // apa_p_h_acc_artwalll_03
    returnedProp.Delete();
    }
    

  • MODERATOR

    @stillhere said in C# get closest prop:

    @meimeiriver Hm maybe this will work:

    if (Function.Call<bool>(Hash.DOES_OBJECT_OF_TYPE_EXIST_AT_COORDS, -558.1558f, 4444.424f, 35.65982f, 1.0f, -1071622219, 0))
    {
    returnedProp = Function.Call<Prop>(Hash.GET_CLOSEST_OBJECT_OF_TYPE, -558.1558f, 4444.424f, 35.65982f, 1.0f, -1071622219, 0, 0, 1); // apa_p_h_acc_artwalll_03
    returnedProp.Delete();
    }
    

    Thanks for the great idea! Sadly, it didn't work. I definitely have an apa_p_h_acc_artwalll_03 at the specified coordinates, but your native call says it's not there. :(

    Just to make sure, hashes are represented as a signed integer, right?! So, the 'real' apa_p_h_acc_artwalll_03 hash is 3223345077. So, that would become 4G - 3223345077 = -1071622219, right?! (That method worked for the portacabin). I tried 3223345077 itself too, of course, but that didn't do it either.



  • @meimeiriver Yes they are represented as signed int I believe. Shame that example didn't work though, I found that one in the decompiled scripts and converted it to C# :/
    Instead of passing the int, you can run the prop name through the native GET_HASH_KEY (or use SHVDN's Game.GenerateHash() method which calls the same native)

    Function.Call<int>(Hash.GET_HASH_KEY, "apa_p_h_acc_artwalll_03");
    or
    Game.GenerateHash("apa_p_h_acc_artwalll_03");
    

    Both methods should return -1071622219 I think. It probably won't solve this issue though.

    Alternatively, you can also use SHVDN's Model class.
    Model artwall = new Model("apa_p_h_acc_artwalll_03");
    and pass artwall.Hash instead of -1071622219.


  • MODERATOR

    @meimeiriver @stillhere Just FYI, Jenkins hashes are represented as 32-bit unsigned integers.


  • MODERATOR

    @stillhere said in C# get closest prop:

    Game.GenerateHash("apa_p_h_acc_artwalll_03")

    Learned another useful way to get hashes. :) Sadly (as we both expected), it didn't solve the issue.


  • MODERATOR

    @Unknown-Modder said in C# get closest prop:

    @meimeiriver @stillhere Just FYI, Jenkins hashes are represented as 32-bit unsigned integers.

    Didn't know that. But does it make much difference?! For instance, for "apa_p_h_acc_artwalll_03" I tried both of these (with an online jenkins hash generator); it yields the same values I already used:

    Signed: -1071622219
    Unsigned: 3223345077

    Neither of which work.

    It just occured to me, btw, that an object like "apa_p_h_acc_artwalll_03" cannot be selected by Menyoo, once placed inside a ymap (!) It is as if the object simply isn't there. There are (a great many) more objects like that, and it's often very annoying you can't just grab them in-game, and need CodeWalker to move those.

    Not sure whether it's related, but if Menyoo can't select it, then maybe our natives don't work on it either, for the exact same reason?!


  • MODERATOR

    meimeiriver said in C# get closest prop:

    @Unknown-Modder said in C# get closest prop:

    @meimeiriver @stillhere Just FYI, Jenkins hashes are represented as 32-bit unsigned integers.

    Didn't know that. But does it make much difference?! For instance, for "apa_p_h_acc_artwalll_03" I tried both of these (with an online jenkins hash generator); it yields the same values I already used:

    Signed: -1071622219
    Unsigned: 3223345077

    Neither of which work.

    It just occured to me, btw, that an object like "apa_p_h_acc_artwalll_03" cannot be selected by Menyoo, once placed inside a ymap (!) It is as if the object simply isn't there. There are (a great many) more objects like that, and it's often very annoying you can't just grab them in-game, and need CodeWalker to move those.

    Not sure whether it's related, but if Menyoo can't select it, then maybe our natives don't work on it either, for the exact same reason?!

    ^^ Just confirmed my own theory: apa_p_h_acc_artwalll_03 et al. are apparently special case objects: they can't be deleted (when put inside a ymap) because they don't register as existing at their location somehow. When I try this with the good old prop_dummy_car, it deletes just fine!

    So, it may seem the object I wanted to remove in the first place, Prop_Bush_Lrg_03, falls into the same special-case category (can't be selected by Menyoo either; and, consequently, can't be removed via our natives either). Very strange!

    ,


  • MODERATOR

    @meimeiriver Sorry, didn't even read the previous posts. If I understood you correctly then the reason why you cannot delete that object is because the script commands (natives) don't have access to it. More specifically, it doesn't have a rage::fwScriptGuid since it's a static object which means it is impossible via natives.


  • MODERATOR

    @Unknown-Modder said in C# get closest prop:

    @meimeiriver Sorry, didn't even read the previous posts. If I understood you correctly then the reason why you cannot delete that object is because the script commands (natives) don't have access to it. More specifically, it doesn't have a rage::fwScriptGuid since it's a static object which means it is impossible via natives.

    Static, how? Surely not the regular <flags value="32"/> static flag in ymap, right?!

    I compared both entries in their respective ytyp maps:

    <Item type="CBaseArchetypeDef">
      <lodDist value="130.00000000"/>
      <flags value="536936448"/>
      <specialAttribute value="11"/>
      <bbMin x="-3.10796000" y="-2.50235800" z="-1.14018100"/>
      <bbMax x="2.62989800" y="2.22617400" z="2.43192200"/>
      <bsCentre x="-0.23903110" y="-0.13809200" z="0.64587060"/>
      <bsRadius value="4.12437700"/>
      <hdTextureDist value="20.00000000"/>
      <name>Prop_Bush_Lrg_03</name>
      <textureDictionary>lrg_bush_1</textureDictionary>
      <clipDictionary/>
      <drawableDictionary/>
      <physicsDictionary>Prop_Bush_Lrg_03</physicsDictionary>
      <assetType>ASSET_TYPE_DRAWABLE</assetType>
      <assetName>Prop_Bush_Lrg_03</assetName>
      <extensions/>
    </Item>
    
    <Item type="CBaseArchetypeDef">
      <lodDist value="30.00000000"/>
      <flags value="536870912"/>
      <specialAttribute value="0"/>
      <bbMin x="-1.12749800" y="-0.05398700" z="-1.16070900"/>
      <bbMax x="1.12749800" y="0.00042600" z="1.16070900"/>
      <bsCentre x="0.00000000" y="-0.02678050" z="0.00000000"/>
      <bsRadius value="1.61840600"/>
      <hdTextureDist value="5.00000000"/>
      <name>apa_p_h_acc_artwalll_03</name>
      <textureDictionary>apa_p_acc_artwalll3</textureDictionary>
      <clipDictionary/>
      <drawableDictionary/>
      <physicsDictionary>int_mp_h_accessories</physicsDictionary>
      <assetType>ASSET_TYPE_DRAWABLE</assetType>
      <assetName>apa_p_h_acc_artwalll_03</assetName>
      <extensions/>
    </Item>
    

    Prop_Bush_Lrg_03 had the following ymap guid flag, though:

      <guid value="1108027714"/>
    

    So, you're probably on to something. :) Thanks.

    I wound up just removing them the old-fashioned way: stripping them out of their ymaps. Judging by the occurances of cs1_14b_long_4.ymap in the game files, I thought I'd have to copy half my game files to mods; but turns out the bush I wanted gone was really only defined in cs1_14b_long_4.ymap (x64q.rpf) and hei_cs1_14b_long_4.ymap (mpheist), both of which were already in my mods folder. And apparently I had already taken care of their LODS for an adjacent bush, earlier. Too bad, though: having been able to remove it with a native would have been much cleaner. Thanks for your help, though.



  • @meimeiriver @stillhere I've had success getting the hash of a prop using JulioNIBS dev tools.....


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.