Jump to content

[CLEO] Send a command automatically if determined ID is next to me


halfastrc
 Share

Recommended Posts

Can you explain more about your request? I didn't get what exactly you want. but. If you meant, is there a way to just use this command for players who are close to you? yes, it is possible, see this topic, it may help you.

 

 

Link to comment
Share on other sites

28 minutes ago, D J C said:

Can you explain more about your request? I didn't get what exactly you want. but. If you meant, is there a way to just use this command for players who are close to you? yes, it is possible, see this topic, it may help you.

 

 

It's like in this topic above, but with a little difference, the command it's just to a specific ID

 

For example, if Player[1] it's next to me, automatically I will send in chat a command

Edited by halfastrc
Link to comment
Share on other sites

This is Tupi's code rework for what you need:

 

{$CLEO}
//{$USE CLEO+}

thread "cop"

repeat
    wait 0 
until 0AFA:

0B63: "cop"
0B34: "cop" @cop

WHILE TRUE
wait 0

if 0@ == 1
then
    0@ = 0
    
        if SAMP.IsPlayerConnected(2@)
        then
            10@ = SAMP.GetActorHandleByPlayerID(2@)
            11@ = SAMP.GetPlayerColor(2@)
            if 056D:   actor 10@ defined
            then
                00A0: store_actor 10@ position_to 3@ 4@ 5@
                00A0: store_actor $PLAYER_ACTOR position_to 6@ 7@ 8@
                050A: 9@ = distance_between_XYZ 3@ 4@ 5@ and_XYZ 6@ 7@ 8@
                if and 
                    not 9@ > 10.0
                    not 11@ == 0xFFAA3333
                then 
                    say "test"
                end
            end
        end
end

END

:cop
SAMP.IsCommandTyped(30@)
if 0AD4: 1@ = scan_string 30@ format "%d" 2@
then
    0@ = 1
else
chatmsg "Syntax: /cop <id>" -1
end
cmdret
Link to comment
Share on other sites

5 hours ago, Nic said:

This is Tupi's code rework for what you need:

 


{$CLEO}
//{$USE CLEO+}

thread "cop"

repeat
    wait 0 
until 0AFA:

0B63: "cop"
0B34: "cop" @cop

WHILE TRUE
wait 0

if 0@ == 1
then
    0@ = 0
    
        if SAMP.IsPlayerConnected(2@)
        then
            10@ = SAMP.GetActorHandleByPlayerID(2@)
            11@ = SAMP.GetPlayerColor(2@)
            if 056D:   actor 10@ defined
            then
                00A0: store_actor 10@ position_to 3@ 4@ 5@
                00A0: store_actor $PLAYER_ACTOR position_to 6@ 7@ 8@
                050A: 9@ = distance_between_XYZ 3@ 4@ 5@ and_XYZ 6@ 7@ 8@
                if and 
                    not 9@ > 10.0
                    not 11@ == 0xFFAA3333
                then 
                    say "test"
                end
            end
        end
end

END

:cop
SAMP.IsCommandTyped(30@)
if 0AD4: 1@ = scan_string 30@ format "%d" 2@
then
    0@ = 1
else
chatmsg "Syntax: /cop <id>" -1
end
cmdret

Thank's, it's something like this, but I got one problem, I would to like say "test" in chat, automatically if the player is next to me. But now, to say "test" in chat, I need type "/cop ID" and the player need near me. 

 

For example, I want type in chat "/cop ID" and if the player it's next to me, automatically send in chat "/approach ID"

 

I try do this:

{$CLEO .cs}
{$USE bitwise}
{$USE CLEO+}
{$USE file}
{$USE ini}
{$USE newOpcodes}

thread "cop"

repeat
    wait 0 
until 0AFA:

0B63: "cop"
0B34: "cop" @cop

WHILE TRUE
wait 0

if 0@ == 1
then
    0@ = 0
    
        if SAMP.IsPlayerConnected(2@)
        then
            10@ = SAMP.GetActorHandleByPlayerID(2@)
            11@ = SAMP.GetPlayerColor(2@)
            if 056D:   actor 10@ defined
            then
                00A0: store_actor 10@ position_to 3@ 4@ 5@
                00A0: store_actor $PLAYER_ACTOR position_to 6@ 7@ 8@
                050A: 9@ = distance_between_XYZ 3@ 4@ 5@ and_XYZ 6@ 7@ 8@
                if and 
                    not 9@ > 10.0
                    not 11@ == 0xFFAA3333
                then 
                    0AFA: samp say_msg "/approach %d
                end
            end
        end
end

END

:cop
SAMP.IsCommandTyped(30@)
if 0AD4: 1@ = scan_string 30@ format "%d" 2@
then
    0@ = 1
else
chatmsg "Syntax: /cop <id>" -1
end
cmdret

I appreciate any help, thanks

Edited by halfastrc
Link to comment
Share on other sites

@halfastrc so after you execute /cop id the mod will wait until the player is near you and then execute /approach id? Or only verify once when /cop command is executed?

And /approach id is a server command or a command from a cleo mod?

Edited by Nic
Link to comment
Share on other sites

2 hours ago, Nic said:

@halfastrc so after you execute /cop id the mod will wait until the player is near you and then execute /approach id? Or only verify once when /cop command is executed?

And /approach id is a server command or a command from a cleo mod?

so after you execute /cop id the mod will wait until the player is near you and then execute /approach id? Yes, is this.

 

/approach is a server command

Link to comment
Share on other sites

{$CLEO}
{$USE CLEO+}

thread "cop"

repeat
    wait 0 
until 0AFA:

0B63: "cop"
0B34: "cop" @cop

WHILE TRUE
wait 0

if 0@ == 1
then
        repeat
        wait 0
    
        if SAMP.IsPlayerConnected(2@)
        then
            10@ = SAMP.GetActorHandleByPlayerID(2@)
            11@ = SAMP.GetPlayerColor(2@)
            if 056D:   actor 10@ defined
            then
                00A0: store_actor 10@ position_to 3@ 4@ 5@
                00A0: store_actor $PLAYER_ACTOR position_to 6@ 7@ 8@
                050A: 9@ = distance_between_XYZ 3@ 4@ 5@ and_XYZ 6@ 7@ 8@
                if and 
                    not 9@ > 10.0 // Distance, lower/higher it for your needs
                    not 11@ == 0xFFAA3333
                then 
                    say "/approach %d" 2@
                    0@ = 0
                    
                    wait 100
                end
            end
        end
        until 0@ == 0
end

END

:cop
SAMP.IsCommandTyped(30@)
if 0AD4: 1@ = scan_string 30@ format "%d" 2@
then
    0@ = 1
else
chatmsg "Syntax: /cop <id>" -1
end
cmdret

Should work now @halfastrc

Edited by Nic
Link to comment
Share on other sites

  • Nic locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.