Advertisement
Guest User

Untitled

a guest
Jun 27th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.65 KB | None | 0 0
  1. local connection = exports['cr_mysql']:getConnection(getThisResource())
  2. addEventHandler("onResourceStart", root,
  3. function(startedRes)
  4. if getResourceName(startedRes) == "cr_mysql" then
  5. connection = exports['cr_mysql']:getConnection(getThisResource())
  6. restartResource(getThisResource())
  7. end
  8. end
  9. )
  10.  
  11. Async:setPriority("high")
  12. Async:setDebug(true)
  13.  
  14. local accounts = {}
  15. --[[
  16. Tábla felépítése:
  17. accounts[name] = {id, password, serial, email, regdate, lastlogin, ip}
  18. ]]
  19. local isSerialAttachedToAccount = {}
  20. --[[
  21. Tábla felépítése:
  22. isSerialAttachedToAccount[serial] = true
  23. ]]
  24. local isEmailAttachedToAccount = {}
  25. --[[
  26. Tábla felépítése:
  27. isEmailAttachedToAccount[email] = true
  28. ]]
  29. local idConvertToName = {}
  30. --[[
  31. Tábla felépítése:
  32. idConvertToName[id] = name
  33. ]]
  34. local isValidAccount = {}
  35. --[[
  36. Tábla felépítése:
  37. isValidAccount[name] = name
  38. ]]
  39. local isLogged = {}
  40. --[[
  41. Tábla felépítése:
  42. isLogged[name] = true
  43. ]]
  44.  
  45. local characters = {}
  46. --[[
  47. Tábla felépítése:
  48. characters[id] = {...}
  49. ]]
  50. local getAccountCharacterID = {}
  51. --[[
  52. Tábla felépítése:
  53. getAccountCharacterID[accountName] = id
  54. ]]
  55. local isAccountHaveCharacter = {}
  56. --[[
  57. Tábla felépítése:
  58. isAccountHaveCharacter[accountName] = true
  59. ]]
  60. local isNameRegistered = {}
  61. --[[
  62. Tábla felépítése:
  63. isAccountHaveCharacter[charname] = true
  64. ]]
  65.  
  66. function receiveTables()
  67. --triggerClientEvent(root, "giveBackToClient", root, accounts, characters)
  68. end
  69. addEvent("receiveTables", true)
  70. addEventHandler("receiveTables", root, receiveTables)
  71.  
  72. local version = "1.5.4"
  73.  
  74. addEventHandler("onResourceStart", resourceRoot,
  75. function()
  76. dbQuery(function(query)
  77. local query, query_lines = dbPoll(query, 0)
  78. if query_lines > 0 then
  79. --for i, row in pairs(query) do
  80. Async:foreach(query, function(row)
  81. local id = tonumber(row["id"])
  82. local name = tostring(row["name"])
  83. local email = tostring(row["email"])
  84. local password = tostring(row["password"])
  85. local serial = tostring(row["serial"])
  86. local ip = tostring(row["ip"])
  87. local registerdatum = tostring(row["registerdatum"])
  88. local lastlogin = tostring(row["lastlogin"])
  89. local online = tonumber(row["online"])
  90. if online == 1 then
  91. isLogged[name] = true
  92. else
  93. isLogged[name] = false
  94. end
  95. accounts[name] = {id, password, serial, email, registerdatum, lastlogin, ip}
  96. --isLogged[name] = false
  97. isValidAccount[name] = true
  98. isSerialAttachedToAccount[serial] = true
  99. isEmailAttachedToAccount[email] = true
  100. idConvertToName[id] = name
  101. end)
  102. end
  103. receiveTables()
  104. outputDebugString("[Success] Loading accounts has finished successfuly. Loaded: " .. query_lines .. " accounts!")
  105. end, connection, "SELECT * FROM `accounts`")
  106. end
  107. )
  108.  
  109. local salt = "LuxyMTA"
  110.  
  111. addEventHandler("onResourceStart", resourceRoot,
  112. function()
  113. dbQuery(function(query)
  114. local query, query_lines = dbPoll(query, 0)
  115. if query_lines > 0 then
  116. --for i, row in pairs(query) do
  117. Async:foreach(query, function(row)
  118. local id = tonumber(row["id"])
  119. local ownerName = tostring(row["ownerAccountName"])
  120. local charname = tostring(row["charname"])
  121. local position = tostring(row["position"])
  122. local health = tonumber(row["health"])
  123. local armor = tonumber(row["armor"])
  124. local skinid = tonumber(row["skinid"])
  125. local pedType = tostring(row["pedType"])
  126. local pedType2 = tostring(row["pedType2"])
  127. local age = tonumber(row["age"])
  128. local weight = tonumber(row["weight"])
  129. local height = tonumber(row["height"])
  130. local fightStyle = tonumber(row["fightStyle"])
  131. local walkStyle = tonumber(row["walkStyle"])
  132. local money = tonumber(row["money"])
  133. local bankmoney = tonumber(row["bankmoney"])
  134. local death = tostring(row["death"])
  135. local headless = tostring(row["headless"])
  136. local playedtime = tonumber(row["playedtime"])
  137. local premiumPoints = tonumber(row["premiumPoints"])
  138. local adminlevel = tonumber(row["adminlevel"])
  139. local job = tonumber(row["job"])
  140. local rot = tonumber(row["rot"])
  141. local adminduty = tostring(row["adminduty"])
  142. local food = tostring(row["food"])
  143. local drink = tostring(row["drink"])
  144. local adminname = tostring(row["adminname"])
  145. local level = tonumber(row["level"])
  146. local deathReasons = tostring(row["deathReasons"])
  147. local bone = tostring(row["bone"])
  148. local adutytime = tonumber(row["adutytime"])
  149. local rtc = tonumber(row["rtc"])
  150. local fix = tonumber(row["fix"])
  151. local fuel = tonumber(row["fuel"])
  152. local ban = tonumber(row["ban"])
  153. local jail = tonumber(row["jail"])
  154. local kick = tonumber(row["kick"])
  155. local ajail = tostring(row["adminJail"])
  156. characters[id] = {
  157. ["ownerName"] = ownerName,
  158. ["charName"] = charname,
  159. ["position"] = position,
  160. ["health"] = health,
  161. ["armor"] = armor,
  162. ["skinid"] = skinid,
  163. ["pedType"] = pedType,
  164. ["pedType2"] = pedType2,
  165. ["age"] = age,
  166. ["weight"] = weight,
  167. ["height"] = height,
  168. ["fightStyle"] = fightStyle,
  169. ["walkStyle"] = walkStyle,
  170. ["money"] = money,
  171. ["bankmoney"] = bankmoney,
  172. ["death"] = death,
  173. ["headless"] = headless,
  174. ["playedtime"] = playedtime,
  175. ["premiumPoints"] = premiumPoints,
  176. ["adminlevel"] = adminlevel,
  177. ["job"] = job,
  178. ["rot"] = rot,
  179. ["adminduty"] = adminduty,
  180. ["food"] = food,
  181. ["drink"] = drink,
  182. ["adminname"] = adminname,
  183. ["level"] = level,
  184. ["deathReasons"] = deathReasons,
  185. ["bone"] = bone,
  186. ["adutytime"] = adutytime,
  187. ["rtc"] = rtc,
  188. ["fix"] = fix,
  189. ["fuel"] = fuel,
  190. ["jail"] = jail,
  191. ["ban"] = ban,
  192. ["kick"] = kick,
  193. ["adminjail"] = ajail,
  194. }
  195. getAccountCharacterID[ownerName] = id
  196. isAccountHaveCharacter[ownerName] = true
  197. isNameRegistered[charname] = true
  198. end)
  199. end
  200. receiveTables()
  201. outputDebugString("[Success] Loading characters has finished successfuly. Loaded: " .. query_lines .. " characters!")
  202. end, connection, "SELECT * FROM `characters`")
  203. end
  204. )
  205.  
  206. addEvent("account >> register", true)
  207. addEventHandler("account >> register", root,
  208. function(sourceElement, username, password, email, serial)
  209. if isSerialAttachedToAccount[serial] then
  210. exports['cr_infobox']:addBox(sourceElement, "error", "Ez a serial ("..serial..") már társítva van egy felhasználóhoz!")
  211. return
  212. end
  213.  
  214. if isEmailAttachedToAccount[email] then
  215. exports['cr_infobox']:addBox(sourceElement, "error", "Ez az email ("..email..") már társítva van egy felhasználóhoz!")
  216. return
  217. end
  218.  
  219. if isValidAccount[username] then
  220. exports['cr_infobox']:addBox(sourceElement, "error", "Ez a felhasználónév ("..username..") már regisztrálva lett!")
  221. return
  222. end
  223.  
  224. local hashPassword1 = hash("md5", username .. password .. username)
  225. local hashedPassword = hash("sha512", salt .. hashPassword1 .. salt)
  226. local ip = getPlayerIP(sourceElement)
  227.  
  228. dbExec(connection, "INSERT INTO `accounts` SET `name` = ?, `email` = ?, `password` = ?, `serial` = ?, `ip` = ?, `registerdatum` = NOW(), `lastlogin` = NOW()", username, email, hashedPassword, serial, ip)
  229.  
  230. dbQuery(function(query)
  231. local query, query_lines = dbPoll(query, 0)
  232. if query_lines > 0 then
  233. --for i, row in pairs(query) do
  234. Async:foreach(query, function(row)
  235. local id = tonumber(row["id"])
  236. local name = tostring(row["name"])
  237. local email = tostring(row["email"])
  238. local password = tostring(row["password"])
  239. local serial = tostring(row["serial"])
  240. local ip = tostring(row["ip"])
  241. local registerdatum = tostring(row["registerdatum"])
  242. local lastlogin = tostring(row["lastlogin"])
  243. accounts[name] = {id, password, serial, email, registerdatum, lastlogin, ip}
  244. isValidAccount[name] = true
  245. isSerialAttachedToAccount[serial] = true
  246. isEmailAttachedToAccount[email] = true
  247. idConvertToName[id] = name
  248. exports['cr_infobox']:addBox(sourceElement, "success", "Sikeres regisztráció most már beléphetsz!")
  249. end)
  250. receiveTables()
  251. end
  252. end, connection, "SELECT * FROM `accounts` WHERE `name` = ?", username)
  253. end
  254. )
  255.  
  256. addEvent("account >> login", true)
  257. addEventHandler("account >> login", root,
  258. function(sourceElement, username, password)
  259. if not isValidAccount[username] then
  260. exports['cr_infobox']:addBox(sourceElement, "error", "Ez a felhasználónév ("..username..") nincs regisztrálva!")
  261. return
  262. end
  263.  
  264. if isLogged[username] then
  265. exports['cr_infobox']:addBox(sourceElement, "error", "Ez a felhasználó ("..username..") már használatban van!")
  266. return
  267. end
  268.  
  269. local data = accounts[username]
  270. local id = data[1]
  271. local realPassword = data[2]
  272. local serial = data[3]
  273. local lastlogin = data[6]
  274. local registerdatum = data[5]
  275. local mtaserial = getElementData(sourceElement, "mtaserial")
  276.  
  277. if string.lower(serial) ~= string.lower(mtaserial) then
  278. if tonumber(serial) == "0" or tonumber(serial) == 0 then -- Serial váltás
  279. dbExec(connection, "UPDATE `accounts` SET `serial`=? WHERE `id`=?", mtaserial, id)
  280. accounts[username][3] = mtaserial
  281. else
  282. exports['cr_infobox']:addBox(sourceElement, "error", "A te serialod nem ehhez a felhasználóhoz van társítva!")
  283. return
  284. end
  285. end
  286.  
  287. local hashedPassword = hash("md5", username .. password .. username)
  288. local hashedPassword2 = hash("sha512", salt .. hashedPassword .. salt)
  289.  
  290. if string.lower(realPassword) ~= string.lower(hashedPassword2) then
  291. exports['cr_infobox']:addBox(sourceElement, "error", "Hibás jelszó!")
  292. return
  293. end
  294.  
  295. isLogged[username] = true
  296.  
  297. --local lastlogin = accounts[username][6]
  298. --local regdatum = accounts[username][5]
  299.  
  300. dbExec(connection, "UPDATE `accounts` SET `lastlogin`=NOW(), `online`=? WHERE `id`=?", 1, id)
  301. dbQuery(function(query)
  302. local query, query_lines = dbPoll(query, 0)
  303. if query_lines > 0 then
  304. --for i, row in pairs(query) do
  305. Async:foreach(query, function(row)
  306. local lastlogin = tostring(row["lastlogin"])
  307. accounts[username][6] = lastlogin
  308. end)
  309. receiveTables()
  310. end
  311. end, connection, "SELECT `lastlogin` FROM `accounts` WHERE `id` = ?", id)
  312.  
  313. --PP Update
  314. dbQuery(function(query)
  315. local query, query_lines = dbPoll(query, 0)
  316. if query_lines > 0 then
  317. --for i, row in pairs(query) do
  318. Async:foreach(query, function(row)
  319. local premiumPoints = tostring(row["premiumPoints"])
  320. characters[id]["premiumPoints"] = premiumPoints
  321. end)
  322. receiveTables()
  323. end
  324. end, connection, "SELECT `premiumPoints` FROM `characters` WHERE `id` = ?", id)
  325.  
  326. setElementData(sourceElement, "acc >> loggedIn", true)
  327. setElementData(sourceElement, "acc >> id", id)
  328. setElementData(sourceElement, "acc >> username", username)
  329.  
  330. if isAccountHaveCharacter[username] then
  331. --Betöltés
  332. local id = getAccountCharacterID[username]
  333. local data = characters[id]
  334. triggerClientEvent(sourceElement, "character >> loading", sourceElement, data, lastlogin, id, registerdatum)
  335. else
  336. --Karakter létrehozása
  337. triggerClientEvent(sourceElement, "character >> create", sourceElement)
  338. end
  339. end
  340. )
  341.  
  342. addEvent("character >> register", true)
  343. addEventHandler("character >> register", root,
  344. function(sourceElement, name, age, weight, height, skinid, pedType, pedType2)
  345. if isNameRegistered[name] then
  346. exports['cr_infobox']:addBox(sourceElement, "error", "Ez a név már használatban van!")
  347. return
  348. end
  349.  
  350. local id = getElementData(sourceElement, "acc >> id")
  351. local username = getElementData(sourceElement, "acc >> username")
  352.  
  353. dbExec(connection, "INSERT INTO `characters` SET `id` = ?, `ownerAccountName` = ?, `charname` = ?, `age` = ?, `weight` = ?, `height` = ?, `skinid` = ?, `pedType` = ?, `pedType2` = ?", id, username, name, age, weight, height, skinid, pedType, pedType2)
  354.  
  355. dbQuery(function(query)
  356. local query, query_lines = dbPoll(query, 0)
  357. if query_lines > 0 then
  358. --for i, row in pairs(query) do
  359. Async:foreach(query, function(row)
  360. local id = tonumber(row["id"])
  361. local ownerName = tostring(row["ownerAccountName"])
  362. local charname = tostring(row["charname"])
  363. local position = tostring(row["position"])
  364. local health = tonumber(row["health"])
  365. local armor = tonumber(row["armor"])
  366. local skinid = tonumber(row["skinid"])
  367. local pedType = tostring(row["pedType"])
  368. local pedType2 = tostring(row["pedType2"])
  369. local age = tonumber(row["age"])
  370. local weight = tonumber(row["weight"])
  371. local height = tonumber(row["height"])
  372. local fightStyle = tonumber(row["fightStyle"])
  373. local walkStyle = tonumber(row["walkStyle"])
  374. local money = tonumber(row["money"])
  375. local bankmoney = tonumber(row["bankmoney"])
  376. local death = tostring(row["death"])
  377. local headless = tostring(row["headless"])
  378. local playedtime = tonumber(row["playedtime"])
  379. local premiumPoints = tonumber(row["premiumPoints"])
  380. local adminlevel = tonumber(row["adminlevel"])
  381. local job = tonumber(row["job"])
  382. local rot = tonumber(row["rot"])
  383. local adminduty = tostring(row["adminduty"])
  384. local adminname = tostring(row["adminname"])
  385. local food = tostring(row["food"])
  386. local drink = tostring(row["drink"])
  387. local level = tonumber(row["level"])
  388. local deathReasons = tostring(row["deathReasons"])
  389. local bone = tostring(row["bone"])
  390. local adutytime = tonumber(row["adutytime"])
  391. local rtc = tonumber(row["rtc"])
  392. local fix = tonumber(row["fix"])
  393. local fuel = tonumber(row["fuel"])
  394. local ban = tonumber(row["ban"])
  395. local jail = tonumber(row["jail"])
  396. local kick = tonumber(row["kick"])
  397. local ajail = tonumber(row["adminJail"])
  398. characters[id] = {
  399. ["ownerName"] = ownerName,
  400. ["charName"] = charname,
  401. ["position"] = position,
  402. ["health"] = health,
  403. ["armor"] = armor,
  404. ["skinid"] = skinid,
  405. ["pedType"] = pedType,
  406. ["pedType2"] = pedType2,
  407. ["age"] = age,
  408. ["weight"] = weight,
  409. ["height"] = height,
  410. ["fightStyle"] = fightStyle,
  411. ["walkStyle"] = walkStyle,
  412. ["money"] = money,
  413. ["bankmoney"] = bankmoney,
  414. ["death"] = death,
  415. ["headless"] = headless,
  416. ["playedtime"] = playedtime,
  417. ["premiumPoints"] = premiumPoints,
  418. ["adminlevel"] = adminlevel,
  419. ["job"] = job,
  420. ["rot"] = rot,
  421. ["adminduty"] = adminduty,
  422. ["food"] = food,
  423. ["drink"] = drink,
  424. ["adminname"] = adminname,
  425. ["level"] = level,
  426. ["deathReasons"] = deathReasons,
  427. ["bone"] = bone,
  428. ["adutytime"] = adutytime,
  429. ["rtc"] = rtc,
  430. ["fix"] = fix,
  431. ["fuel"] = fuel,
  432. ["jail"] = jail,
  433. ["ban"] = ban,
  434. ["kick"] = kick,
  435. ["adminjail"] = ajail,
  436. }
  437. getAccountCharacterID[ownerName] = id
  438. isAccountHaveCharacter[ownerName] = true
  439. isNameRegistered[charname] = true
  440. local data = accounts[ownerName]
  441. local lastlogin = data[6]
  442. local registerdatum = data[5]
  443. exports['cr_infobox']:addBox(sourceElement, "success", "Sikeres karakterregisztráció most már beléphetsz!")
  444. triggerClientEvent(sourceElement, "destroyCharCreate", sourceElement)
  445. local data = characters[id]
  446. triggerClientEvent(sourceElement, "character >> loading", sourceElement, data, lastlogin, id, registerdatum)
  447. end)
  448. receiveTables()
  449. end
  450. end, connection, "SELECT * FROM `characters` WHERE `id` = ?", id)
  451. end
  452. )
  453.  
  454. local isValid = {
  455. ["needSpawn"] = true,
  456. ["char >> skin"] = true,
  457. ["char >> fightStyle"] = true,
  458. ["char >> walkStyle"] = true,
  459. ["char >> death"] = true,
  460. ["char >> headless"] = true,
  461. ["char >> name"] = true,
  462. ["char >> armor"] = true,
  463. ["char >> death"] = true,
  464. }
  465.  
  466. addEventHandler("onElementDataChange", root,
  467. function(dName, oValue)
  468. if getElementType(source) == "player" and isValid[dName] then
  469. if dName == "needSpawn" then
  470. local value = getElementData(source, dName)
  471. if value then
  472. local x,y,z, dim, int = unpack(getElementData(source, "char >> position"))
  473. local rot = getElementData(source, "char >> rot")
  474. local skinid = getElementData(source, "char >> skin")
  475. setElementModel(source, skinid)
  476. setElementRotation(source, 0,0,rot)
  477. setElementDimension(source, dim)
  478. setElementInterior(source, int)
  479. setElementPosition(source, x, y, z)
  480. spawnPlayer(source, x,y,z, rot, skinid, int, dim)
  481. setElementHealth(source, getElementData(source, "char >> health"))
  482. setElementFrozen(source, true)
  483. local source = source
  484. setTimer(
  485. function()
  486. setElementFrozen(source, false)
  487. end, 7000, 1
  488. )
  489. end
  490. elseif dName == "char >> skin" then
  491. local value = getElementData(source, dName)
  492. setElementModel(source, value)
  493. elseif dName == "char >> fightStyle" then
  494. local value = getElementData(source, dName)
  495. setPedFightingStyle(source, value)
  496. elseif dName == "char >> walkStyle" then
  497. local value = getElementData(source, dName)
  498. setPedWalkingStyle(source, value)
  499. elseif dName == "char >> name" then
  500. local value = getElementData(source, dName)
  501. setPlayerName(source, value)
  502. local id = getElementData(source, "acc >> id")
  503. characters[id]["charName"] = value
  504. if oValue and type(oValue) == "string" then
  505. isNameRegistered[oValue] = false
  506. end
  507. isNameRegistered[value] = true
  508. receiveTables()
  509. --[[
  510. elseif dName == "char >> death" then
  511. local value = getElementData(source, "char >> death")
  512. if type(value) == "number" and value == 1 then
  513. killPed(source, source)
  514. elseif type(value) == "table" then
  515. local killer, weapon, part, stealth = unpack(value)
  516. killPed(source, killer, weapon, part, stealth)
  517. end
  518. ]]
  519. elseif dName == "char >> armor" then
  520. local value = getElementData(source, dName)
  521. setPedArmor(source, value)
  522. --[[
  523. elseif dName == "char >> death" then
  524. local value = getElementData(source, dName)
  525. if value == 1 then
  526. killPed(source)
  527. end
  528. ]]
  529. elseif dName == "char >> headless" then
  530. local value = getElementData(source, dName)
  531.  
  532. setPedHeadless(source, value)
  533. end
  534. end
  535. end
  536. )
  537.  
  538. addEventHandler("onPlayerChangeNick", root,
  539. function(oldNick, newNick)
  540. if getElementData(source, "loggedIn") then
  541. cancelEvent()
  542. end
  543. end
  544. )
  545.  
  546. addEventHandler("onPlayerQuit", root,
  547. function()
  548. savePlayer(source)
  549. end
  550. )
  551.  
  552. addEventHandler("onResourceStop", resourceRoot,
  553. function()
  554. for k,v in pairs(getElementsByType("player")) do
  555. savePlayer(v)
  556. end
  557. end
  558. )
  559.  
  560. function savePlayer(source)
  561. if getElementData(source, "acc >> loggedIn") then
  562. local id = getElementData(source, "acc >> id")
  563. dbExec(connection, "UPDATE `accounts` SET `online`=? WHERE `id`=?", 0, id)
  564. local ownerName = idConvertToName[id]
  565. isLogged[ownerName] = false
  566. end
  567. if getElementData(source, "loggedIn") then
  568. local id = getElementData(source, "acc >> id")
  569. --isLogged[username] = true
  570. local dim = getElementDimension(source)
  571. if getElementData(source, "char >> death") or getElementData(source, "inDeath") then
  572. local oldDimension = getElementData(source, "oldDimension") or getElementDimension(source)
  573. dim = oldDimension
  574. end
  575. local int = getElementInterior(source)
  576. local x,y,z = getElementPosition(source)
  577. local position = toJSON({x,y,math.floor(z + 1), dim, int})
  578. local money = getElementData(source, "char >> money")
  579. local bankmoney = getElementData(source, "char >> bankmoney")
  580. local ax, ay, rot = getElementRotation(source)
  581. local skinid = getElementData(source, "char >> skin")
  582. local fightStyle = getElementData(source, "char >> fightStyle")
  583. local walkStyle = getElementData(source, "char >> walkStyle")
  584. local charname = getElementData(source, "char >> name")
  585. local health = getElementHealth(source)
  586. local armor = getPedArmor(source)
  587. local job = getElementData(source, "char >> job")
  588. local death = tostring(getElementData(source, "char >> death"))
  589. local headless = tostring(getElementData(source, "char >> headless"))
  590. local playedtime = getElementData(source, "char >> playedtime")
  591. local premiumPoints = getElementData(source, "char >> premiumPoints")
  592. local adminlevel = getElementData(source, "admin >> level")
  593. if adminlevel == 1 then
  594. adminlevel = 0
  595. end
  596. local adminduty = "false"
  597. local adminname = tostring(getElementData(source, "admin >> name"))
  598. local food = getElementData(source, "char >> food")
  599. local drink = getElementData(source, "char >> drink")
  600. local level = getElementData(source, "char >> level")
  601. local deathReason = getElementData(source, "deathReason") or "Ismeretlen"
  602. local deathReasonAdmin = getElementData(source, "deathReason >> admin") or "Ismeretlen"
  603. local deathReasons = toJSON({deathReason, deathReasonAdmin})
  604. local bones = getElementData(source, "char >> bone") or {true, true, true, true, true}
  605. bones[1] = true
  606. local bone = toJSON(bones)
  607. local adutytime = getElementData(source, "admin >> time") or 0
  608. local rtc = getElementData(source, "rtc >> using") or 0
  609. local fix = getElementData(source, "fix >> using") or 0
  610. local fuel = getElementData(source, "fuel >> using") or 0
  611. local ban = getElementData(source, "ban >> using") or 0
  612. local jail = getElementData(source, "jail >> using") or 0
  613. local kick = getElementData(source, "kick >> using") or 0
  614. local abool = getElementData(source,"char >> ajail") or false
  615. local areason = getElementData(source,"char >> ajail >> reason") or ""
  616. local atype = getElementData(source,"char >> ajail >> type") or 0
  617. local aadmin = getElementData(source,"char >> ajail >> admin") or ""
  618. local atime = getElementData(source,"char >> ajail >> time") or 0
  619. local ajail = toJSON({abool,areason,atype,aadmin,atime})
  620. dbExec(connection, "UPDATE `characters` SET `position`=?, `charname`=?, `health`=?, `armor`=?, `skinid`=?, `fightStyle`=?, `walkStyle`=?, `money`=?, `bankmoney`=?, `death`=?, `headless`=?, `playedtime`=?, `premiumPoints`=?, `adminlevel`=?, `job`=?, `rot`=?, `adminduty`=?, `food`=?, `drink`=?, `level`=?, `adminname`=?, `deathReasons`=?, `bone`=?, `adutytime`=?, `rtc`=?, `fix`=?, `fuel`=?, `ban`=?, `jail`=?, `kick`=?, `adminJail`=? WHERE `id`=?", position, charname, health, armor, skinid, fightStyle, walkStyle, money, bankmoney, death, headless, playedtime, premiumPoints, adminlevel, job, rot, adminduty, food, drink, level, adminname, deathReasons, bone, adutytime, rtc, fix, fuel, ban, jail, kick, ajail, id)
  621. local ownerName = idConvertToName[id]
  622. characters[id] = {
  623. ["ownerName"] = ownerName,
  624. ["charName"] = charname,
  625. ["position"] = position,
  626. ["health"] = health,
  627. ["armor"] = armor,
  628. ["skinid"] = skinid,
  629. ["pedType"] = pedType,
  630. ["pedType2"] = pedType2,
  631. ["age"] = age,
  632. ["weight"] = weight,
  633. ["height"] = height,
  634. ["fightStyle"] = fightStyle,
  635. ["walkStyle"] = walkStyle,
  636. ["money"] = money,
  637. ["bankmoney"] = bankmoney,
  638. ["death"] = death,
  639. ["headless"] = headless,
  640. ["playedtime"] = playedtime,
  641. ["premiumPoints"] = premiumPoints,
  642. ["adminlevel"] = adminlevel,
  643. ["job"] = job,
  644. ["rot"] = rot,
  645. ["adminduty"] = adminduty,
  646. ["food"] = food,
  647. ["drink"] = drink,
  648. ["adminname"] = adminname,
  649. ["level"] = level,
  650. ["deathReasons"] = deathReasons,
  651. ["bone"] = bone,
  652. ["adutytime"] = adutytime,
  653. ["rtc"] = rtc,
  654. ["fix"] = fix,
  655. ["fuel"] = fuel,
  656. ["jail"] = jail,
  657. ["ban"] = ban,
  658. ["kick"] = kick,
  659. ["adminjail"] = ajail,
  660. }
  661. receiveTables()
  662. outputDebugString("[ChSave]: " .. charname .. "("..id..") - saved succesfuly!", 0, 87,255,87)
  663. end
  664. end
  665. --addEvent("savePlayer")
  666.  
  667. function getCharacterNameByID(id)
  668. if characters[id] then
  669. return characters[id]["charName"]
  670. else
  671. return "Ismeretlen"
  672. end
  673. end
  674.  
  675. function getNames(element,name)
  676. if isNameRegistered[name] then
  677. return false
  678. else
  679. setElementData(element, "char >> name", name)
  680. exports['cr_infobox']:addBox(element, "success", "Új nevet kaptál! ("..name..")")
  681. return true
  682. end
  683. end
  684.  
  685. function resetserial_sc(player,cmd,username)
  686. if exports['cr_permission']:hasPermission(player, "resetserial") then
  687. if not(username) then
  688. local syntax = exports['cr_core']:getServerSyntax(false, "warning")
  689. outputChatBox(syntax.."#ffffff /"..cmd.." [Felhasználónév]",player,0,0,0,true)
  690. else
  691. local color = exports['cr_core']:getServerColor(nil, true)
  692. local syntax = exports['cr_core']:getServerSyntax(false, "success")
  693. outputChatBox(syntax.."Sikeresen alaphelyzetbe állítottad "..color..username.."#ffffff serialját!",player,255,255,255,true)
  694. --exports['cr_core']:sendMessageToAdmin(target,color..getAdminName(player,true).."#ffffff alaphelyzetbe tette "..color..username.."#ffffff serialját!",1)
  695.  
  696. accounts[username][3] = "0"
  697. end
  698. end
  699. end
  700. addCommandHandler("resetserial",resetserial_sc)
  701.  
  702. function changeCharData(id,data,value)
  703. if characters[id][data] then
  704. if data == "adminjail" then
  705. characters[id][data] = value
  706. dbExec(connection, "UPDATE `characters` SET `adminJail`=? WHERE `id`=?", value, id)
  707. elseif data == "position" then
  708. characters[id][data] = value
  709. dbExec(connection, "UPDATE `characters` SET `position`=? WHERE `id`=?", value, id)
  710. end
  711. end
  712. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement