I'm new.I want to know how to use this code.Code:(bool) isPlayerInZone(string ZoneID, BasePlayer player)
For example i make an zone.
i want to know If a person in that zone , how he can use a command for example /buy or something like that.
Code:class RPtest : RustPlugin { [ChatCommand("buy")] private void ReportCmd(BasePlayer player, string key, string[] args) { foreach (BasePlayer p in BasePlayer.activePlayerList.Where(x => x.IsAdmin)) { if(isPlayerInZone(zonejob)==true) SendReply(p, $"{player.displayName} used /buy!"); } } private bool isPlayerInZone(string ZoneID, BasePlayer player) { ZoneID = "10946375"; return; } }
How can i use this code?
Discussion in 'Rust Development' started by SoroushMarc, Apr 21, 2018.
-
Hi, isPlayerZone return boolean. You need to return true or false .
Edit : Sorry I answered a little quickly . All you had to do was call isPlayerInZone with the zone and players settings
If I understood correctly you want to see the players who are can use the buy command?
You can pass an argument to your buy command like this /buy 012345 this argument will be the area you want to test .
Code:class RPtest : RustPlugin { [ChatCommand("buy")] private void ReportCmd(BasePlayer player, string key, string[] args) { foreach (BasePlayer p in BasePlayer.activePlayerList.Where(x => x.IsAdmin)) { if(isPlayerInZone(args[0], p)) SendReply(player, $"{p.displayName} used /buy!"); } } }
You can also put the argument hard in your code.
Code:if(isPlayerInZone("012345", p)) SendReply(player, $"{p.displayName} used /buy!");
Last edited by a moderator: Apr 21, 2018 -
Code:[PluginReference] private Plugin ZoneManager;
Code:if ((bool) ZoneManager.Call("isPlayerInZone", zoneName, player)) { Puts("YES"); } else { Puts("NO"); }
Live example:
Code:[ChatCommand("buy")] private void ReportCmd(BasePlayer player, string key, string[] args) { if ((bool) ZoneManager.Call("isPlayerInZone", "noBuyZone", player)) { player.ChatMessage("You can't use /buy in this zone!"); return; } // Your code if player is not in zone }