@name Event Joiner + Commands
@persist Name:string Job:string Scale Pos:vector Enabled
@persist CSS:array Hl2:array Given:array
@persist Lock

function void printCommands(){
    print("COMMANDS")
    print("Created by Jim Dangle")
    print("Type /title + (title you want), this sets what players have to type to join")
    print("Example /title russian makes it so people have to type /russian to join")
    print("Type /req + (job), to make a specific job required")
    print("Example /req Blood Gangster, if the player is a blood they can join")
    print("Type /space + Number, this will increase the radius players are spawned in")
    print("WARNING: the spacing is 10*Scale so if you put space 100 it will be a radius of 1000")
    print("Type /disable or /enable to disable or enable the required job")
    print("Type /lock to finalize your chip so you can place more down")
    }


runOnChat(1)

if(first() | duped()){
    
    Enabled = 0
    #These are all listed in order in lordis css weapons so you can just count there
    CSS = array("weapon_lordi_wep_ak47", "weapon_lordi_wep_aug", "weapon_lordi_wep_awp", "weapon_lordi_wep_c4", "weapon_lordi_wep_deagle", "weapon_lordi_wep_elite", "weapon_lordi_wep_famas", "weapon_lordi_wep_flashbang" ,"weapon_lordi_wep_57","weapon_lordi_wep_g3","weapon_lordi_wep_glock","weapon_lordi_wep_galil","weapon_lordi_wep_knife","weapon_lordi_wep_m249","weapon_lordi_wep_m3","weapon_lordi_wep_m4a1","weapon_lordi_wep_mac10","weapon_lordi_wep_mp5","weapon_lordi_wep_p228","weapon_lordi_wep_p90","weapon_lordi_wep_scout","weapon_lordi_wep_sg550","weapon_lordi_wep_sg552","weapon_lordi_wep_tmp","weapon_lordi_wep_ump","weapon_lordi_wep_usp","weapon_lordi_wep_xm1014")
    #HL2 Weapons are supper buggy dont use
    #HL2 = array("weapon_357", "weapon_ar2" , "weapon_crossbow" , "weapon_crowbar" ,"weapon_pistol","weapon_rpg","weapon_shotgun","weapon_smg1","weapon_stunstick")
    Given = array(CSS[24, string], CSS[13, string], CSS[11, string])
    
    hint("type /help to view commands", 3)
    }


function void giveWeapons(Ent:entity){
    #Ent:stripWeapons()
    for(I=1, Given:count()){
    #    Ent:give(Given[I, string])
        }
    #Ent:setAmmo(10000,"SMG1")
    #Ent:setAmmo(10000,"Buckshot")
    #Ent:setAmmo(10000,"Pistol")

    } 
if(Lock!=1){
if(chatClk(owner())){
    Chat = owner():lastSaid():explode(" ")
    if(Chat:string(1):upper()=="/TITLE"){
        hideChat(1)
        Name = Chat:string(2)
        }
    if(Chat:string(1):upper()=="/REQ"){
        hideChat(1)
        Job = owner():lastSaid():sub(6)
        
        }
    if(Chat:string(1):upper()=="/SPACE"){
        hideChat(1)
        Scale = Chat:string(2):toNumber()
        }
    Pos = entity():pos()+vec(randint(10*Scale),randint(10*Scale), 3)
    
    if(Chat:string(1):upper()=="/HELP"){
        hideChat(1)
        printCommands()
        }
    if(Chat:string(1):upper()=="/ENABLE"){
        hideChat(1)
        hint("Required Job has been enabled", 3)
        Enabled = 1
        }
    if(Chat:string(1):upper()=="/DISABLE"){
        hideChat(1)
        hint("Required Job has been disabled",3)
        Enabled = 0
        }
    if(Chat:string(1):upper()=="/LOCK"){
        hideChat(1)
        Lock=1
        hint("Lock is: "+Lock, 4)
        }
    }
}


if(first() | duped()){
    if(Name==""){
    Name = "join"
    }
    if(Job==""){
    Job="Citizen"
    }
}


if(Enabled==1){
if(chatClk(lastSpoke()) & lastSpoke():team():teamName()==Job){
    
    CC = lastSpoke():lastSaid():explode(" ")
    if(CC:string(1):upper()=="/"+Name:upper()){
        lastSpoke():teleport(Pos)
        giveWeapons(lastSpoke())
        }
    }
}
elseif(chatClk(lastSpoke())){
    CC1 = lastSpoke():lastSaid():explode(" ")
    if(CC1:string(1):upper()=="/"+Name:upper()){
        lastSpoke():teleport(Pos)
        giveWeapons(lastSpoke())
        }
    }
