@name Hunger Games E2
@inputs 
@outputs 
@persist Players:array
@trigger 
runOnChat(1)

U = lastSpoke()
S = U:lastSaid()

#Defines GameMaster / Leader
GameMaster = findPlayerByName("Banter")
#=============================================================================
#Allows player registering
if(S == "Register"+S:sub(9)){
    if(Players:exists(4) == 0){
    Players:pushString(U:name())
    concmd("say Added tribute! "+U:name())
}
else{
    if(Players:exists(4) == 1){
        print("Denied")
        concmd("say Sorry! User slots are full!")
    }
}
}

if(S == "register"+S:sub(9)){
    if(Players:exists(4) == 0){
    Players:pushString(U:name())
    concmd("say Added tribute! "+U:name())
}
else{
    if(Players:exists(4) == 1){
        print("Denied")
        concmd("say Sorry! User slots are full!")
    }
}
}
#=============================================================================
#Prints players list (Used to check for errors)
if(GameMaster:lastSaid() == "-s"){
    print(Players)
}
#=============================================================================
#Seperates players into a single string
A = Players[1,string]
B = Players[2,string]
C = Players[3,string]
D = Players[4,string]
#=============================================================================
#Takes the single string from above to find their entity
AN = findPlayerByName(A)
BN = findPlayerByName(B)
CN = findPlayerByName(C)
DN = findPlayerByName(D)
#=============================================================================
#Checks if Player is dead or not
if(AN:isAlive() == 0){
    concmd("say | HUNGER GAMES TRIBUTE | "+A+" has died!")
}
else{
    
}
if(BN:isAlive() == 0){
    concmd("say | HUNGER GAMES TRIBUTE | "+B+" has died!")
}
else{
    
}
if(CN:isAlive() == 0){
    concmd("say | HUNGER GAMES TRIBUTE | "+C+" has died!")
}
else{
    
}
if(DN:isAlive() == 0){
    concmd("say | HUNGER GAMES TRIBUTE | "+D+" has died!")
}
else{
    
}
#=============================================================================
#Game Master's clear (stop) and start commands
if(GameMaster:lastSaid() == "-clear"){
    Players = array()
    concmd("say Tributes list cleared! New game starting soon!")
    hint("Starting waiting your approval!",5)
}

if(GameMaster:lastSaid() == "-start"){
    concmd("say | HUNGER GAMES | has started! Type register to join!")
    hint("Hunger games started!",5)
}

if(GameMaster:lastSaid() == "-begin"){
    concmd("say The hunger games have begun!")
    hint("Begun",5)
    if(S == "register"){
        concmd("say sorry, it has already begun!")
    }
}
#=============================================================================
