|
本帖最后由 j4b 于 2024-7-12 00:53 编辑
这个方法不推荐使用最好是服务器更新防挂
挂消失更好
如何防范挂逼在函数S.prototype.onThrowed = function(e)加入- S.prototype.onThrowed = function(e) {
- var pp=0
- for (var t = 0; t < h.instance.players.length; t++) {
- var n = h.instance.players[t];
- if (n == this.gameObject)
- continue;
- if(n.anchoredX >= this.gameObject.anchoredX - 60
- && n.anchoredX < this.gameObject.anchoredX
- && n.anchoredY <= this.gameObject.anchoredY + 30
- && n.anchoredY >= this.gameObject.anchoredY - 10){
- pp=1
- break;
- }
- if(n.anchoredX <= this.gameObject.anchoredX + 60
- && n.anchoredX > this.gameObject.anchoredX
- && n.anchoredY <= this.gameObject.anchoredY + 30
- && n.anchoredY >= this.gameObject.anchoredY - 10){
- pp=1
- break;
- }
- }
- if(pp==1){
- for(var i=0;i<Hei.length;i++){
- if(Hei[i] == this.uuid){break;}else{
- var t = parseInt(e);
- this.rigidbody.velocity.y = -this.throwHeight,
- this.rigidbody.velocity.x = e == 0 ? -this.throwSpeed : this.throwSpeed,
- this.controlable = !1
- break;
- }
- }
- }
- pp=0
- }
- ,
复制代码 在调用throw改为- case "throw":
- this.isMe || this.throw();
- var t = e.target
- , n = h.instance.playerMap["p" + t];
- n && n.Player && n.Player.onThrowed(e.dir);
- fang=t
- gong=this.uuid
- youname=this.playerName
- if(meuuid==fang){
- number++
- youuuid=gong
- }
- setInterval(function(){
- number=0
- },2000);
- if(number==3) {
- Hei.push({uuid:youuuid,name:youname})
- }
- break;
复制代码 记得在自执行声明变量- var Hei=[{uuid:114514,name:"挂逼"}]//给个初始值方便遍历
- ,meuuid=0
- ,youuuid=0
- ,youname=""
- ,gong=0
- ,fang=0
- ,number=0
复制代码
|
|