| Blockland Forums > Modification Help |
| How might one go about fetching all players in a server? |
| (1/1) |
| Lugnut:
I saw this question in Kekomons console command list. So I made this, I am 99% sure it won't work (untested), and I think I know where the error would be. Would this work? --- Code: ---function servercmdfetchallplayers(%c) { if(!%c.issuperadmin) return; for(%x=0;%x<clientGroup.getCount();%x++) clientGroup.getObject(%x).player.settansform(%c.player.gettransform()); } --- End code --- I think the error would come after for(%x=0;%x<clientGroup.getCount();%x++) because of some improper transition or something. Anyone? |
| otto-san:
I think what you have will work. |
| Lugnut:
Just chatted a bit with Jetz, apparently the only problem is a console error if the player doesn't exist. so I threw in if(!isObject(clientGroup.getObject(%x).player)) return; only to realize this would kill the whole loop. I then, as per jetz's reccomendation to 'inverting the condition of the loop, since you're only doing one thing with the player." This is the final product. --- Code: ---function servercmdfetchallplayers(%c) { if(!%c.issuperadmin) return; for(%x=0;%x<clientGroup.getCount();%x++) if(isObject(clientGroup.getObject(%x).player)) clientGroup.getObject(%x).player.settansform(%c.player.gettransform()); } --- End code --- |
| Navigation |
| Message Index |