Bennington Posted January 3, 2011 Share Posted January 3, 2011 Hey there my friend is just working on a script where he needs to get a grenade (thrown by the player) saved in a variable. I looked for some opcodes to get it, but there aren´t any fitting ones. Can anyone help us? Link to comment https://gtaforums.com/topic/466696-get-thrown-grenades/ Share on other sites More sharing options...
DK22Pac Posted January 4, 2011 Share Posted January 4, 2011 (edited) 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 January 4, 2011 by DK22Pac Link to comment https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060279893 Share on other sites More sharing options...
gta_sa_player123 Posted January 5, 2011 Share Posted January 5, 2011 I dont think that works but you should increase the radius if you want to get throwngrenades. Link to comment https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060280519 Share on other sites More sharing options...
toonskull Posted January 6, 2011 Share Posted January 6, 2011 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 More sharing options...
BnB Posted January 6, 2011 Share Posted January 6, 2011 {$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 More sharing options...
DK22Pac Posted January 6, 2011 Share Posted January 6, 2011 (edited) 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 January 6, 2011 by DK22Pac Link to comment https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060282870 Share on other sites More sharing options...
BnB Posted January 6, 2011 Share Posted January 6, 2011 (edited) 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 Edited January 6, 2011 by BnB Link to comment https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060282876 Share on other sites More sharing options...
TheSiggi Posted January 6, 2011 Share Posted January 6, 2011 Bet he missed a zero: 30.0 But I think its easier to find a pointer to the projectiles... Link to comment https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060282879 Share on other sites More sharing options...
BnB Posted January 6, 2011 Share Posted January 6, 2011 Bet he missed a zero: 30.0 But I think its easier to find a pointer to the projectiles... Lol you are right. Using that script the grenade would have already exploded because of the delay. Link to comment https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060282888 Share on other sites More sharing options...
Bennington Posted January 6, 2011 Author Share Posted January 6, 2011 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 More sharing options...
Deji Posted January 6, 2011 Share Posted January 6, 2011 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 More sharing options...
Bennington Posted January 9, 2011 Author Share Posted January 9, 2011 No I didn´t, and I dunno if my friend has already (he´s looking on that topic sometimes). He´s actually the one who wanna know. Link to comment https://gtaforums.com/topic/466696-get-thrown-grenades/#findComment-1060288160 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now