I looked at the plugin Deathnotes
I tried to make myselfCode:for ply in BasePlayer.activePlayerList: if self.distance(ply.transform.position, vpos) <= float(PLUGIN['MESSAGES RADIUS']):
Code:for a in player.activePlayerList do if Vector3.Distance(a.transform.position, player.transform.position) <= 300.0 then rust.SendChatMessage(a, player.displayName, msg, player.UserID) end end
Solved Message in radius (Lua)
Discussion in 'Rust Development' started by SwipoStyle, Jul 20, 2015.
-
Calytic Community Admin Community Mod
It would be helpful to add the error you are receiving when attempting to run this.
You cannot currently enumerate over a List Collection with a for loop in lua. Referenced Teleportation
Code:local PlayerListEnumerator = global.BasePlayer.activePlayerList:GetEnumerator() -- Iterate through the online player list and check for a match. while PlayerListEnumerator:MoveNext() do -- Do stuff here local displayName = string.lower( PlayerListEnumerator.Current.displayName ) end
Code:UnityEngine.Vector3.Distance
And finally, you can useCode:rust.UserIDFromPlayer(PlayerListEnumerator.Current)
-
Thank you very much for the help
I want to share my code, local text chat, hopefully to someone it is will be useful
Code:function PLUGIN:OnPlayerChat(arg) local msg = arg:GetString(0, "text") local star = string.sub(msg, 0, 1) local msg = string.sub(msg, 2, -1) if star == '*' then local player = arg.connection.player local PlayerListEnumerator = global.BasePlayer.activePlayerList:GetEnumerator() while PlayerListEnumerator:MoveNext() do local a = PlayerListEnumerator.Current local a_pos = PlayerListEnumerator.Current.transform.position if UnityEngine.Vector3.Distance(a_pos, player.transform.position) <= 300.0 then rust.SendChatMessage(a, player.displayName, msg, rust.UserIDFromPlayer(player)) end end return true end end
Input in chat '*hello world'Last edited by a moderator: Jul 22, 2015