Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.78 KB | None | 0 0
  1. --[[ اسکریپت اولیه سرور ام تی ای
  2. Author: Deihim007
  3. Name: NGS Main Script
  4. Decription: Login , Register , Spawn , Respawn , Data Saving
  5. ]]
  6.  
  7.  
  8. local cur = 1
  9. local speedX = 0.05
  10. local speedY = 0.30
  11. local timers = {}
  12. local boats = {}
  13.  
  14. local cameraPoints = {
  15. {sx=-1142.81, sy=855.058, sz=84.00, ex=-1780, ey=790, ez=70}, -- San Fierro Bridges
  16. {sx=368.04, sy=-2056.82, sz=16.9, ex=443.90, ey=-1680.15, ez=25.08}, -- Los Santos Beach
  17. {sx=816.19, sy=-1218.46, sz=39.33, ex=911.66, ey=-864.66, ez=83.18}, -- Los Santos Film Studio
  18. {sx=-100.56, sy=-1414.22, sz=106.04, ex=-340.46, ey=-1836.81, ez=2.6}, -- Los Santos West Country
  19. {sx=2443.706, sy=-978.581, sz=95.3, ex=2299.454, ey=-1236.496, ez=28}, -- Los Santos Las Collinas
  20. {sx=1526.356, sy=-1756.763, sz=33.429, ex=1526.777, ey=-1693.961, ez=13.382}, -- Los Santos Police Department
  21. {sx=1807.681, sy=-1556.710, sz=45.875, ex=1817.355, ey=-1609.757, ez=15.38}, -- Los Santos Prison Building
  22. {sx=-495.60, sy=2098.54, sz=131.93, ex=-816.23, ey=1805.05, ez=7.0}, -- The Dam
  23. {sx=-149.97, sy=2506.71, sz=25.9, ex=473.29, ey=2515.49, ez=22.87}, -- The Old Air Strip
  24. {sx=-2865.38, sy=2600.06, sz=278.12, ex=-2235.21, ey=2054.00, ez=60}, -- Bayside Marina
  25. }
  26.  
  27. addEventHandler("onPlayerJoin",root,
  28. function ()
  29. setPlayerHudComponentVisible ( source, "clock", false )
  30. setPlayerHudComponentVisible ( source, "radar", false )
  31. setPlayerHudComponentVisible ( source, "area_name", false )
  32. showChat ( source, false )
  33. showCursor ( source, true )
  34. fadeCamera ( source, false,1 )
  35. exports["HUD"]:showNewHudComponent(source,"all","false")
  36. end)
  37.  
  38. function saveUserData (source, account, reset)
  39. if ( getAccount(tostring(account)) ) then
  40. local account = getAccount(tostring(account))
  41. if getElementHealth(source) > 0 then
  42. local x, y, z = getElementPosition(source)
  43. local rotation = getPedRotation(source)
  44. local skin = getElementModel(source)
  45. local dimension = getElementDimension(source)
  46. if (getPlayerTeam(source)) then
  47. local team = getTeamName(getPlayerTeam(source))
  48. setAccountData(account, "NGS.playerTeam", team)
  49. end
  50. local money = getPlayerMoney(source)
  51. local interior = getElementInterior(source)
  52. local health = tonumber(getElementHealth(source))
  53. if (isPedDead(source)) then
  54. health = 0
  55. end
  56. local armor = getPedArmor(source)
  57. local wanted = tostring(getPlayerWantedLevel(source))
  58. setAccountData(account, "NGS.playerX", x)
  59. setAccountData(account, "NGS.playerY", y)
  60. setAccountData(account, "NGS.playerZ", z)
  61. setAccountData(account, "NGS.playerRotation", rotation)
  62. setAccountData(account, "NGS.playerSkin",skin)
  63. setAccountData(account, "NGS.playerDimension", dimension)
  64. setAccountData(account, "NGS.playerMoney", money)
  65. setAccountData(account, "NGS.playerInterior", interior)
  66. setAccountData(account, "NGS.playerHealth", health)
  67. setAccountData(account, "NGS.playerWanted", wanted)
  68. setAccountData(account, "NGS.playerArmor", armor)
  69. if (source and reset) then
  70. setPlayerMoney(source, 0)
  71. setPlayerTeam(source, nil)
  72. exports["Jobs"]:setPlayerJob(source,"None")
  73. end
  74. end
  75. end
  76. end
  77.  
  78.  
  79. function serverStart ()
  80. local vehicle
  81. for k, v in ipairs (getElementsByType("veh")) do
  82. vehicle = createVehicle(getElementData(v,"model"),getElementData(v,"posX"),getElementData(v,"posY"),getElementData(v,"posZ"),0,0,getElementData(v,"rotation"))
  83. setElementData(vehicle,"owner",getElementData(v,"owner"))
  84. toggleVehicleRespawn(vehicle,true)
  85. setVehicleIdleRespawnDelay(vehicle,120000)
  86. setVehicleRespawnDelay (vehicle, 20000 )
  87. end
  88. for index, player in pairs(getElementsByType("player")) do
  89. local account = getPlayerAccount(player)
  90. if not account or isGuestAccount(account) then
  91. setPlayerHudComponentVisible ( player, "clock", false )
  92. setPlayerHudComponentVisible ( player, "radar", false )
  93. setPlayerHudComponentVisible ( player, "area_name", false )
  94. showChat ( player, false )
  95. showCursor( player, true )
  96. end
  97. end
  98. end
  99. addEventHandler ( "onResourceStart", resourceRoot, serverStart )
  100.  
  101. addEventHandler ( "onResourceStop", resourceRoot,
  102. function ()
  103. for index, player in ipairs ( getElementsByType ( "player" ) ) do
  104. saveUserData(player, getAccountName(getPlayerAccount(player)))
  105. if not getElementData(player, "tempWeapons") then
  106. savePlayerWeapons(player, getPlayerAccount(player))
  107. end
  108. end
  109. end
  110. )
  111.  
  112. function onLoginAttempt(username, password)
  113. local account = getAccount(username, password)
  114. if (account~=false) then
  115. --login
  116. if (logIn(source,account,password)) then
  117. triggerClientEvent(source, "loginSuccessful", getRootElement(), getAccountData(account,"NGS.madeCharacter"))
  118. else
  119. triggerClientEvent(source, "makeMessage", getRootElement(), "Error logging you in. \n Try again later", "Login Error")
  120. end
  121. else
  122. --failed
  123. triggerClientEvent(source, "makeMessage", getRootElement(), "Your username/password was incorrect.", "Login Error")
  124. end
  125. end
  126. addEvent("tryLogin",true)
  127. addEventHandler("tryLogin", getRootElement(), onLoginAttempt)
  128.  
  129. function onRegisterAttempt(username, password, email, question, answer)
  130. if (getAccount(username,password) == false) then
  131. --username acceptable!
  132. account = addAccount(username,password)
  133. if (account) then
  134. setAccountData(account, "NGS.email",email)
  135. setAccountData(account, "NGS.madeCharacter",false)
  136. setAccountData(account, "NGS.securityQuestion",tostring(question))
  137. setAccountData(account, "NGS.securityQuestionAnswer",tostring(answer))
  138. if(logIn(source,account,password)==true) then
  139. triggerClientEvent(source, "registerSuccessful", getRootElement())
  140. else
  141. triggerClientEvent(source, "makeMessage", getRootElement(), "Try Logging in with your account", "Registration Complete")
  142. end
  143. else
  144. triggerClientEvent(source, "makeMessage", getRootElement(), "Unable to create your account. \n Try again later.", "Registration Error")
  145. end
  146. else
  147. --username not acceptable
  148. triggerClientEvent(source, "makeMessage", getRootElement(), "The username you requested \n i s unavailable.", "Registration Error")
  149. end
  150. end
  151. addEvent("tryRegister", true)
  152. addEventHandler("tryRegister", getRootElement(), onRegisterAttempt)
  153.  
  154. addEvent("resetPassword",true)
  155. addEventHandler("resetPassword",root,
  156. function (client, username, mail, question, answer, newPassword)
  157. local account = getAccount(username)
  158. if (account==false) then
  159. triggerClientEvent(client, "makeMessage", getRootElement(), "Your username was incorrect.", "Forgot password Error")
  160. return
  161. end
  162. local email = getAccountData(account,"NGS.email")
  163. local securityQuestion = getAccountData(account,"NGS.securityQuestion")
  164. local securityQuestionAnswer = getAccountData(account,"NGS.securityQuestionAnswer")
  165. if mail ~= email then
  166. triggerClientEvent(client, "makeMessage", getRootElement(), "The email is incorrect.", "Forgot password Error")
  167. return
  168. end
  169. if question ~= securityQuestion then
  170. triggerClientEvent(client, "makeMessage", getRootElement(), "The security question is incorrect.", "Forgot password Error")
  171. return
  172. end
  173. if answer ~= securityQuestionAnswer then
  174. triggerClientEvent(client, "makeMessage", getRootElement(), "The security question answer is incorrect.", "Forgot password Error")
  175. return
  176. end
  177. setAccountPassword(account,newPassword)
  178. triggerClientEvent(client, "makeMessage", getRootElement(), "You have successfully changed the password \nyou can now login.", "Password changed")
  179. end)
  180.  
  181. function spawnMe(player)
  182. local source = source or player
  183. local account = getPlayerAccount ( source )
  184. local x = getAccountData(account, "NGS.playerX")
  185. local y = getAccountData(account, "NGS.playerY")
  186. local z = getAccountData(account, "NGS.playerZ")
  187. local rotation = getAccountData(account, "NGS.playerRotation")
  188. local skin = getAccountData(account, "NGS.playerSkin")
  189. local interior = getAccountData(account, "NGS.playerInterior")
  190. local dimension = getAccountData(account, "NGS.playerDimension")
  191. local teamName = getAccountData(account, "NGS.playerTeam")
  192. local health = getAccountData(account, "NGS.playerHealth")
  193. local money = getAccountData(account, "NGS.playerMoney")
  194. local wanted = tonumber(getAccountData(account, "NGS.playerWanted"))
  195. local armor = getAccountData(account, "NGS.playerArmor")
  196. setPlayerMoney(source, money)
  197. spawnPlayer(source, x, y, z, rotation, tonumber(skin), interior, dimension, team)
  198. exports["HUD"]:showNewHudComponent(source,"all","true")
  199. if tonumber(skin) == 0 then
  200. setTimer(function (source)
  201. for type=0, 17 do
  202. local info = getAccountData(account,"clothes_".. type)
  203. if info then
  204. local info = split(info, ",")
  205. if (info[1] and info[2]) then
  206. addPedClothes(source, tostring(info[1]), tostring(info[2]), type)
  207. end
  208. end
  209. end
  210. end, 2000, 1, source)
  211. end
  212. setElementHealth(source, health)
  213. showCursor(source, false)
  214. if (wanted) then
  215. setPlayerWantedLevel(source, wanted)
  216. end
  217. if (armor and tonumber(armor)) then
  218. setPedArmor(source, armor)
  219. end
  220. setPlayerHudComponentVisible ( source, "clock", true )
  221. setPlayerHudComponentVisible ( source, "radar", true )
  222. setPlayerHudComponentVisible ( source, "area_name", true )
  223. showChat(source,true)
  224. showCursor(source,false)
  225. setCameraTarget(source, source)
  226. fadeCamera(source, true)
  227. if (teamName) then
  228. local team = getTeamFromName(teamName)
  229. local teamColR, teamColG, teamColB = getTeamColor ( team )
  230. setPlayerTeam(source,team)
  231. else
  232. local teamColR = 255
  233. local teamColG = 255
  234. local teamColB = 0
  235. end
  236. toggleControl(source,"enter_exit",true)
  237. setPlayerNametagShowing(source, true)
  238. end
  239. addEvent("spawnMe", true)
  240. addEventHandler("spawnMe", getRootElement(), spawnMe)
  241.  
  242. --[[
  243. function loadPlayerWeapons2(player, account)
  244. local weapons = getAccountData(account,"NGS.playerWeapons") or "0;0"
  245. local weps = split(weapons,string.byte(","))
  246. for k, v in ipairs(weps) do
  247. local wepData = split(v,string.byte(";"))
  248. if (player) then
  249. giveWeapon(player, tonumber(wepData[1]), tonumber(wepData[2]), true)
  250. end
  251. end
  252. return weapons
  253. end
  254. --]]
  255.  
  256. function loadPlayerWeapons(player, account)
  257. local weapons = getAccountData(account,"NGS.playerWeapons") or "[{}]"
  258. for weapon, ammo in pairs(fromJSON(weapons)) do
  259. if (player) then
  260. giveWeapon(player, tonumber(weapon), tonumber(ammo), true)
  261. end
  262. end
  263. setElementData(player, "tempWeapons", nil)
  264. return weapons
  265. end
  266.  
  267. addCommandHandler("loadweps",
  268. function (player)
  269. if (getPlayerAccount(player) and getPlayerAccount(player) == getAccount("Deihim007")) then
  270. local accountsTable = {}
  271. local wepsTable = {}
  272. local jsons = {}
  273. for index, account in ipairs(getAccounts()) do
  274. wepsTable[account] = {}
  275. jsons[account] = {}
  276. accountsTable[account] = loadPlayerWeapons2(nil, account)
  277. end
  278. for account,_ in pairs(accountsTable) do
  279. for index, weapon in pairs(split(accountsTable[account],",")) do
  280. local wepData = split(weapon,string.byte(";"))
  281. wepsTable[account][wepData[1]] = tonumber(wepData[2])
  282. end
  283. jsons[account] = toJSON(wepsTable[account])
  284. end
  285. for account, json in pairs(jsons) do
  286. setAccountData(account,"NGS.playerWeapons",json)
  287. outputDebugString(getAccountName(account) ..": ".. json)
  288. end
  289. end
  290. end)
  291.  
  292. function select()
  293. local account = getPlayerAccount(source)
  294. local x, y, z, rotation = 2299.55469, -16.13815, 26.48438, 270
  295. local skin = 29
  296. local team = getTeamFromName("Unemployed")
  297. setAccountData(account, "NGS.playerX", x)
  298. setAccountData(account, "NGS.playerY", y)
  299. setAccountData(account, "NGS.playerZ", z)
  300. setAccountData(account, "NGS.playerRotation", rotation)
  301. setAccountData(account, "NGS.playerSkin", skin)
  302. setAccountData(account, "NGS.playerInterior", 0)
  303. setAccountData(account, "NGS.playerDimension", 0)
  304. setAccountData(account, "NGS.playerTeam", "Unemployed")
  305. fadeCamera(source, true)
  306. spawnPlayer(source, x, y, z, rotation, skin, 0, getteam)
  307. giveWeapon(source,22,17,true)
  308. local dimension = getFreeDimension()
  309. cleanNotUsedBoats()
  310. if isElement(boats[source]) then destroyElement(boats[source]) end
  311. boats[source] = createVehicle(581, 2299.543, -12.054, 26.080, 359.357, 0, 0)
  312. setVehicleHandling(boats[source],"dragCoeff",3.5)
  313. setVehicleHandling(boats[source],"tractionMultiplier",1.5)
  314. setVehicleHandling(boats[source],"tractionLoss",0.95)
  315. setVehicleHandling(boats[source],"tractionBias",0.47)
  316. setVehicleHandling(boats[source],"maxVelocity",200)
  317. setVehicleHandling(boats[source],"engineAcceleration",25)
  318. setElementFrozen(boats[source], true)
  319. setElementDimension(boats[source], dimension)
  320. setElementDimension(source, dimension)
  321. triggerClientEvent(source,"startIntro",source,dimension)
  322. end
  323. addEvent("spawnForSkinSelect", true)
  324. addEventHandler("spawnForSkinSelect", getRootElement(), select)
  325.  
  326. function cleanNotUsedBoats()
  327. for player, boat in pairs(boats) do
  328. if not isElement(player) and isElement(boat) then
  329. destroyElement(boat)
  330. end
  331. end
  332. end
  333.  
  334. function skinSelected(skin)
  335. local account = getPlayerAccount(source)
  336. local money = 2500
  337. local x, y, z, rotation = 2431.82593, -2707.37598, 3, 0
  338. setAccountData(account, "NGS.madeCharacter",true)
  339. setAccountData(account, "NGS.playerX", x)
  340. setAccountData(account, "NGS.playerY", y)
  341. setAccountData(account, "NGS.playerZ", z)
  342. setAccountData(account, "NGS.playerRotation", rotation)
  343. setAccountData(account, "NGS.playerSkin", tonumber(skin))
  344. setAccountData(account, "NGS.playerDimension", 0)
  345. setAccountData(account, "NGS.playerInterior", 0)
  346. setAccountData(account, "NGS.playerTeam", "Unemployed")
  347. setAccountData(account, "NGS.playerMoney", money)
  348. setAccountData(account, "NGS.playerHealth", 100)
  349. setTimer(showChat,5000,1,source,true)
  350. if isElement(boats[source]) then destroyElement(boats[source]) end
  351. fadeCamera(source,false)
  352. setTimer(fadeCamera,5000,1,source,true)
  353. setTimer(spawnMe,5000,1,source)
  354. toggleControl(source,"enter_exit",true)
  355. end
  356. addEvent("SkinSelected",true)
  357. addEventHandler("SkinSelected",getRootElement(),skinSelected)
  358.  
  359. --
  360. local lawTeams = {["Police"]=true, ["SWAT"]=true, ["Staff"] = true, ["FBI"] = true}
  361.  
  362. function getCopTeam()
  363. local plrs = {}
  364. for i, v in ipairs(getElementsByType("player")) do
  365. if (lawTeams[getTeamName(getPlayerTeam(v))]) then
  366. table.insert(plrs, v)
  367. end
  368. end
  369.  
  370. return plrs
  371. end
  372. --
  373. function criminalRespawn(source, team, killer)
  374. if (getPlayerWantedLevel(source) == 0) then
  375. return false
  376. end
  377. local x, y, z = getElementPosition(source)
  378.  
  379. if (isElement(killer)) then
  380.  
  381. local wanted = getPlayerWantedLevel(source)
  382. if (wanted > 0 and lawTeams[getTeamName(getPlayerTeam(killer))]) then
  383. spawnPlayer(source, x, y, z, 0, getElementModel(source), 0, 0, team)
  384. fadeCamera(source, true)
  385. setCameraTarget(source, source)
  386. showChat(source, true)
  387. exports["Info"]:setInfoState(source, true)
  388. setElementFrozen(source, true)
  389. setPedAnimation(source, "wuzi", "cs_dead_guy", -1, true, false, false, true, 250)
  390. setTimer(
  391. function(player)
  392. if (not isElement(player)) then
  393. return false
  394. end
  395. setElementFrozen(player, false)
  396. setPedAnimation(player)
  397. end
  398. , 15000, 1, source)
  399. return true
  400. end
  401. end
  402.  
  403. for i, v in ipairs(getCopTeam()) do
  404. local x2, y2, z2 = getElementPosition(v)
  405.  
  406. if (getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) < 50) then
  407. spawnPlayer(source, x, y, z, 0, getElementModel(source), 0, 0, team)
  408. fadeCamera(source, true)
  409. setCameraTarget(source, source)
  410. showChat(source, true)
  411. exports["Info"]:setInfoState(source, true)
  412. setElementFrozen(source, true)
  413. setPedAnimation(source, "wuzi", "cs_dead_guy", -1, true, false, false, true, 250)
  414. setTimer(
  415. function(player)
  416. if (not isElement(player)) then
  417. return false
  418. end
  419. setElementFrozen(player, false)
  420. setPedAnimation(player)
  421. end
  422. , 15000, 1, source, false)
  423. return true
  424. end
  425. end
  426.  
  427. return false
  428. end
  429. --
  430.  
  431. function respawnMe(source, team, killer)
  432. if isElement(source) then
  433. local respawn = criminalRespawn(source, team, killer)
  434. if (respawn) then
  435. return false
  436. end
  437. local account = getPlayerAccount(source)
  438. local hospitals = {
  439. {1178.59, -1323.90, 14.1279, 270, "All Saints General Hospital", {1214.7238769531, -1323.6098632813, 31.14349937439, 1213.8430175781, -1323.6158447266, 30.670255661011, 0, 70}},
  440. {2035.42, -1413.28, 17, 90, "Jefferson Hospital", {1997.6190185547, -1451.2794189453, 29.641700744629, 1998.2390136719, -1450.5690917969, 29.308361053467, 0, 70}},
  441. {-2666.39, 632.23, 14.46, 180, "San Fierro Medical Center", {-2595.7521972656, 592.87780761719, 30.298700332642, -2596.611328125, 593.29095458984, 29.996469497681, 0, 70}},
  442. {1607.40, 1822.67, 11, 0, "Las Venturas Medical Center", {1642.0198974609, 1836.3166503906, 22.070699691772, 1641.1240234375, 1836.0695800781, 21.7015209198, 0, 70}},
  443. }
  444. fadeCamera(source, true)
  445. local x,y,z = getElementPosition(source)
  446. local smallest = 99999
  447. local nearest = 0
  448. local dist
  449. for n = 1,4 do
  450. dist = getDistanceBetweenPoints2D(x, y, hospitals[n][1], hospitals[n][2])
  451. if (dist <= smallest) then
  452. smallest = dist
  453. nearest = n
  454. end
  455. end
  456. local hospitalName = tostring(hospitals[nearest][5])
  457. setCameraMatrix(source, unpack(hospitals[nearest][6]))
  458. exports["Cinematics"]:createCinematic(source, "You have been returned to ".. hospitalName ..".")
  459. setTimer(
  460. function(source)
  461. if (isElement(source)) then
  462. exports["Cinematics"]:destroyCinematic(source)
  463. spawnPlayer(source, hospitals[nearest][1], hospitals[nearest][2], hospitals[nearest][3], hospitals[nearest][4], getElementModel(source), 0, 0, team)
  464. fadeCamera(source, true)
  465. setCameraTarget(source, source)
  466. showChat(source, true)
  467. exports["Info"]:setInfoState(source, true)
  468. end
  469. end
  470. , 7000, 1, source)
  471. end
  472. end
  473.  
  474. addEventHandler("onPlayerSpawn",root,
  475. function ()
  476. setElementData(source,"spawn_protection",true)
  477. setElementAlpha(source,100)
  478. toggleControl(source,"fire",false)
  479. toggleControl(source,"aim_weapon",false)
  480. triggerClientEvent(source,"spawn_protection",source,false)
  481. setTimer(toggleControl,10000,1,source,"fire",true)
  482. setTimer(toggleControl,10000,1,source,"aim_weapon",true)
  483. setTimer(setElementData,10000,1,source,"spawn_protection",false)
  484. setTimer(triggerClientEvent,10000,1,source,"spawn_protection",source,true)
  485. setTimer(setElementAlpha,10000,1,source,255)
  486. if not getPlayerTeam(source) then
  487. setPlayerTeam(source, getTeamFromName("Unemployed"))
  488. end
  489. loadPlayerWeapons(source, getPlayerAccount(source))
  490. end)
  491.  
  492. addEventHandler( "onPlayerWasted", getRootElement(),
  493. function(_, killer)
  494. showChat(source, false)
  495. exports["Info"]:setInfoState(source, false)
  496. fadeCamera ( source, false, 1.0, 255, 255, 255 )
  497. if not getElementData(source,"tempWeapons") then
  498. savePlayerWeapons(source, getPlayerAccount(source))
  499. setElementData(source, "tempWeapons", true)
  500. end
  501. setTimer( respawnMe, 3000, 1, source, getPlayerTeam(source), killer )
  502. end
  503. )
  504.  
  505. function savePlayerWeapons(player, account)
  506. if (player and account) then
  507. local wepsTable = {}
  508. for i=0, 12 do
  509. local weapon = getPedWeapon(player, i)
  510. local weaponAmmo = getPedTotalAmmo(player, i)
  511. if tonumber(weaponAmmo) > 0 then
  512. wepsTable[weapon] = weaponAmmo
  513. end
  514. end
  515. setAccountData(account,"NGS.playerWeapons",toJSON(wepsTable))
  516. return toJSON(wepsTable)
  517. else
  518. outputDebugString("Error found: Player and Account arguments not set for player ".. getPlayerName(player) ..".", 1)
  519. return false
  520. end
  521. end
  522.  
  523. addEventHandler ( "onPlayerQuit",root,
  524. function()
  525. saveUserData(source, getAccountName(getPlayerAccount (source)), true)
  526. if not getElementData(source, "tempWeapons") then
  527. if savePlayerWeapons(source, getPlayerAccount(source)) then
  528. takeAllWeapons(source)
  529. end
  530. end
  531. if isTimer(timers[source]) then killTimer(timers[source]) end
  532. end
  533. )
  534.  
  535. addEventHandler("onPlayerLogout",getRootElement(),
  536. function (prev)
  537. saveUserData(source, getAccountName(prev), true)
  538. if not getElementData(source, "tempWeapons") then
  539. if savePlayerWeapons(source, getPlayerAccount(source)) then
  540. takeAllWeapons(source)
  541. end
  542. end
  543. setPlayerHudComponentVisible ( source, "clock", false )
  544. setPlayerHudComponentVisible ( source, "radar", false )
  545. setPlayerHudComponentVisible ( source, "area_name", false )
  546. exports["HUD"]:showNewHudComponent(source,"all","false")
  547. showChat ( source, false )
  548. showCursor ( source, true )
  549. fadeCamera ( source, false )
  550. if isElement(boats[source]) then destroyElement(boats[source]) end
  551. triggerClientEvent(source,"stopIntro",source)
  552. triggerClientEvent(source,"returnIsPlayerLoggedIn",source,false)
  553. end)
  554.  
  555. addEvent("isPlayerLoggedIn",true)
  556. addEventHandler("isPlayerLoggedIn",root,
  557. function (client)
  558. local account = getPlayerAccount(client)
  559. if not isGuestAccount(account) then
  560. triggerClientEvent(client,"returnIsPlayerLoggedIn",client,true)
  561. else
  562. triggerClientEvent(client,"returnIsPlayerLoggedIn",client,false)
  563. end
  564. end)
  565.  
  566. addEventHandler("onPlayerLogin",root,
  567. function ()
  568. if isTimer(timers[source]) then killTimer(timers[source]) end
  569. local account = getPlayerAccount(source)
  570. local question = getAccountData(account,"NGS.securityQuestion")
  571. if (not question or question == "") then
  572. triggerClientEvent(source,"showSecurityQuestionCreator",source,getAccountName(account))
  573. end
  574. end)
  575.  
  576. addEvent("securityQuestionSet",true)
  577. addEventHandler("securityQuestionSet",root,
  578. function (client, accountName, question, answer, mail)
  579. local account = getAccount(accountName)
  580. if getPlayerAccount(client) == account then
  581. setAccountData(account,"NGS.securityQuestion",tostring(question))
  582. setAccountData(account,"NGS.securityQuestionAnswer",tostring(answer))
  583. setAccountData(account,"NGS.email",tostring(mail))
  584. exports["Info"]:sendMessage(client,"Security question set to: ".. tostring(question) ..".",0,255,0)
  585. exports["Info"]:sendMessage(client,"Account e-mail set to: ".. tostring(mail) ..".",255,255,0)
  586. end
  587. end)
  588.  
  589. function getPageText(page)
  590. local info = xmlLoadFile("pages/page-"..tonumber(page)..".xml")
  591. if (not info) then
  592. info = xmlLoadFile("pages/page-1.xml")
  593. page = 1
  594. end
  595. local returnInfo = xmlNodeGetValue(info)
  596. xmlUnloadFile(info)
  597. triggerClientEvent(source,"returnPageText",source,returnInfo,page)
  598. end
  599. addEvent("getPageText",true)
  600. addEventHandler("getPageText",root,getPageText)
  601.  
  602. addEvent("getSkins",true)
  603. addEventHandler("getSkins",root,
  604. function ()
  605. local skinsTable = exports["SkinShop"]:getSkinsTable()
  606. triggerClientEvent(source,"returnSkins",source,skinsTable)
  607. end)
  608.  
  609. addEvent("warpToBoat",true)
  610. addEventHandler("warpToBoat",root,
  611. function ()
  612. if isElement(boats[source]) then
  613. warpPedIntoVehicle(source, boats[source])
  614. setElementFrozen(boats[source], false)
  615. triggerClientEvent(source,"createArrow",source)
  616. end
  617. end)
  618.  
  619. function elementCheck(element, sType)
  620. return element and isElement(element) and (not sType or getElementType(element) == sType)
  621. end
  622.  
  623. function getFreeDimension()
  624. local dimension = 0
  625. local tempTable = {}
  626. for index, player in pairs(getElementsByType("player")) do
  627. tempTable[getElementDimension(player)] = true
  628. end
  629. repeat
  630. dimension = dimension +1
  631. until not tempTable[dimension]
  632. return tonumber(dimension)
  633. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement