[Suggestion] add an option to the /player command to apply it to every fake player
cncz42 opened this issue ยท 3 comments
Was using this mod to set up groups of dummy players as npcs for a little project and noticed it's a bit hard to get all the dummy players to certain positions or make them all do the same thing, would it be possible to add an argument to the /player command that does the command on every fake player rather than needing to do one at a time, such as /player [everyone] look?
Not sure how useful would that be most of the time, but you can always do something like that in Scarpet (by getting each online bot with something like filter(players('all'),_~'player_type'=='fake');
, then looping your command with that.
Like:
fakes = filter(players('all'),_~'player_type'=='fake');
for(fakes,
run('player '+_~'name'+' look');
);
Or if you need it to work like if you did execute it, just put execute as [your name] run
in there.
Maybe even convert it into a function and save it into a Scarpet app:
allPlayers(command) ->
(
fakes = filter(players('all'),_~'player_type'=='fake');
for(fakes,
run('execute as '+player()~'name'+' run '+replace(command,'%s',_~'name'));
);
)
Then run with /script run allPlayers('player %s look')
if you have it in the global command scope
or if it's saved in an app something like /script in [app name] run allPlayers('player %s look')
.
(basically run the function and %s will be replaced with the names of the fakes).
You can read the Scarpet docs if you want a custom command for this, you could do something like /allfakes [command]
with the new command system, but I'm still not familiar with it.
Note: Those scripts were designed here in the browser, I didn't test them.
__config()->{
'commands'->{
'<action>'->'allPlayers'
},
'arguments'->{
'action'->{
'type'->'term',
'suggest'->[
//this would be a list of all possible actions u can do with /player
]
}
}
};
allPlayers(command) ->
(
fakes = filter(players('all'),_~'player_type'=='fake');
for(fakes,
run('execute as '+player()~'name'+' run '+replace(command,'%s',_~'name'));
);
)