local mysql = exports.mysql  local scriptVer = exports.global:getScriptVersion()  local salt = "vgrpkeyscotland"     -- Gay beta code  local hasBeta = { }     function UserAccountLoggedOut()      exports['anticheat-system']:changeProtectedElementDataEx(client, "gameaccountloggedin", 0, true)  end  addEvent("account:loggedout", true)  addEventHandler("account:loggedout", getRootElement(), UserAccountLoggedOut)     function UserLoggedOut()      exports['anticheat-system']:changeProtectedElementDataEx(source, "loggedin", 0, true)  end  addEvent("player:loggedout", true)  addEventHandler("player:loggedout", getRootElement(), UserLoggedOut)     function UserLoggedOutAll()      exports['anticheat-system']:changeProtectedElementDataEx(client, "loggedin", 0, true)      exports['anticheat-system']:changeProtectedElementDataEx(client, "gameaccountloggedin", 0, true)  end  addEvent("accountplayer:loggedout", true)  addEventHandler("accountplayer:loggedout", getRootElement(), UserLoggedOutAll)     function informServerHasBeta()      hasBeta[client] = false  end  addEvent("hasBeta", true)  addEventHandler("hasBeta", getRootElement(), informServerHasBeta)     function beta(thePlayer)      if ( exports.global:isPlayerAdmin(thePlayer)) then          local count = 0          for k,v in pairs(hasBeta) do              count = count + 1          end          exports.global:sendMessageToAdmins("> " .. count .. " people are running Sapphire Beta.")      end  end  addCommandHandler("beta", beta)     function playerQuit()      hasBeta[source] = nil  end  addEventHandler("onPlayerQuit", getRootElement(), playerQuit)     function acceptBeta()      redirectPlayer(client, "temp.chuevo.com", getServerPort(), getServerPassword())  end  addEvent("acceptBeta", true)  addEventHandler("acceptBeta", getRootElement(), acceptBeta)  -- end gay beta code     function sendSalt()      triggerClientEvent(client, "sendSalt", source, salt, getPlayerIP(source), getElementData(getRootElement(), "account:motd"))  end  addEvent("getSalt", true)  addEventHandler("getSalt", getRootElement(), sendSalt)     function encrypt(str)      local hash = 0      for i = 1, string.len(str) do          hash = hash + tonumber(string.byte(str, i, i))      end            if (hash==0) then          return 0      end      hash = hash + 100000000      return hash  end     function encryptSerial(str)      local hash = md5(str)      local rhash = "VGRP" .. string.sub(hash, 17, 20) .. string.sub(hash, 1, 2) .. string.sub(hash, 25, 26) .. string.sub(hash, 21, 2)      return rhash  end     function resourceStart(resource)      setGameType("Roleplay")      setMapName("Cylus RP: Los Santos")      setRuleValue("Script Version", tostring(scriptVer))      setRuleValue("Author", "Cylus Scripting Team")            local motdresult = mysql:query_fetch_assoc("SELECT value FROM settings WHERE name='motd' LIMIT 1")      exports['anticheat-system']:changeProtectedElementDataEx(getRootElement(), "account:motd", motdresult["value" ], false )      local amotdresult = mysql:query_fetch_assoc("SELECT value FROM settings WHERE name='amotd' LIMIT 1")      exports['anticheat-system']:changeProtectedElementDataEx(getRootElement(), "account:amotd", amotdresult["value" ], false )         for key, value in ipairs(exports.pool:getPoolElementsByType("player")) do          triggerEvent("playerJoinResourceStart", value, resource)      end  end  addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), resourceStart)        function onJoin()      -- Set the user as not logged in, so they can't see chat or use commands      exports['anticheat-system']:changeProtectedElementDataEx(source, "loggedin", 0)      exports['anticheat-system']:changeProtectedElementDataEx(source, "gameaccountloggedin", 0, false)      exports['anticheat-system']:changeProtectedElementDataEx(source, "gameaccountusername", "")      exports['anticheat-system']:changeProtectedElementDataEx(source, "gameaccountid", "")      exports['anticheat-system']:changeProtectedElementDataEx(source, "dbid", false)      exports['anticheat-system']:changeProtectedElementDataEx(source, "adminlevel", 0)      exports['anticheat-system']:changeProtectedElementDataEx(source, "hiddenadmin", 0)      exports['anticheat-system']:changeProtectedElementDataEx(source, "globalooc", 1, false)      exports['anticheat-system']:changeProtectedElementDataEx(source, "muted", 0)      exports['anticheat-system']:changeProtectedElementDataEx(source, "loginattempts", 0, false)      exports['anticheat-system']:changeProtectedElementDataEx(source, "timeinserver", 0, false)      setElementDimension(source, 9999)      setElementInterior(source, 0)      clearChatBox(source)      exports.global:updateNametagColor(source)  end  addEventHandler("onPlayerJoin", getRootElement(), onJoin)  addEvent("playerJoinResourceStart", false)  addEventHandler("playerJoinResourceStart", getRootElement(), onJoin)     addEvent("restoreJob", false)  function spawnCharacter(charname, version)      exports.global:takeAllWeapons(client)      exports.global:takeAllWeapons(source)      takeAllWeapons(source)      takeAllWeapons(client)      source = client            local id = getElementData(client, "gameaccountid")      charname = string.gsub(tostring(charname), " ", "_")            local safecharname = mysql:escape_string(charname)            local data = mysql:query_fetch_assoc("SELECT * FROM characters WHERE charactername='" .. safecharname .. "' AND account='" .. mysql:escape_string(id) .. "' AND cked = 0")            if (data) then          local id = tonumber(data["id"])          local currentid = getElementData(source, "dbid")          if hasBeta[source] then              if id == currentid then                  return              elseif currentid then                  triggerEvent("savePlayer", source, "Change Character", source)              end          end                    for key, value in ipairs(getElementsByType("player")) do              if ( getElementData(value, "loggedin") == 1 and value ~= source and hasBeta[value] ) then                  triggerClientEvent(value, "onPlayerCharacterChange", source, charname)              end          end                    local x = tonumber(data["x"])          local y = tonumber(data["y"])          local z = tonumber(data["z"])                    local rot = tonumber(data["rotation"])          local interior = tonumber(data["interior_id"])          local dimension = tonumber(data["dimension_id"])          local health = tonumber(data["health"])          local armor = tonumber(data["armor"])          local skin = tonumber(data["skin"])          setPedSkin(source, skin)                    local money = tonumber(data["money"])          local factionID = tonumber(data["faction_id"])          local cuffed = tonumber(data["cuffed"])          local radiochannel = tonumber(data["radiochannel"])          local masked = tonumber(data["masked"])          local duty = tonumber(data["duty"])          local cellnumber = tonumber(data["cellnumber"])          local fightstyle = tonumber(data["fightstyle"])          local pdjail = tonumber(data["pdjail"])          local pdjail_time = tonumber(data["pdjail_time"])          local pdjail_station = tonumber(data["pdjail_station"])          local job = tonumber(data["job"])          local casualskin = tonumber(data["casualskin"])          local weapons = tostring(data["weapons"])          local ammo = tostring(data["ammo"])          local carlicense = tonumber(data["car_license"])          local gunlicense = tonumber(data["gun_license"])          local bankmoney = tonumber(data["bankmoney"])          local fingerprint = tostring(data["fingerprint"])          local tag = tonumber(data["tag"])          local hoursplayed = tonumber(data["hoursplayed"])          local timeinserver = tonumber(data["timeinserver"])          local restrainedobj = tonumber(data["restrainedobj"])          local restrainedby = tonumber(data["restrainedby"])          local factionrank = tonumber(data["faction_rank"])          local dutyskin = tonumber(data["dutyskin"])          local phoneoff = tonumber(data["phoneoff"])          local blindfold = tonumber(data["blindfold"])          local gender = tonumber(data["gender"])          local cellphonesecret = tonumber(data["cellphonesecret"])          local photos = tonumber(data["photos"])                    local age = data["age"]          local race = tonumber(data["skincolor"])          local weight = data["weight"]          local height = data["height"]          local desc = data["description"]          local maxvehicles = tonumber(data["maxvehicles"])          local factionleader = tonumber(data["faction_leader"])          local d_addiction = tostring(data["d_addiction"])                    exports['anticheat-system']:changeProtectedElementDataEx(source, "chardescription", desc)          exports['anticheat-system']:changeProtectedElementDataEx(source, "age", age)          exports['anticheat-system']:changeProtectedElementDataEx(source, "weight", weight)          exports['anticheat-system']:changeProtectedElementDataEx(source, "height", height)          exports['anticheat-system']:changeProtectedElementDataEx(source, "race", race)          exports['anticheat-system']:changeProtectedElementDataEx(source, "maxvehicles", maxvehicles)                    -- LANGUAGES          local lang1 = tonumber(data["lang1"])          local lang1skill = tonumber(data["lang1skill"])          local lang2 = tonumber(data["lang2"])          local lang2skill = tonumber(data["lang2skill"])          local lang3 = tonumber(data["lang3"])          local lang3skill = tonumber(data["lang3skill"])          local currentLanguage = tonumber(data["currlang"])          exports['anticheat-system']:changeProtectedElementDataEx(source, "languages.current", currentLanguage, false)                            if lang1 == 0 then              lang1skill = 0          end                    if lang2 == 0 then              lang2skill = 0          end                    if lang3 == 0 then              lang3skill = 0          end                    exports['anticheat-system']:changeProtectedElementDataEx(source, "languages.lang1", lang1, false)          exports['anticheat-system']:changeProtectedElementDataEx(source, "languages.lang1skill", lang1skill, false)                    exports['anticheat-system']:changeProtectedElementDataEx(source, "languages.lang2", lang2, false)          exports['anticheat-system']:changeProtectedElementDataEx(source, "languages.lang2skill", lang2skill, false)                    exports['anticheat-system']:changeProtectedElementDataEx(source, "languages.lang3", lang3, false)          exports['anticheat-system']:changeProtectedElementDataEx(source, "languages.lang3skill", lang3skill, false)          -- END OF LANGUAGES                    exports['anticheat-system']:changeProtectedElementDataEx(source, "timeinserver", timeinserver, false)                    exports['anticheat-system']:changeProtectedElementDataEx(source, "dbid", tonumber(id))          exports['item-system']:loadItems( source, true )                    exports['anticheat-system']:changeProtectedElementDataEx(source, "loggedin", 1)                    -- Check his name isn't in use by a squatter          local playerWithNick = getPlayerFromName(tostring(charname))