Nov 11 2010, 03:51 AM Post #1 | |
Ameteur Member Posts: 42 From: Guatemala Joined: 22-December 09 | I'm trying to get a random ped, and then, when aiming to him/her, automatically change the $player model to him/her. I do these codes, but when I'm aiming an actor the games crash, (with both codes ) can you help me with this? CODE 1 CODE {$CLEO .cs} 0000: NOP :Noname_2 wait 0 if Player.Defined($PLAYER_CHAR) jf @Noname_2 if 0AB0: key_pressed 105 jf @Noname_2 :Noname_37 0A8D: 4@ = read_memory 0xB74490 size 4 virtual_protect 0 4@ += 4 0A8D: 4@ = read_memory 4@ size 4 virtual_protect 0 5@ = 0 :Noname_77 wait 0 0A8D: 20@ = read_memory 4@ size 1 virtual_protect 0 4@ += 1 if and 20@ >= 0 128 > 20@ jf @Noname_273 005A: 20@ += 5@ // (int) if and not Actor.Dead(20@) 803C: not $PLAYER_ACTOR == 20@ // (int) jf @Noname_273 31@ = 0 :Noname_165 wait 0 if 0457: player $PLAYER_CHAR aiming_at_actor 20@ jf @Noname_245 0665: get_actor 20@ model_to 6@ Model.Load(6@) 038B: load_requested_models :Noname_166 wait 0 if Model.Available(6@) jf @:Noname_166 09C7: change_player $PLAYER_CHAR model_to 6@ Player.Build($PLAYER_CHAR) wait 100 0687: clear_actor $PLAYER_ACTOR task Model.Destroy(6@) jump @Noname_305 :Noname_245 31@ += 1 31@ > 3 jf @Noname_165 31@ = 0 :Noname_273 5@ += 256 5@ > 35584 jf @Noname_77 jump @Noname_37 :Noname_305 wait 0 if Player.Defined($PLAYER_CHAR) jf @Noname_305 if 00E1: player 0 pressed_key 17 jf @Noname_305 09C7: change_player $PLAYER_CHAR model_to #NULL Player.Build($PLAYER_CHAR) 0792: disembark_instantly_actor $PLAYER_ACTOR wait 500 jump @Noname_2 CODE 2 CODE {$CLEO .cs} 0000: NOP :Noname_2 wait 0 if Player.Defined($PLAYER_CHAR) jf @Noname_2 if 0AB0: key_pressed 105 jf @Noname_2 :Noname_33 wait 0 Actor.StorePos($PLAYER_ACTOR, 2@, 3@, 4@) 5@ = -1 08E5: get_actor_in_sphere 2@ 3@ 4@ radius 10.0 handle_as 5@ if Actor.Defined(5@) jf @Noname_212 if Actor.Driving(5@) jf @Noname_116 jump @Noname_200 :Noname_116 wait 0 if 0457: player $PLAYER_CHAR aiming_at_actor 5@ jf @Noname_200 0665: get_actor 5@ model_to 6@ Model.Load(6@) 038B: load_requested_models :Noname_166 wait 0 if Model.Available(6@) jf @:Noname_166 09C7: change_player $PLAYER_CHAR model_to 6@ Player.Build($PLAYER_CHAR) wait 100 0687: clear_actor $PLAYER_ACTOR task Model.Destroy(6@) jump @Noname_212 :Noname_200 Actor.RemoveReferences(5@) jump @Noname_33 :Noname_212 5@ = -1 wait 100 jump @Noname_2 sorry if isn't to much readable... EDIT--------- I feel me like a noob! both are working now but, what is the best way to make what I want? because for the first script it need a little wait, and for the second, it doesn't catch 'special actors' THANKS! This post has been edited by jayd00: Nov 11 2010, 05:03 AM -------------------- |
Nov 11 2010, 09:19 AM Post #2 | |
The master of cut retort Posts: 239 From: Warsaw, PL Joined: 21-July 10 | I believe that you can do it even in two other, easier ways: 1. CLEO3: SANNY {$CLEO} 0000: TARGETTED_ACTOR while true wait 0 if 0256: player 0 defined then if 0AB0: key_pressed 0x69 then 0A8D: 0@ = read_memory 0xB6FB54 size 4 virtual_protect 0 // Pointer to Target + 0x79C if 0019: 0@ > 0 // Any CPed targetted? then 0665: get_actor 0@ model_to 1@ 0247: load_model 1@ while 8248: not model 1@ available wait 0 end 09C7: change_player 0 model_to 1@ 0249: release_model 1@ while 0AB0: key_pressed 0x69 // Wait until key will be released, should improve stability of script wait 0 end end end end end 2. CLEO4 (0AD2 opcode): SANNY {$CLEO} 0000: TARGETTED_ACTOR while true wait 0 if 0256: player 0 defined then if 0AB0: key_pressed 0x69 then if 0AD2: 0@ = player 0 targeted_actor //IF and SET then 0665: get_actor 0@ model_to 1@ 0247: load_model 1@ while 8248: not model 1@ available wait 0 end 09C7: change_player 0 model_to 1@ 0249: release_model 1@ while 0AB0: key_pressed 0x69 // Wait until key will be released, should improve stability of script wait 0 end end end end end Also you shouldn't remove references of that actor, because he isn't created by script. And yeah, looks like getting special actor ID is impossible. If you can't understand high-level constructs, then just recompile your CLEO |
Nov 12 2010, 01:26 AM Post #3 | |
Ameteur Member Posts: 42 From: Guatemala Joined: 22-December 09 | hoo! thanks man! it's much more understandable in high-level.. and what about change $playermodel to the nearest ped?? -------------------- |
Nov 12 2010, 11:42 AM Post #4 | |
The master of cut retort Posts: 239 From: Warsaw, PL Joined: 21-July 10 | Just use that opcode: SANNY 0AB5: store_actor $PLAYER_ACTOR closest_vehicle_to 0@ closest_ped_to 1@ |
Nov 12 2010, 01:27 PM Post #5 | |
Ameteur Member Posts: 48 Joined: 19-August 10 | Question here. What for you loading model if its already loaded ('cause its a streamed-in ped) or the game need model loading anyway for streamed-in models too? |
Nov 12 2010, 03:19 PM Post #6 | |
Coding like a Rockstar! Posts: 1,468 From: ??? Joined: 28-May 09 | Indeed, there's no need to load any model that's already visible... but using 0247 only attempts to load if the model isn't already loaded. 0249 doesn't exactly release the model instantly, it basically tells the game that it can release it whenever it wants (like with remove_reference opcodes). If there are other things which still need the model and have not called 0249 yet, the release will wait until all scripts have finished.. Which is why you can witness Rockstar releasing a model straight after creating it. The model is still in use until the entity is destroyed. Even Ryosuke made this mistake a few times. It's not too much to worry about, since the while check checks if the model isn't loaded first, so while the model loading IS useless, the wait 0 isn't run, so there's no delay. Neither is 0247, so no extra load. The only difference is wasted script bytes. You might as well delete 0247 and 0249 from the script. -------------------- | CLEO 4.3.22 | A?i?a?o?3D | UI SDK | Black Market Mod 1.0.1 | GInput 0.3 | Cheat Keyboard | Tactile Cheat Activation | Stream Ini Extender 0.7 | SuperVars | ScrDebug | Vigilante Justice: San Andreas | |
Nov 12 2010, 11:29 PM Post #7 | |
Ameteur Member Posts: 42 From: Guatemala Joined: 22-December 09 | THANKS for help! CODE $CLEO} 0000: TARGETTED_ACTOR while true wait 0 if 0256: player 0 defined then if 0AB0: key_pressed 0x69 then 0AB5: store_actor $PLAYER_ACTOR closest_vehicle_to 3@ closest_ped_to 0@ wait 0 0665: get_actor 0@ model_to 1@ 0247: load_model 1@ while 8248: not model 1@ available wait 0 end 09C7: change_player 0 model_to 1@ 0249: release_model 1@ while 0AB0: key_pressed 0x69 // Wait until key will be released, should improve stability of script wait 0 end end end end ------------------------------------ hey someone can get me out of doubt in this opcode 0256: player 0 defined '0' means player 0 and it's the same as $PLAYER_CHAR right?? but what about $PLAYER_ACTOR ?? is the same? and what about this opcode: 038B: load_requested_models how to know, when use it? always after model.load ?? This post has been edited by jayd00: Nov 12 2010, 11:39 PM -------------------- |
Nov 13 2010, 01:04 PM Post #8 | |
The master of cut retort Posts: 239 From: Warsaw, PL Joined: 21-July 10 | hey someone can get me out of doubt in this opcode 0256: player 0 defined '0' means player 0 and it's the same as $PLAYER_CHAR right?? but what about $PLAYER_ACTOR ?? is the same? Yeah, $PLAYER_CHAR can be replaced with 0, but $PLAYER_ACTOR can't. and what about this opcode: 038B: load_requested_models how to know, when use it? always after model.load ?? It is useless in SA, you don't have to use it anywhere. @Sweet & Deji for that tip |
Nov 13 2010, 05:26 PM Post #9 | |
Ameteur Member Posts: 48 Joined: 19-August 10 | Teh difference between $PLAYER_CHAR and $PLAYER_ACTOR is obvious. ehT $PLAYER_CHAR is directly pointer to player data and struct as it is. So, $PLAYER_ACTOR is pointer to player as actor (ie. like any ped in sa) |
Nov 14 2010, 08:56 PM Post #10 | |
Ameteur Member Posts: 42 From: Guatemala Joined: 22-December 09 | thanks!! but let me see if I understood well.. the opcodes that have $PLAYER_CHAR can be used for another actor? I mean Actor 1@ can be placed instead $PLAYER_CHAR . Right? and the opcodes that have $PLAYER_ACTOR are only for the player am I right? -------------------- |
Nov 14 2010, 09:15 PM Post #11 | |
The master of cut retort Posts: 239 From: Warsaw, PL Joined: 21-July 10 | In reversed order xP Opcodes with $PLAYER_ACTOR can be used for another actors. Opcodes for $PLAYER_CHAR are only for player(s). |
Nov 14 2010, 11:01 PM Post #12 | |
Ameteur Member Posts: 42 From: Guatemala Joined: 22-December 09 | thanks for help! -------------------- |