Jump to content

not outputing account data "xp"


John Smith

Recommended Posts

Posted

i am starting to create somekind of xp system,just out of boredom but i got a simple problem.

function xpSystem() 
local playerAccount = getPlayerAccount(source) 
local xp = getAccountData(playerAccount,"xp") 
  if isGuestAccount(playerAccount,source,true) then 
  return 
  else 
      if isGuestAccount(playerAccount,source,false) then 
         if (playerAccount) then 
            if xp ~= nil then 
               setAccountData(playerAccount,"xp",0) 
               outputChatBox(xp, getRootElement(), 0, 255, 0) 
            end 
         end 
      end 
   end 
end 
addEventHandler("onPlayerJoin",getRootElement(),xpSystem) 
addEventHandler("onPlayerLogin",getRootElement(),xpSystem) 

it doesn't output anything.

no errors.

maybe i haven't set account data in good way.

can anyone help me please?

Posted

Your code does not make any sense, you are trying to set 'xp' when but you are setting it to 0. Please explain what you want!

Posted

lol,

if xp ~= nil then 

im checking if theres data in the account,and that data is "xp"

and then if there's no data in account,im setting it to number zero(0 xp aka 0 experience)

setAccountData(playerAccount,"xp",0) 

because if theres no account data considering "xp" it means its a new player, who (logic)-didnt make any kills so he got 0xp.

Now in the script there isnt anything about killing but i will add it later,but i just want to test this out by adding 0 xp to people

i hope u understand my english

  • Moderators
Posted

May I ask, how can you login manually before you join?.........

isGuestAccount(playerAccount,source,false) 
if isGuestAccount(playerAccount) then 

if not isGuestAccount(playerAccount) then 

Posted (edited)
May I ask, how can you login manually before you join?.........

isGuestAccount(playerAccount,source,false) 
if isGuestAccount(playerAccount) then 

if not isGuestAccount(playerAccount) then 

function xpSystem() 
local playerAccount = getPlayerAccount(source) 
local xp = getAccountData(playerAccount,"xp") 
  if isGuestAccount(playerAccount) then 
  return 
  else 
      if not isGuestAccount(playerAccount) then 
         if (playerAccount) then 
            if not xp then 
               setAccountData(playerAccount,"xp",0) 
               outputChatBox(xp, getRootElement(), 0, 255, 0) 
            end 
         end 
      end 
   end 
end 
addEventHandler("onPlayerJoin",getRootElement(),xpSystem) 
addEventHandler("onPlayerLogin",getRootElement(),xpSystem) 

[16:18:39] WARNING: xp\script.lua:11: Bad argument @ 'outputChatBox' [Expected string at argument 1, got boolean]
Edited by Guest
Posted
  
function xpSystem(_, playerAccount) 
local xp = getAccountData(playerAccount,"xp") 
    if (playerAccount) then 
        if xp then 
            outputChatBox(xp, getRootElement(), 0, 255, 0) 
        else 
            setAccountData(playerAccount,"xp",0) 
        end 
    end 
end 
addEventHandler("onPlayerLogin",getRootElement(),xpSystem) 
  

Posted

by the way,i just wanted to ask one more question.

how could i give xp to people when they send a message on chatbox?

function giveXP(_,playerAccount) 
   if (playerAccount) then 
      if xp then 
         setAccountData(playerAccount,"xp"+133) 
         outputChatBox(xp, getRootElement(), 0, 255, 0) 
      end 
   end 
end 
addEventHandler("onPlayerChat",getRootElement(),giveXP) 

sorry if i ask for too much,i just want to know better how setAccountData works

  • Moderators
Posted
not working

NNNNOOO WORKING.... OMG! I AM SO SEXY.

addEventHandler("onPlayerChat",root, 
function(message,messageType) 
    local playerAccount = getPlayerAccount ( source ) 
    if not isGuestAccount ( playerAccount) then 
        setAccountData(playerAccount,"xp",(getAccountData(playerAccount,"xp") or 0)+133) 
    end 
end) 
  

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.
×
×
  • Create New...