felipebaidoloko

System Level / XP

Recommended Posts

Good evening,

I need help in Level and XP system, this is a bug not only in XP and Level but when it dies .. the Bug is so when you die has 7 Seconds to be able to be reborn .. only if you move in the middle of it or Disclaimer when I get shot ... when you log in again the game will be bugged, not showing the level ... Summarizing this bugado and I'm already 2 weeks trying to solve this bug and I can not and I decided without on the Wiki can help to help me To solve the Bug I did some systems to try to correct (I do not know much of .lua plus I know the basics) I do some level system and tried to make it look like more did not work .. I do not know if it's right, but I tried to do it myself A system that makes see any player Level and XP of it .. Please I need help in this if it is wrong to correct me please because I want to learn this the system that I did was this

function(_, acc)
  if (acc) then
    if (getAccountData(acc, "level") ~= 0) and (getAccountData(acc, "experience") ~= 0) then
        setElementData(source, "level", getAccountData(acc, "level"))
        setElementData(source, "experience", getAccountData(acc, "experience")))
    end
end
)

Or show me a system that I can put in to make an analysis of when the Player logs in to check the level and his patent eg "Level" and "experience"

OPS: When the Player is Born bugged, neither Level nor XP (the Hud in dxDrawText) and the Level goes from 1 to 105 ..

I just decided to open a help here on the Wiki because I no longer know what I can do ..

Baido ~

Edited by felipebaidoloko
error

Share this post


Link to post

Any errors/warnings reported into debugscript?

Share this post


Link to post
16 hours ago, felipebaidoloko said:

 

I do not think so. I think I did the wrong script so I asked for help.

show full code or we can't help you.

Share this post


Link to post

dataTables.lua

Spoiler

KillerDataTable = {
  {"level"},
  {"experience"},
}

playerDataTable = {
  {"alivetime"},
  {"skin"},
  {"level"},
  {"experience"},
  {"MAX_Slots"},
  {"bandit"},
  {"blood"},
  {"food"},
  {"thirst"},
  {"helmetLife"},
  {"vestLife"},
  {"wearingBackpack"},
  {"temperature"},
  {"currentweapon_1"},
  {"currentweapon_2"},
  {"currentweapon_3"},
  {"bleeding"},
  {"brokenbone"},
  {"pain"},
  {"cold"},
  {"infection"},
  {"humanity"},
  {"zombieskilled"},
  {"headshots"},
  {"murders"},
  {"banditskilled"},
  {"Wood Pile"},
  {"Bandage"},
  {"Handcuffs"},
  {"Antibiotics"},
  {"Bouteille"},
  {"Burger"},
  {"Box of Matches"},
  {"Morphine"},
  {"Soda Bottle"},
  {"Empty Gas Canister"},
  {"Full Gas Canister"},
  {"Roadflare"},
  {"Milk"},
  {"Watch"},
  {"Medic Kit"},
  {"Heat Pack"},
  {"Blood Bag"},
  {"GPS"},
  {"Map"},
  {"Syringe"},
  {"Hose"},
  {"Trap"},
  {"Stinger"},
  {"Toolbox"},
  {"Wire Fence"},
  {"Tire"},
  {"Engine"},
  {"Windscreen Glass"},
  {"Main Rotor Assembly"},
  {"Tank Parts"},
  {"Infrared Goggles"},
  {"Night Vision Goggles"},
  {"Tent"},
  {"Big Tent"},
  {"Raw Meat"},
  {"Cooked Meat"},
  {"Survivor Clothing"},
  {"Ghillie Desert"},
  {"Ghillie Suit"},
  {"Ghillie[F] Suit"},
  {"Civilian[F] Clothing"},
  {"Painkiller"},
  {"Binoculars"},
  {"Empty Water Bottle"},
  {"Water Bottle"},
  {"Empty Soda Cans"},
  {"Scruffy Burgers"},
  {"Radio Device"},
  {"Parachute"},

}

 

Login.lua

Spoiler

