Guest User

loginh1.lua

a guest
May 10th, 2015
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.56 KB | None | 0 0
  1. addEventHandler("onPlayerLogin",getRootElement(),
  2. function()
  3.     local pAcc = getPlayerAccount(source)
  4.     local civTeam = getTeamFromName("Civilian")
  5.     local playerName = getPlayerName(source)
  6.     local playerFromName = getPlayerFromName(playerName)
  7.     if not getAccountData(pAcc, "first.time") then
  8.          outputChatBox("Welcome to the server, this seems like your first time!",source,0,255,0)
  9.          outputChatBox("Choose a city!",source,255,255,0)
  10.          setAccountData(pAcc,"first.time",true)
  11.          setPlayerTeam(source, civTeam)
  12.          givePlayerMoney(playerFromName,15000)
  13.          exports.tpmenu:triggerMenu(playerFromName)
  14.          exports.stats:triggerDefaultsForFirstLogin(playerFromName)
  15.          setAccountData(pAcc, "account.walkstyle",0)
  16.          setAccountData(pAcc, "account.bank",0)
  17.         else
  18.         local loginX = getAccountData(pAcc, "loginlocation.x")
  19.         local loginY = getAccountData(pAcc, "loginlocation.y")
  20.         local loginZ = getAccountData(pAcc, "loginlocation.z")
  21.         local lastWalk = getAccountData(pAcc, "account.walkstyle")
  22.         local accountMoney = getAccountData(pAcc, "account.money")
  23.         local lastTeam = getAccountData(pAcc, "last.team")
  24.         spawnPlayer(playerFromName,loginX,loginY,loginZ)
  25.         setElementFrozen(source,false)
  26.         if (accountMoney) then 
  27.            setPlayerMoney(source, accountMoney)
  28.         end
  29.         if (lastTeam) then
  30.         local getTheTeamsName = getTeamFromName(lastTeam)
  31.         setPlayerTeam(source,getTheTeamsName)
  32.         else
  33.         setPlayerTeam(source,civTeam)
  34.         cancelEvent()
  35.         end
  36.         if getAccountData(pAcc,"account.walkstyle") == nil then
  37.         outputChatBox("NIL WALKSTYLE")
  38.         elseif getAccountData(pAcc, "account.walkstyle") == 0 then
  39.         setPedWalkingStyle(source,0)
  40.         elseif getAccountData(pAcc, "account.walkstyle") == 1 then
  41.         setPedWalkingStyle(source,69)
  42.         elseif getAccountData(pAcc, "account.walkstyle") == 2 then
  43.         setPedWalkingStyle(source,128)
  44.         end
  45.     end
  46.     fadeCamera(source, true)
  47.     setCameraTarget(source, source)
  48.     outputChatBox("You are now logged in!, Welcome",source,0,255,0)
  49. end)
  50.  
  51. addEventHandler("onPlayerQuit",getRootElement(),
  52. function()
  53.     local pAcc = getPlayerAccount (source)
  54.     local getHisTeam = getPlayerTeam(source)
  55.     local playersMoney = getPlayerMoney(source)
  56.     local lastWalk = getElementData(source, "temp.walkOpen")
  57.     if (pAcc) and not isGuestAccount(pAcc) then
  58.         local lastOccupation = getAccountData(pAcc, "account.occupation")
  59.         local logoutX, logoutY, logoutZ = getElementPosition(source)
  60.         setAccountData(pAcc, "loginlocation.x", logoutX)
  61.         setAccountData(pAcc, "loginlocation.y", logoutY)
  62.         setAccountData(pAcc, "loginlocation.z", logoutZ)
  63.         setAccountData(pAcc, "marked.latest.temp", false)
  64.         setAccountData(pAcc, "account.occupation",lastOccupation)
  65.         setAccountData(pAcc, "account.money", playersMoney)
  66.         setAccountData(pAcc, "account.walkstyle", lastWalk)
  67.     if (getHisTeam) then
  68.         local teamsName = getTeamName(getHisTeam)
  69.         setAccountData(pAcc,"last.team", teamsName)
  70.      end
  71.    end
  72. end)
  73. ---ALL BELOW HERE IS FOR TESTING PURPOSES---
  74. function resetLogin(thePlayer,cmdname,arg3)
  75. local playerName = getPlayerName(thePlayer)
  76. local playerFromName = getPlayerFromName(playerName)
  77. local pAcc = getPlayerAccount(playerFromName)
  78. setAccountData(pAcc, "first.time",false)
  79. outputChatBox("Reseted the login!",playerFromName,0,255,0)
  80. end
  81. addCommandHandler("rl",resetLogin)
  82. function checkWalk(thePlayer,cmdname,arg3)
  83. if (thePlayer) then
  84.  local pAcc = getPlayerAccount(thePlayer)
  85.  local lastWalk = getAccountData(pAcc, "account.walkstyle")
  86.  outputChatBox("Result: " ..lastWalk.. " ",thePlayer,0,255,0)
  87. end
  88. end
  89. function setSneak(thePlayer,cmdname,arg3)
  90. if (thePlayer) then
  91. local pAcc = getPlayerAccount(thePlayer)
  92. setAccountData(pAcc,"account.walkstyle",arg3)
  93. outputChatBox("DONE",thePlayer)
  94. end
  95. end
  96. addCommandHandler("cwalk",checkWalk)
  97. addCommandHandler("ss",setSneak)
  98. function checkData(thePlayer)
  99. local pAcc = getPlayerAccount(thePlayer)
  100. if (pAcc) then
  101. local theData = getAccountData(pAcc, "account.interior")
  102. outputChatBox("Result:" ..theData.. " ",thePlayer,0,255,0)
  103. end
  104. end
  105. function setData(thePlayer,cmdname,arg3)
  106. local pAcc = getPlayerAccount(thePlayer)
  107. if (pAcc) then
  108. setAccountData(pAcc, "account.interior",arg3)
  109. end
  110. end
  111. function convertData(thePlayer)
  112. local pAcc = getPlayerAccount(thePlayer)
  113. if (pAcc) then
  114. local retrievedData = getAccountData(pAcc, "account.interior")
  115. local convertedData = tonumber(retrievedData)
  116. setAccountData(pAcc,"account.interior",convertedData)
  117. end
  118. end
  119. addCommandHandler("c1",checkData)
  120. addCommandHandler("c2",setData)
  121. addCommandHandler("c3",convertData)
Advertisement
Add Comment
Please, Sign In to add comment