@name FailCake Expressware V1 PlyFinder
@inputs EGP:wirelink
@persist PlayerList:array Ply:entity [O E]:entity
@persist Chat:array GTABLE:gtable PlyL:array Music:array
@trigger all

function void findPly(HS:entity){

for(I=0,PlyL:count()){
    
if(HS == PlayerList[I,entity]){
hint("Player Already In!",7) 
E:soundPlay(1,0,"/ui/trade_failure.wav")
break   
}

if(I >= PlyL:count()){
PlayerList:pushEntity(HS)  
hint("* Player "+HS:name()+" Joined the Game! *",7) 
E:soundPlay(1,0,"/ui/trade_success.wav") 
}

}
   
}



interval(100)

if(first() | duped())
{
runOnChat(1)
    
GTABLE = gTable("expressware",2) 
O = owner() 
E = entity()
}

if(GTABLE["Find",number] & changed(GTABLE["Find",number]))
{
E:soundPlay(1,0,"/ui/duel_event.wav")    
}


if(GTABLE["Find",number] == 1){
if(chatClk()){
Chat = lastSaid():explode(" ")
Ply = lastSpoke()

if(Chat[1,string] == "-join"){
findPly(Ply)
}

}
    
}
 

findByClass("player")
PlyL = findToArray()


if(GTABLE["Send",number] == 1){
GTABLE["playerlist",array] = PlayerList #Send the List and clean it
GTABLE["Send",number] = 0 ## reset all
hint("[DEBUG] PlayerList Sended",7)
}


if(GTABLE["Music",number]){
GTABLE["Music",number] = 0
Music = GTABLE["Musics",array]
E:soundPlay(2,0,Music[randint(1,Music:count()),string])      
}
