Another GTA Fan Posted March 19, 2018 Share Posted March 19, 2018 I've created a script that creates an object that can be thrown; Works pretty much like the grenades in the game, though the thing I can't seem to do is make them explode on impact like the Molotov Cocktail. To put it simple: How do I make it so they explode on impact like the Molotovs? At least what coding am I missing to make this so? Link to comment Share on other sites More sharing options...
GuruGuru Posted March 19, 2018 Share Posted March 19, 2018 IF HAS_OBJECT_COLLIDED_WITH_ANYTHING (obj) GET_OBJECT_COORDINATES (obj) (x,y,z) ADD_EXPLOSION (x, y, z, 0) DELETE_OBJECT (obj)ENDIF I guess this could work,haven't tested though. Link to comment Share on other sites More sharing options...
Sanmodder Posted March 19, 2018 Share Posted March 19, 2018 if 04DA: has_object [email protected] collided then Object.StorePos([email protected], [email protected] [email protected] [email protected] 020C: create_explosion_with_radius 0 at [email protected] [email protected] [email protected] object.Destroy([email protected]) end Link to comment Share on other sites More sharing options...
Another GTA Fan Posted March 20, 2018 Author Share Posted March 20, 2018 IF HAS_OBJECT_COLLIDED_WITH_ANYTHING (obj) GET_OBJECT_COORDINATES (obj) (x,y,z) ADD_EXPLOSION (x, y, z, 0) DELETE_OBJECT (obj)ENDIF I guess this could work,haven't tested though. I honestly couldn't find them in the op code search feature in SannyBuilder, unless I'm using them wrong. if 04DA: has_object [email protected] collided then Object.StorePos([email protected], [email protected] [email protected] [email protected] 020C: create_explosion_with_radius 0 at [email protected] [email protected] [email protected] object.Destroy([email protected]) end That's how I originally coded the script, but 04DA doesn't seem to work for me. I've tried that code loads of times and it just doesn't want to work for me. As of now, I'm using 05A3 to check if the object has stopped, and that works, but 04DA doesn't. Is there any reason why? Because checking to see if the object has stopped takes too long which is why I'd love to get 04DA to work instead so it's an impact thing. Link to comment Share on other sites More sharing options...
Sanmodder Posted March 20, 2018 Share Posted March 20, 2018 (edited) it has to be in a loop see this script :startwaai 0if 00E1: player 0 pressed_key 7 // Ejf @SPH_15A7 04ED: load_animation "GRENADE" Model.Load(1598)jump @SPH_14AB :SPH_14AB04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 0.0 2.0 0.5 0812: AS_actor $PLAYER_ACTOR perform_animation "WEAPON_THROW" IFP "GRENADE" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 0 time -1 // versionB wait 70 [email protected] = Object.Init(1598, [email protected], [email protected], [email protected])Object.ToggleInMovingList([email protected]) = True08D2: object [email protected] scale_model 0.1 04D9: object [email protected] set_scripted_collision_check 1 Object.CollisionDetection([email protected]) = TrueObject.Indestructibility([email protected]) = True0906: set_object [email protected] mass_to 10000.0 // float [email protected] = Actor.Angle($PLAYER_ACTOR)0819: [email protected] = actor $PLAYER_ACTOR distance_from_ground [email protected] = 140.1 02F6: [email protected] = sine [email protected] // (float) 02F7: [email protected] = cosine [email protected] // (float) 006B: [email protected] *= [email protected] // (float) 006B: [email protected] *= [email protected] // (float) [email protected] *= -1.0 [email protected] += 3.0 Object.Throw([email protected], [email protected], [email protected], [email protected])Object.RemoveReferences([email protected])[email protected] = 1 jump @SPH_15A7 :SPH_15A7if [email protected] == 1 jf @SPH_16DE if 03CA: object [email protected] exists jf @SPH_16DE 0400: store_coords_to [email protected] [email protected] [email protected] from_object [email protected] with_offset 0.0 0.0 0.0 04D5: create_corona_at [email protected] [email protected] [email protected] radius 6.5 type 1 flare 1 RGB 200 0 0 095C: create_smoke_at [email protected] [email protected] [email protected] velocity 0.0 0.0 0.0 RGBA 0.0 0.0 1.0 1.0 size 0.1 last_factor 0.1 09E5: create_flash_light_at [email protected] [email protected] [email protected] RGB_mask 200 0 0 radius 200.0 jump @SPH_1657 :SPH_1657if 03CA: object [email protected] exists jf @SPH_16DE if or04E7: object [email protected] in_water 04DA: has_object [email protected] collided jf @SPH_16DE 0400: store_coords_to [email protected] [email protected] [email protected] from_object [email protected] with_offset 0.0 0.0 0.0 0948: create_explosion_at [email protected] [email protected] [email protected] type 10 camera_shake 0.2 if 03CA: object [email protected] exists jf @SPH_16D0 Object.Destroy([email protected])Model.Destroy(1598):[email protected] = 0wait 0:SPH_16DEjump @start Edited March 20, 2018 by Sanmodder Link to comment Share on other sites More sharing options...
ZAZ Posted March 20, 2018 Share Posted March 20, 2018 That's how I originally coded the script, but 04DA doesn't seem to work for me. I've tried that code loads of times and it just doesn't want to work for me.not all objects detect collision to everything, peds, cars, mapobjectsuse one of these objects: 1598, beachball 3065, BBALL_col 2891, kmb_packet 3054, DYN_WREKING_BALL 1305, dyn_quarryrock01 1582, pizzabox, prop_pizzabox CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
Another GTA Fan Posted March 20, 2018 Author Share Posted March 20, 2018 It works! Thank you @Sanmodder and @ZAZ I changed it to the beachball and looped it as you both said, and it's working perfectly Sanmodder 1 Link to comment Share on other sites More sharing options...