Nova7GFU Posted May 23, 2016 Share Posted May 23, 2016 Well, these questions are mainly to create an "advanced Bodyguard" And would do to learn more about CLEO and have a bodyguard to look after me when walking on the street and I meet Haitians annoying, you know. 1) How to store the "Actor" who attack "Player_Actor" in a variable? For example, a "cop" shoots the "player", then the "cop" is detected and stored in Variable [email protected] 2) How I can add weapons to the "actors" without the game crashes? (I tried loading the model, check and put with the 'opcode: 01B2' to the actor, but the game crashes). That's all for now. Sorry for my bad english. Link to comment Share on other sites More sharing options...
spaceeinstein Posted May 24, 2016 Share Posted May 24, 2016 There is an example code for 01B2 here. Link to comment Share on other sites More sharing options...
Nova7GFU Posted May 25, 2016 Author Share Posted May 25, 2016 (edited) There is an example code for 01B2 here. Sir, I've already tried this way. :Name_Threadthread 'THREAD'0247: request_model 1030247: request_model #M4:Label_01wait 0IF 0248: model 103 available 0248: model #M4 availableTHEN 04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0 009A: [email protected] = create_actor 4 103 at [email protected] [email protected] [email protected] 01B2: give_actor [email protected] weapon #M4 ammo 500 01DF: tie_actor [email protected] to_player $PLAYER_CHAR 0249: release_model 103 0249: release_model #M4ELSE jump @Label_01END This is just one example of what I did. Sorry for my english. EDIT: the game still crashes, why? Edited May 25, 2016 by Nova7GFU Link to comment Share on other sites More sharing options...
thehambone Posted May 25, 2016 Share Posted May 25, 2016 (edited) Three things: IF 0248: model 103 available 0248: model #M4 available This should be an "IF AND" statement, since you have more than one condition and you want both conditions to be true in order to continue. (SannyBuilder should throw an error about this) 01B2: give_actor [email protected] weapon #M4 ammo 500 The second parameter for this opcode is not the weapon model ID. It is the weapon number, which is different than the model ID. For the M4, the weapon number is 26. You can find a list of all weapon numbers here. 004E: end_thread You must add this to the end of your code or it will crash.I recommend using constants in your code as it makes your code easier to read and understand. It's also easier to make changes (such as changing the ped model) when you use constants.Here's the full, working code (with constants). {$CLEO .cs}const PED_MODEL = 103 WEAP_MODEL = #M4 WEAP_NUMBER = 26end:Name_Threadthread 'THREAD'0247: request_model PED_MODEL0247: request_model WEAP_MODEL:Label_01wait 0IF AND 0248: model PED_MODEL available 0248: model WEAP_MODEL availableTHEN 04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0 009A: [email protected] = create_actor 4 PED_MODEL at [email protected] [email protected] [email protected] 01B2: give_actor [email protected] weapon WEAP_NUMBER ammo 500 01DF: tie_actor [email protected] to_player $PLAYER_CHAR 0249: release_model PED_MODEL 0249: release_model WEAP_MODELELSE jump @Label_01END004E: end_thread Edited May 25, 2016 by thehambone Meet the GTA 3 players who've spent a decade playing pass-the-pad to 100% the game - GamesRadar GTA:LCS Save Editor - Supports Android, iOS, PS2, and PSP saves! GTA3 Save Editor - Big update in the works! Link to comment Share on other sites More sharing options...
Nova7GFU Posted May 25, 2016 Author Share Posted May 25, 2016 (edited) IF 0248: model 103 available 0248: model #M4 available This should be an "IF AND" statement, since you have more than one condition and you want both conditions to be true in order to continue. (SannyBuilder should throw an error about this) Exactly, Sanny Builder does, but that's not the problem. And thanks for reply, I'll try and then tell you. EDIT: I'm a n00b, I forgot jump @Label_01 after creating the actor. I want more than one bodyguard, but with the '004E: end_thread' I can only have one. Here the code: {$CLEO .cs}const PED_MODEL = 103 WEAP_MODEL = #M4 WEAP_NUMBER = 26end:Name_Threadthread 'THREAD'[email protected] = 0:Label_010247: request_model PED_MODEL0247: request_model WEAP_MODELwait 0IF AND 0248: model PED_MODEL available 0248: model WEAP_MODEL availableTHEN IF [email protected] == 0 THEN IF 0AB0: key_pressed 0x73 THEN 04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0 009A: [email protected] = create_actor 4 PED_MODEL at [email protected] [email protected] [email protected] 01B2: give_actor [email protected] weapon WEAP_NUMBER ammo 500 0319: set_actor [email protected] running 1 01DF: tie_actor [email protected] to_player $PLAYER_CHAR 0249: release_model PED_MODEL 0249: release_model WEAP_MODEL [email protected] = 1 jump @Label_01 ELSE jump @Label_01 END ELSE IF [email protected] == 1 THEN IF or Actor.Dead($PLAYER_ACTOR) Actor.Dead([email protected]) THEN Actor.DestroyWithFade([email protected]) Actor.RemoveReferences([email protected]) [email protected] = 0 wait 1000 jump @Label_01 ELSE jump @Label_01 END ELSE jump @Label_01 END ENDELSE jump @Label_01END But, I don't understand why sometimes not attack who attacked me. PS: All who are interested please help me, I will appreciate your help. EDIT2: Now, I don't understand WHY sometimes does not disappear when the player dies. I using 'RemoveReferences' and 'DestroyWithFade'. Edited May 26, 2016 by Nova7GFU Link to comment Share on other sites More sharing options...
ZAZ Posted May 27, 2016 Share Posted May 27, 2016 (edited) Load models only as soon as they're needed (not before the keypress) ---- Nice to see that you're able to use a var as "switch/step controler" -> [email protected] But i think it's not necessary for that tiny script Test the script inside the spoiler {$CLEO .cs}thread 'BGUARD'const PED_MODEL = 103 WEAP_MODEL = #M4 WEAP_NUMBER = 26endwhile truewait 0 if 0256: player $PLAYER_CHAR defined then if 0AB0: key_pressed 0x73// press F4 key then 0247: request_model PED_MODEL 0247: request_model WEAP_MODEL while true wait 0 IF AND 0248: model PED_MODEL available 0248: model WEAP_MODEL available THEN 04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0 009A: [email protected] = create_actor 4 PED_MODEL at [email protected] [email protected] [email protected] 01B2: give_actor [email protected] weapon WEAP_NUMBER ammo 500 04F5: unknown_actor [email protected] kiss_player $PLAYER_CHAR on 1 0249: release_model PED_MODEL 0249: release_model WEAP_MODEL break end end while 0256: player $PLAYER_CHAR defined wait 0 if 8118: not actor [email protected] dead then if 00E9: player $PLAYER_CHAR 0 [email protected] radius 100.0 100.0 then if 8320: not actor [email protected] in_range_of_player $PLAYER_CHAR then 01DF: tie_actor [email protected] to_player $PLAYER_CHAR end else break end else break end end 03E5: text_box 'FEM_OFF' Actor.RemoveReferences([email protected]) end endend Everthing is inside the key_press check: model load, loop to check if models are loaded and actor spawn, then the loop to ckeck if actor dies as well if he is still in range, also Actor.RemoveReferences a textbox message "OFF" appears at the end to indicate especially if actor is too far away I made loops by using the while statement, either for ever (as long as game is running ingame): while true wait 0 end or with condition while 0256: player $PLAYER_CHAR defined wait 0 end the command break let the code leave the loop I found this method in the gangmem thread of vc main.scm: 04F5: unknown_actor [email protected] kiss_player $PLAYER_CHAR on 1if 00E9: player $PLAYER_CHAR 0 [email protected] radius 100.0 100.0then if 8320: not actor [email protected] in_range_of_player $PLAYER_CHAR then 01DF: tie_actor [email protected] to_player $PLAYER_CHAR ..... Edited May 27, 2016 by ZAZ CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
Silent Posted May 27, 2016 Share Posted May 27, 2016 (edited) Same code as ZAZ's, but tweaked a bit to be shorter and more R* style with checks (notice different loops). Also removed script name since it's useless with CLEO scripts (unless you're doing inter-script communication): {$CLEO}0000: BGUARDconst PED_MODEL = 103 WEAP_MODEL = #M4 WEAP_NUMBER = 26endwhile true wait 0 if 0256: player $PLAYER_CHAR defined then if 0AB0: key_pressed 0x73// press F4 key then 0247: request_model PED_MODEL 0247: request_model WEAP_MODEL while true if or 8248: not model PED_MODEL available 8248: notmodel WEAP_MODEL available jf break wait 0 end 04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0 009A: [email protected] = create_actor 4 PED_MODEL at [email protected] [email protected] [email protected] 01B2: give_actor [email protected] weapon WEAP_NUMBER ammo 500 04F5: set_char [email protected] as_player_friend $PLAYER_CHAR on 1 0249: release_model PED_MODEL 0249: release_model WEAP_MODEL while 0256: player $PLAYER_CHAR defined if 8118: not actor [email protected] dead jf break if 00E9: player $PLAYER_CHAR 0 [email protected] radius 100.0 100.0 jf break wait 0 if 8320: not actor [email protected] in_range_of_player $PLAYER_CHAR then 01DF: tie_actor [email protected] to_player $PLAYER_CHAR end end 03E5: text_box 'FEM_OFF' 01C2: remove_references_to_actor [email protected] end endendSince both scripts are valid and 100% identical behaviour wise, you could consider this an example of different coding styles! Edited May 27, 2016 by Silent Link to comment Share on other sites More sharing options...
X-Falcon Posted May 27, 2016 Share Posted May 27, 2016 (edited) Amazing Silent it so very short! but i wonder. What different with loop REPEAT until FALSE, sorry copy'paste just for learning. {$CLEO}0000: BGUARDconst PED_MODEL = 103 WEAP_MODEL = #M4 WEAP_NUMBER = 26endwhile true wait 0 if 0256: player $PLAYER_CHAR defined then if 0AB0: key_pressed 0x73// press F4 key then 0247: request_model PED_MODEL 0247: request_model WEAP_MODEL REPEAT wait 0 if or 8248: not model PED_MODEL available 8248: notmodel WEAP_MODEL available jf break until FALSE 04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0 009A: [email protected] = create_actor 4 PED_MODEL at [email protected] [email protected] [email protected] 01B2: give_actor [email protected] weapon WEAP_NUMBER ammo 500 04F5: set_char [email protected] as_player_friend $PLAYER_CHAR on 1 0249: release_model PED_MODEL 0249: release_model WEAP_MODEL while 0256: player $PLAYER_CHAR defined if 8118: not actor [email protected] dead jf break if 00E9: player $PLAYER_CHAR 0 [email protected] radius 100.0 100.0 jf break wait 0 if 8320: not actor [email protected] in_range_of_player $PLAYER_CHAR then 01DF: tie_actor [email protected] to_player $PLAYER_CHAR end end 03E5: text_box 'FEM_OFF' 01C2: remove_references_to_actor [email protected] end end endSince both scripts are valid and 100% identical behaviour wise, you could consider this an example of different coding styles! Edited May 27, 2016 by X-Falcon Link to comment Share on other sites More sharing options...
Silent Posted May 27, 2016 Share Posted May 27, 2016 (edited) repeat...until false and while true are identical, but the first one is objectively more awkward You wouldn't see it in any real-purpose language, unlike a while loop. Edited May 27, 2016 by Silent thehambone 1 Link to comment Share on other sites More sharing options...
X-Falcon Posted May 28, 2016 Share Posted May 28, 2016 Ah, I didn't know that is have awkward language. But i wouldn't out the fact, i also see Master Seemann old post that common showing the while loop. Seems this can amplify the absolute while true. Guess when the both loop work properties, i would keep the both to be tried. Thank you for feedback Silent. Link to comment Share on other sites More sharing options...
Nova7GFU Posted May 29, 2016 Author Share Posted May 29, 2016 (edited) Well, thank you very much Mr. @ZAZ and Mr. @Silent for replies. New learned skill. EDIT: Personally, I prefer the style that Mr. ZAZ suggested. Sorry for my english. Edited May 29, 2016 by Nova7GFU Link to comment Share on other sites More sharing options...
Nova7GFU Posted June 28, 2016 Author Share Posted June 28, 2016 I have a new question!How I can put my own camera like this? Objective: Handling my own camera with Mouse pointing where I want Issue: The camera only points in the direction (read code) and I can't move the camera Here the code: {$CLEO .cs}0000: SLOWMOB // TESTED!CONST SWITCHER = [email protected] TRUE wait 0 IF 00E1: player 0 pressed_key 6 THEN 04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 0.4 -1.5 0.7 Camera.SetPosition([email protected], [email protected], [email protected], 0.0, 0.0, 0.0) Camera.PointAt([email protected], [email protected], [email protected], 2) SWITCHER = 1 ELSE IF SWITCHER == 1 THEN Camera.Restore_WithJumpCut() SWITCHER = 0 END ENDEND I hope some help. Link to comment 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