function playerLogin(username,pass,player)
  local playerID = getAccountData(getPlayerAccount(player), "playerID")
  account = getPlayerAccount(player)
  local x, y, z = getAccountData(account, "last_x"), getAccountData(account, "last_y"), getAccountData(account, "last_z")
    local skin = getAccountData(account, "skin")
        createZombieTable (player)
    if getAccountData(account, "isDead") then
        spawnDayZPlayer(player)
    return
    end
  spawnPlayer(player, x, y, z, math.random(0, 360), skin, 0, 0)
        fadeCamera(player, true)
        setCameraTarget(player, player)
        playerCol = createColSphere(x, y, z, 1.5)
        setElementData(player, "playerCol", playerCol)
        attachElements(playerCol, player, 0, 0, 0)
        setElementData(playerCol, "parent", player)
        setElementData(playerCol, "player", true)
    for i,data in ipairs(playerDataTable)do
    local elementData = getAccountData(account,data[1])
    if not elementData and not checkThis(data[1]) then
      elementData = 0
    end
    setElementData(player,data[1],elementData)
  end
  setElementData(player,"logedin",true)
  setElementData(player,"isDead",false)
  setElementData(player,"playerKilled",false)
    local weapon = getElementData(player, "currentweapon_1")
    if weapon then
    local ammoData, weapID = getWeaponAmmoType(weapon)
        giveWeapon(player, weapID, getElementData(player, ammoData), true)
    end
    local weapon = getElementData(player, "currentweapon_2")
    if weapon then
    local ammoData, weapID = getWeaponAmmoType(weapon)
        giveWeapon(player, weapID, getElementData(player, ammoData), false)
    end
    local weapon = getElementData(player, "currentweapon_3")
    if weapon then
    local ammoData, weapID = getWeaponAmmoType(weapon)
        giveWeapon(player, weapID, getElementData(player, ammoData), false)
    end
       setElementModel(player,getElementData(player,"skin"))
  setElementData(player,"admin",getAccountData(account,"admin")or false)
  setElementData(player,"supporter",getAccountData(account,"supporter")or false)
  triggerClientEvent(player,"onClientPlayerDayZLogin",player)
end
addEvent("onPlayerDayZLogin", true)
addEventHandler("onPlayerDayZLogin", getRootElement(), playerLogin)

