Jump to content

Get thrown grenades


Recommended Posts

I think You can find it from objects near player.

 

{$CLEO .cs}0000:while true    wait 0    if        not player.Defined(0)    then        continue    end    actor.StorePos($player_actor, 0@, 1@, 2@)    if        0AE3: 3@ = random_object_near_point 0@ 1@ 2@ in_radius 2.0 find_next false   then        repeat            if               object.Model(3@) == #GRENADE               then               // Ok, here it is           end       until 8AE3: 3@ = random_object_near_point 0@ 1@ 2@ in_radius 2.0 find_next true   end end

 

Edited by DK22Pac
Link to comment
https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060279893
Share on other sites

I tend to think it would get stuck in an infinite loop here;

 

 

repeat          if              object.Model(3@) == #GRENADE              then              // Ok, here it is          end      until 8AE3: 3@ = random_object_near_point 0@ 1@ 2@ in_radius 2.0 find_next true

 

 

From a program point of view, the code would find any random object such as a cardboard box a then wait in this loop until it turns into a grenade. Since there is no wait in the repeat...until loop it would freeze your game.

Link to comment
https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060282556
Share on other sites

 

{$CLEO}0000: Hell Yeahwhile true   wait 0   if player.Defined($PLAYER_CHAR)   then       04C4: store_coords_to 1@ 2@ 3@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0        0866: get_object_in_sphere 1@ 2@ 3@ radius 10.0 handle_as 4@       if object.Exists(4@)       then           0984: 5@ = object 4@ model           045A: text_draw_1number  250.0  40.0 'NUMBER' 5@           if  5@ == #GRENADE            then               05BE: AS_kill_actor $PLAYER_ACTOR            end          end   end  end  // main loop

 

 

That's a correct check BUT the radius is too small thrown grenade model may is different than #GRENADE and it is a special object because it can explode. The delay would be big.

Link to comment
https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060282848
Share on other sites

 

From a program point of view, the code would find any random object such as a cardboard box a then wait in this loop until it turns into a grenade.  Since there is no wait in the repeat...until loop it would freeze your game.

Your "program point of view" is wrong.

Yep, the radius might be a lil bigger, like 3.0. That's all.

 

{$CLEO .cs}0000:while true   wait 0   if       not player.Defined(0)   then       continue   end   actor.StorePos($player_actor, 0@, 1@, 2@)   if       0AE3: 3@ = random_object_near_point 0@ 1@ 2@ in_radius 3.0 find_next false  then       repeat           if              object.Model(3@) == #GRENADE              then              object.StorePos(3@, 5@, 6@, 7@)              object.Create(4@, #KNIFECUR, 5@, 6@, 7@)              object.RemoveReferences(4@)          end      until 8AE3: 3@ = random_object_near_point 0@ 1@ 2@ in_radius 3.0 find_next true  end end

 

Edited by DK22Pac
Link to comment
https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060282870
Share on other sites

 

From a program point of view, the code would find any random object such as a cardboard box a then wait in this loop until it turns into a grenade.  Since there is no wait in the repeat...until loop it would freeze your game.

Your "program point of view" is wrong.

Yep, the radius might be a lil bigger, like 3.0. That's all.

What the ... man 3.0 is too little.

BTW a wait is missing wink.gif

Edited by BnB
Link to comment
https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060282876
Share on other sites

Bet he missed a zero: 30.0

 

But I think its easier to find a pointer to the projectiles...

Pointers? How is that working? I would also need it for bullets. I already asked that in another topic but noone has answered yet...

Link to comment
https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060283139
Share on other sites

3.0 is a far better value than 30.0. What you are doing is scanning for every object every frame... It depends on the speed of the computer whether the value needs adjusting higher. I'd say 6.0 for some breathing space, but it just depends on what you're actually trying to do.

 

@Bennington

Have you actually tried the above code yet?

Link to comment
https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060283185
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.