Jump to content

doesn't save??


HUNGRY:3

Recommended Posts

hey guys when i reconnect it doesn't save!!

here's code

function addvip( thePlayer, commandName, playername ) 
    if getElementData( thePlayer,"admin") == true then 
        if playername then 
            local vipplayer = getPlayerFromName ( playername ) 
            if vipplayer then 
                setElementData( vipplayer,"VIP", true) 
                outputChatBox("#FF0000[VIP_SYSTEM]Congratz the Player is now vip -->"..getPlayerName(vipplayer),root,255,255,255,true) 
            else 
                outputChatBox ( "Player does not exist!", thePlayer ) 
            end 
        else 
            outputChatBox ( "You MUST define a player to add him!", thePlayer ) 
        end 
    end 
end 
addCommandHandler("add", addvip) 

help

Link to comment
function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then  
            local vip = getElementData(source,"VIP") == true then 
            setAccountData ( playeraccount, "VIP", true ) 
      end 
end 
  
function onPlayerLogin (_, playeraccount ) 
      if ( playeraccount ) then 
            local playermoney = getAccountData ( playeraccount, "VIP" ) 
            if ( vip ) then 
                  setElementData ( source,"VIP") 
            end 
      end 
end 
  
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) 
  

gonna work?

Link to comment
  
  
  
 function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
            local vip = getElementData(source,"VIP") 
            if vip == true then 
            setAccountData ( playeraccount, "VIP", true ) 
            else 
            setAccountData ( playeraccount, "VIP", false ) 
            end 
      end 
end 
  
function onPlayerLogin (_, playeraccount ) 
      if ( playeraccount ) then 
            local accvip = getAccountData ( playeraccount, "VIP" ) 
            if accvip == true then 
                  setElementData ( source,"VIP", true) 
            end 
      end 
end 
  
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) 
  
  
  

not tested.

( thanks ALw7sH for correcting me )

Edited by Guest
Link to comment
  
  
function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
            local vip = getElementData(source,"VIP")  
            if vip == true then 
            setAccountData ( playeraccount, "VIP", true ) 
           else  
          setAccountData ( playeraccount, "VIP", false ) 
      end 
end 
  
function onPlayerLogin (_, playeraccount ) 
      if ( playeraccount ) then 
            local accvip = getAccountData ( playeraccount, "VIP" ) 
            if accvip == true then 
                  setElementData ( source,"VIP", true) 
            end 
      end 
end 
  
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) 
  
  
  

not tested.

you have missed end for line 7 end

function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
            local vip = getElementData(source,"VIP") 
            if vip == true then 
            setAccountData ( playeraccount, "VIP", true ) 
            else 
            setAccountData ( playeraccount, "VIP", false ) 
            end 
      end 
end 
  
function onPlayerLogin (_, playeraccount ) 
      if ( playeraccount ) then 
            local accvip = getAccountData ( playeraccount, "VIP" ) 
            if accvip == true then 
                  setElementData ( source,"VIP", true) 
            end 
      end 
end 
  
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) 

Link to comment

I don't think that setting account data on exit based on account data is the solution.

Explanation: accountData is always saved AUTOMATICALLY. It's being saved in internal.db where it is safe and is stored by account

Here is my version, I commented all of it.

P.S: Put it in your code editor, the text is very disordered here in the Code Box.

function getPlayerFromPartialName(who) --Useful Function | Author: TAPL 
    local who = who and who:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
    if who then 
        for _, player in ipairs(getElementsByType("player")) do 
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
            if name_:find(who, 1, true) then 
                return player 
            end 
        end 
    end 
end 
  
function vip(thePlayer, cmd, target) 
      if isElement(thePlayer) then --Check if the player who triggered the function exists (not really useful, just to hesitate errors) 
            if (target ~= "") then --Check if the target string isn't empty 
                  local target = getPlayerFromPartialName(target) --Call the function "getPlayerFromPartialName" to get the target element from the name and store it as the var target 
                  if isElement(target) then --Check if the element "target" exists 
                        local account = getPlayerAccount(target) --Get the target account 
                        if (getAccountData(account, "vip") == false) then --If he is not a vip, then... (vip == false) 
                              setAccountData(account, "vip", true) --Set his VIP status 
                              outputChatBox("Added "..getPlayerName(target):gsub("#%x%x%x%x%x%x", "").." as VIP", thePlayer, 255, 255, 255) --Output to thePlayer's chat 
                        elseif (getAccountData(account, "vip") == true) then --If he is a vip, then... (vip == true) 
                              setAccountData(account, "vip", false) --Set his VIP status 
                              outputChatBox("Removed "..getPlayerName(target):gsub("#%x%x%x%x%x%x", "").." as VIP", thePlayer, 255, 255, 255) --Output to thePlayer's chat 
                        end 
  
                        --The code above makes it so you can use only one command for ADDING and REMOVING 
                  end 
            end 
      end 
end 
addCommandHandler("avip", vip) --Add the command 

You shall chose the one you like ;)

Link to comment

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...