Quantcast

Jump to content

» «
Photo

Object in radius

2 replies to this topic
caeser10
  • caeser10

    Player Hater

  • Members
  • Joined: 14 Dec 2013

#1

Posted 14 December 2013 - 11:20 PM Edited by caeser10, 15 December 2013 - 06:21 AM.

Well, hi all, I'm a total newbie in CLEO coding and I've spent 4 hours on my first piece of code. The point is I've found multiple syntax rules and opcodes all over the internet and I dunno how to write correctly. I want to show off a text draw above an object (vending machine ID 1209) when the player gets close by (radius of 200 meters). I'm looking for the opcode that will allow to identify an object with its ID and convert it to a float (4@) but I'm exhausted and my brain is smoking. Here is the beginning (sorry for the poor quality):

 

{$CLEO .cs}

//-------------MAIN---------------
0000: NOP

:MNBG_1
wait 500
  Actor.StorePos($PLAYER_ACTOR, 1@, 2@, 3@)
 set_visibility_of_closest_object_of_type 1@ 2@ 3@ radius 200.0 model $1209 visibility 1
 jump @MNBG_1   

 

 

 

Thanks for helping!!!!


Jack
  • Jack

    aka Hollywood Jack

  • Feroci
  • Joined: 06 Dec 2011
  • Serbia

#2

Posted 15 December 2013 - 06:52 AM

Read CLEO scrypt tutorial first and then try with this:
{$CLEO}
0000: OID
 
WHILE 8256:   not player $PLAYER_CHAR defined 
    wait 250
END
 
WHILE TRUE
    wait 0
    00A0: store_actor $PLAYER_ACTOR position_to 0@ 1@ 2@ 
    IF
        0AE3: 3@ = random_object_near_point 0@ 1@ 2@ in_radius 200.0 find_next 0 // are there any object within players radius of 200.0?
    THEN 
        REPEAT
            IF 
                09CC:   object 3@ model_is 1209  // is the object ID 1209   
            THEN
            0400: store_coords_to 4@ 5@ 6@ from_object 3@ with_offset 0.0 0.0 5.0  // 5.0 is a Z coord position (above object)
            text draw should be here - I'm not sure which opcode - I don't work with them much
            END
        UNTIL 8AE3:   not   3@ = random_object_near_point 0@ 1@ 2@ in_radius 200.0 find_next 1 //IF and SET
    END
END
Good luck.

caeser10
  • caeser10

    Player Hater

  • Members
  • Joined: 14 Dec 2013

#3

Posted 15 December 2013 - 08:27 AM

Thank you so much!! it's gonna be very useful. As you are not comfortable with text draw, I ask someone else some help with this :

{$CLEO}
0000: OID
 
WHILE 8256:   not player $PLAYER_CHAR defined
    wait 250
END
 
WHILE TRUE
    wait 0
    00A0: store_actor $PLAYER_ACTOR position_to 0@ 1@ 2@
    03F0: enable_text_draw 1
    IF
        0AE3: 3@ = random_object_near_point 0@ 1@ 2@ in_radius 200.0 find_next 0 // are there any object within players radius of 200.0?
    THEN
        REPEAT
            IF
                09CC:   object 3@ model_is 1209  // is the object ID 1209   
            THEN
            0400: store_coords_to 4@ 5@ 6@ from_object 3@ with_offset 0.0 0.0 5.0  // 5.0 is a Z coord position (above object)
        0342: set_text_draw_centered 1
        081C: draw_text_outline 1 RGBA 0 0 0 175
        0340: set_text_draw_RGBA 255 255 255 175
        033F: set_text_draw_letter_size 0.3 1.1
        033E: set_draw_text_position 4@ 5@ GXT 'Go there'
            END
        UNTIL 8AE3:   not   3@ = random_object_near_point 0@ 1@ 2@ in_radius 200.0 find_next 1 //IF and SET
    END
END




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users