D J C Posted September 17, 2020 Share Posted September 17, 2020 I want the code to receive the ID or name of the who is close to me and execute a specific command, EX: /repairall -> Offer car repair to people close to me Link to comment Share on other sites More sharing options...
Tupi Posted September 17, 2020 Share Posted September 17, 2020 (edited) Hello, Try this code: {$CLEO} repeat wait 0 until 0AFA: 0B63: "repairall" 0B34: "repairall" @REPAIRALL WHILE TRUE wait 0 if 0@ == 1 then 0@ = 0 for 1@ = 0 to 999 if SAMP.IsPlayerConnected(1@) then 2@ = SAMP.GetActorHandleByPlayerID(1@) 10@ = SAMP.GetPlayerColor(1@) if 056D: actor 2@ defined then 00A0: store_actor 2@ 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 not 9@ > 15.0 then if or not 10@ == 0xAA3333 not 10@ == 0xAA3333FF then say "/repair %d 1" 1@ wait 200 end end end end end END :REPAIRALL 0B12: 0@ = 0@ XOR 1 cmdret I hope I helped you, if you need anything else, you can leave it below and I will help you. Edited September 17, 2020 by Tupi Link to comment Share on other sites More sharing options...
D J C Posted September 17, 2020 Author Share Posted September 17, 2020 (edited) Error: A jump to the offest is not found. repeat wait 0 until 0AFA: I think the problem is from this. Edited September 17, 2020 by DjC Link to comment Share on other sites More sharing options...
Tupi Posted September 17, 2020 Share Posted September 17, 2020 4 minutes ago, DjC said: Error: A jump to the offest is not found. I missed something, sorry, try this {$CLEO} thread "RepairAll" repeat wait 0 until 0AFA: ... Link to comment Share on other sites More sharing options...
D J C Posted September 17, 2020 Author Share Posted September 17, 2020 (edited) Got crash from it, other suggest way to resolve it ?! It's all the code: {$CLEO} thread "RepairAll" repeat wait 0 until 0AFA: 0B63: "repairall" 0B34: "repairall" @REPAIRALL WHILE TRUE wait 0 if 0@ == 1 then 0@ = 0 for 1@ = 0 to 999 if SAMP.IsPlayerConnected(1@) then 2@ = SAMP.GetActorHandleByPlayerID(1@) 10@ = SAMP.GetPlayerColor(1@) if 056D: actor 2@ defined then 00A0: store_actor 2@ 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 not 9@ > 15.0 then if or not 10@ == 0xAA3333 not 10@ == 0xAA3333FF then say "/repair %d 1" 1@ wait 200 end end end end end END :REPAIRALL 0B12: 0@ = 0@ XOR 1 cmdret Edited September 17, 2020 by DjC Link to comment Share on other sites More sharing options...
Tupi Posted September 17, 2020 Share Posted September 17, 2020 13 minutes ago, DjC said: Got crash from it, other suggest way to resolve it ?! It's all the code: {$CLEO} thread "RepairAll" repeat wait 0 until 0AFA: 0B63: "repairall" 0B34: "repairall" @REPAIRALL WHILE TRUE wait 0 if 0@ == 1 then 0@ = 0 for 1@ = 0 to 999 if SAMP.IsPlayerConnected(1@) then 2@ = SAMP.GetActorHandleByPlayerID(1@) 10@ = SAMP.GetPlayerColor(1@) if 056D: actor 2@ defined then 00A0: store_actor 2@ 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 not 9@ > 15.0 then if or not 10@ == 0xAA3333 not 10@ == 0xAA3333FF then say "/repair %d 1" 1@ wait 200 end end end end end END :REPAIRALL 0B12: 0@ = 0@ XOR 1 cmdret Ok, this is solution, i tested and don't received crash {$CLEO} thread "Repairall" repeat wait 0 until 0AFA: 0B63: "repairall" 0B34: "repairall" @REPAIRALL WHILE TRUE wait 0 if 0@ == 1 then 0@ = 0 for 1@ = 0 to 999 if SAMP.IsPlayerConnected(1@) then 2@ = SAMP.GetActorHandleByPlayerID(1@) 11@ = SAMP.GetPlayerColor(1@) if 056D: actor 2@ defined then 00A0: store_actor 2@ 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 Actor.Driving(2@) not 9@ > 10.0 not 11@ == 0xFFAA3333 then say "/repair %d 1" 1@ wait 1000 end end end end end END :REPAIRALL 0B12: 0@ = 0@ XOR 1 cmdret 1 Link to comment Share on other sites More sharing options...
CouldnoT Posted September 17, 2020 Share Posted September 17, 2020 (edited) Hello, Putting a command that handles an event forwarded to 1000 player as a maximum number in an infinite loop isn't best performance as it may cause memory crash in a huge place like an event or CNN. this maybe a more efficient essay with less memory crash, as the anti-spammer will limit it to the first three players with the smaller ID. :repairall FOR 12@ = 0 to 999 IF SAMP.IsPlayerConnected(12@) THEN 26@ = SAMP.GetActorHandleByPlayerID(12@) IF 056D: actor 26@ defined THEN 00A0: store_actor $PLAYER_ACTOR position_to 13@ 14@ 15@ 00A0: store_actor 26@ position_to 16@ 17@ 18@ 050A: 19@ = distance_between_XYZ 13@ 14@ 15@ and_XYZ 16@ 17@ 18@ IF and 19@ <= 8.0 00DF: actor 26@ driving THEN say "/repair %d 1" 12@ END END END END SAMP.CmdRet() If you're still with idea that you want it in an infinite loop then assign false to 0@ after the process of the instructions coming after as it's better performance, it won't allow you to re-use the command /repairall until the process of the for loop is fully satisfied. So this would be the approach : WHILE TRUE wait 0 if 0@ == 1 then for 1@ = 0 to 999 if SAMP.IsPlayerConnected(1@) then 2@ = SAMP.GetActorHandleByPlayerID(1@) //11@ = SAMP.GetPlayerColor(1@) if 056D: 2@ then 00A0: store_actor 2@ 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 Actor.Driving(2@) not 9@ > 10.0 //not 11@ == 0xFFAA3333 <---- this will limit the repair to reach your collegues then say "/repair %d 1" 1@ wait 1000 end end end end 0@ = 0 end END Make sure you fully understand the algorithm before using it. Edited September 17, 2020 by CouldnoT 1 Link to comment Share on other sites More sharing options...
Tupi Posted September 17, 2020 Share Posted September 17, 2020 (edited) 48 minutes ago, CouldnoT said: :repairall FOR 12@ = 0 to 999 IF SAMP.IsPlayerConnected(12@) THEN 26@ = SAMP.GetActorHandleByPlayerID(12@) IF 056D: actor 26@ defined THEN 00A0: store_actor $PLAYER_ACTOR position_to 13@ 14@ 15@ 00A0: store_actor 26@ position_to 16@ 17@ 18@ 050A: 19@ = distance_between_XYZ 13@ 14@ 15@ and_XYZ 16@ 17@ 18@ IF and 19@ <= 8.0 00DF: actor 26@ driving THEN say "/repair %d 1" 12@ END END END END SAMP.CmdRet() @CouldnoT 1. function FOR maybe used only in a loop, not in commands. 2. If you not use SAMP.GetPlayerColor and verify if color is for hitman, you received a small ban for illegal mods. @DjC solved? Edited September 17, 2020 by Tupi 1 Link to comment Share on other sites More sharing options...
D J C Posted September 17, 2020 Author Share Posted September 17, 2020 3 minutes ago, Tupi said: @CouldnoT 1. function FOR maybe used only in a loop, not in commands. 2. If you not use SAMP.GetPlayerColor and verify if color is for hitman, you received a small ban for illegal mods. @DjC solved? Yep problem solved, thanks for the support. Link to comment Share on other sites More sharing options...
Tupi Posted September 17, 2020 Share Posted September 17, 2020 2 minutes ago, DjC said: Yep problem solved, thanks for the support. With pleasure! If you still need help, contact me on PM! 1 Link to comment Share on other sites More sharing options...
Recommended Posts