function playerRegister(username, pass, player)
  number = math.random(#spawnPositions)
  x,y,z = spawnPositions[number][1],spawnPositions[number][2],spawnPositions[number][3]
  spawnPlayer (player, x,y,z, math.random(0,360), 0, 0, 0)
  fadeCamera(player,true)
  setCameraTarget(player,player)
  playerCol = createColSphere(x,y,z,1.5)
  attachElements(playerCol,player,0,0,0)
  setElementData(playerCol,"parent",player)
  setElementData(playerCol,"player",true)
  for i,item in pairs(playerDataTable) do
    setElementData(player,item[1],0)
  end
  for _,item in pairs(registerItems)do
    setElementData(player,item[1],item[2])
  end
  setElementData(player,"logedin",true)
  createZombieTable(player)    
end
addEvent("onPlayerDayZRegister", true)
addEventHandler("onPlayerDayZRegister", getRootElement(), playerRegister)

 Spwan.lua

Spoiler

function kilLDayZPlayer(killer,headshot,weapon)
  setElementData(source,"teleporting",true)
  if getElementData(source,"playerKilled") then
    return
  end
  pedCol = false
  local account = getPlayerAccount(source)
  if not account then
    return
  end
  killPed(source)
  setElementData(source,"playerKilled",true)
  if getElementData(source,"alivetime")> 10 and not isElementInWater(source) then
    local x,y,z = getElementPosition(source)
    if getDistanceBetweenPoints3D(x,y,z,6000,6000,0)> 200 then
      local x,y,z = getElementPosition(source)
      local rotX,rotY,rotZ = getElementRotation(source)
      local skin = getElementModel(source)
      local ped = createPed(skin,x,y,z,rotZ)
      triggerClientEvent("AddDeathPedClothes",source,ped,source)
      pedCol = createColSphere(x,y,z,1.5)
      killPed(ped)
      setTimer(destroyDeadPlayer, 600000, 1, ped, pedCol)
      attachElements(pedCol,ped,0,0,0)
      setElementData(pedCol,"parent",ped)
      setElementData(pedCol,"playername",getPlayerName(source))
      setElementData(pedCol,"deadman",true)
      setElementData(pedCol,"MAX_Slots",getElementData(source,"MAX_Slots"))
      local time = getRealTime()
    local hours = time.hour
    local minutes = time.minute
        setElementData(pedCol, "deadreason", getPlayerName(source) .. " está morto. Causa da morte: " .. (weapon or "Unknown") .. ". Hora da morte: " .. hours .. ":" .. minutes .. ".") end
    end
    if killer then
    if not getElementData(source,"bandit") then
        addPlayerStats (killer,"humanity",math.random(-2500,-1000))
    else
        addPlayerStats (killer,"humanity",math.random(1000,2500))    
    end
        setElementData(killer,"murders",getElementData(killer,"murders")+1)
        setElementData(killer,"experience",getElementData(killer,"experience")+980)
    if getElementData(killer,"humanity") < 0 then
        setElementData(killer,"bandit",true)
    end
    if getElementData(source,"bandit") == true then
        setElementData(killer,"banditskilled",getElementData(killer,"banditskilled")+1)
        setElementData(killer,"experience",getElementData(killer,"experience")+800)
    end
    if headshot == true then
        setElementData(killer,"headshots",getElementData(killer,"headshots")+1)
        setElementData(killer,"experience",getElementData(killer,"experience")+1300)
    end
    end
    if pedCol then
    for i,data in ipairs(playerDataTable)do
      if tonumber(getElementData(source,data[1]))then
        setElementData(pedCol,data[1],getElementData(source,data[1]))
      end
    end
    local skinID = getElementData(source, "skin")
    local skin = getSkinNameFromID(skinID)
    setElementData(pedCol, skin, 1)
  end
  setTimer(setElementPosition,500,1,source,6000,6000,0)
  triggerClientEvent(source,"onClientPlayerDeathInfo",source)
  setAccountData(account,"isDead",true)
  setElementData(source,"isDead",true)
  triggerClientEvent("onRollMessageStart",getRootElement(),"#FFFFFF"..getPlayerName(source).." #FFFFFFwas killed",0,22,255,"died")
  if isElement(getElementData(source,"playerCol")) then
        destroyElement(getElementData(source,"playerCol"))
    end
    setTimer(spawnDayZPlayer,9600,1,source)
end
addEvent("kilLDayZPlayer",true)
addEventHandler("kilLDayZPlayer",getRootElement(),kilLDayZPlayer)

 

 

Script level patent .lua ==> Client

Spoiler

local ranksTable =
{
  {"1","Training","1000"},
  {"2","Recruit","2000"},
  {"3","Private","3000"},
  {"4","Private First Class","4000"},
  {"5","Corporal","5000"},
  {"6","Sergeant","5800"},
  {"7","Staff Sergeant |","8100"},
  {"8","Staff Sergeant ||","11000"},
  {"9","Staff Sergeant |||","14600"},
  {"10","Sergeant First Class |","18800"},
  {"11","Sergeant First Class ||","23800"},
  {"12","Sergeant First Class |||","29600"},
  {"13","Master Sergeant |","36300"},
  {"14","Master Sergeant ||","44100"},
  {"15","Master Sergeant |||","53000"},
  {"16","Master Sergeant ||||","63000"},
  {"17","Command Sergeant Major |","74500"},
  {"18","Command Sergeant Major |||","87400"},
  {"19","Command Sergeant Major ||||","102000"},
  {"20","Command Sergeant Major ||||","118400"},
  {"21","Command Sergeant Major |||||","136700"},
  {"22","Second Lieutenant |","157200"},
  {"23","Second Lieutenant ||","180000"},
  {"24","Second Lieutenant |||","205200"},
  {"25","Second Lieutenant ||||","233300"},
  {"26","Second Lieutenant |||||","264400"},
  {"27","First Lieutenant |","298700"},
  {"28","First Lieutenant ||","336500"},
  {"29","First Lieutenant |||","378000"},
  {"30","First Lieutenant ||||","423700"},
  {"31","First Lieutenant |||||","473700"},
  {"32","Captain |","528400"},
  {"33","Captain |||","588100"},
  {"34","Captain ||||","653400"},
  {"35","Captain ||||","724400"},
  {"36","Captain |||||","801600"},
  {"37","Major |","885500"},
  {"38","Major |||","976400"},
  {"39","Major ||||","1074800"},
  {"40","Major ||||","1181100"},
  {"41","Major |||||","1296000"},
  {"42","Lieutenant Colonel |","1419700"},
  {"43","Lieutenant Colonel ||","1552900"},
  {"44","Lieutenant Colonel |||","1696200"},
  {"45","Lieutenant Colonel ||||","1849900"},
  {"46","Lieutenant Colonel |||||","2014800"},
  {"47","Colonel |","2191200"},
  {"48","Colonel ||","2380000"},
  {"49","Colonel |||","2581500"},
  {"50","Colonel |||| ","2796400"},
  {"51","Colonel |||||","3025300"},
  {"52","Brigadier General |","3268800"},
  {"53","Brigadier General ||","3527500"},
  {"54","Brigadier General |||","3801900"},
  {"55","Brigadier General ||||","4092800"},
  {"56","Brigadier General |||||","4400600"},
  {"57","Major General |","4726000"},
  {"58","Major General ||","5069500"},
  {"59","Major General |||","5431800"},
  {"60","Major General ||||'","6000000"},
  {"61","Major General |||||'","6568200"},
  {"62","Lieutenant General |","7136400"},
  {"63","Lieutenant General ||'","7704600"},
  {"64","Lieutenant General |||","8272800"},
  {"65","Lieutenant General ||||","8841000"},
  {"66","Lieutenant General |||||","9409200"},
  {"67","General |","9977400"},
  {"68","General ||","10545600"},
  {"69","General |||","11113800"},
  {"70","General of the Army","11692000"}
}


function getPlayerRankName()
  for i=1,70 do
    if getElementData(localPlayer, "level") == tonumber(ranksTable[1]) then
      return ranksTable[2]
    end
  end
end

function getPlayerRankExperience()
  for i=1,70 do
    if getElementData(localPlayer, "level") == tonumber(ranksTable[1]) then
      return tonumber(ranksTable[3])
    end
  end
end

function mainRanks()
  if getElementData(localPlayer, "logedin") == true then
    if getElementData(localPlayer, "experience") > getPlayerRankExperience() then
      if getElementData(localPlayer, "level") < 70 then
        setElementData(localPlayer, "level", getElementData(localPlayer, "level") + 1)
      end
    end
    dxDrawImage ( sW/22, sH/2.8, sW/60, sH/60, "images/level/rank"..getElementData(localPlayer, "level")..".jpg" )    
    dxDrawText ( getPlayerRankName().." ("..getElementData(localPlayer, "level")..")",sW/65, sH/3.6, sW/0, sH/0, tocolor ( 240, 230, 140, 255 ), 1.02, "default-bold" )    
    dxDrawText ( "Current experience: "..getElementData(localPlayer, "experience"), sW/65, sH/3.27, sW/0, sH/0, tocolor ( 70, 130, 180, 255 ), 1.02, "default-bold" )
    if getElementData(localPlayer, "level") < 70 then
      dxDrawText ( "Need experience: "..getPlayerRankExperience(),sW/65, sH/3, sW/0, sH/0, tocolor ( 70, 130, 180, 255 ), 1.02, "default-bold" )
    else
      dxDrawText ( "The maximum is reached",sW/65, sH/3, sW/0, sH/0, tocolor ( 70, 130, 180, 255 ), 1.02, "default-bold" )
    end      
  end
end
addEventHandler ( "onClientRender", root, mainRanks )

 

This is to functions the Spawn.lua is that buga when you die and displaces the count to be reborn

Share this post


Link to post

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.