Jump to content

getAccountName


SkatCh

Recommended Posts

hi guys please i need some help here i create a vip system and i got some warinings here : just i want when i restart the resource evrey one will get his VIP status :

  
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), 
function () 
for i, p in ipairs ( getElementsByType ( "player" ) ) do 
if ( getAccountName ( p ) ) then  <------------- this line 
if ( getAccountData ( getAccountName ( p ), "vip" ) ) then 
setElementData ( p, "vip", true ); 
setElementData ( p, "vip.time", tonumber ( getAccountData ( getAccountName ( p ), "vip.time" ) ) ); 
startVip ( p ); 
end 
end 
end 
end 
); 

Warning : bad argument @ 'getAccountName' [expected account at argument 1 , got player]

Link to comment

First you must get the player's account using

getPlayerAccount 

and then use

getAccountName 

local ranp = getRandomPlayer()  
if ranp then  
  local acc = getPlayerAccount (ranp )  
local accName = getAccountName (acc)  -- You got his account name  
   else  
       outputChatBox ("Could not find a random player")  
end 

Link to comment

yes bro me too i think it's right but i try didn't work can you fix it please:

addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), 
function () 
for i, p in ipairs ( getElementsByType ( "player" ) ) do 
local account = getPlayerAccount (p) 
if ( getAccountName ( account ) ) then  <------------- this line 
if ( getAccountData ( getAccountName ( p ), "vip" ) ) then 
setElementData ( p, "vip", true ); 
setElementData ( p, "vip.time", tonumber ( getAccountData ( getAccountName ( p ), "vip.time" ) ) ); 
startVip ( p ); 
end 
end 
end 
end 
); 

Link to comment
  
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), 
    function () 
        for i, p in ipairs ( getElementsByType ( "player" ) ) do 
            local account = getPlayerAccount (p) 
            if not ( isGuestAccount( account ) ) then  
                if ( getAccountData ( p , "vip" ) ) then 
                    setElementData ( p, "vip", true ) 
                    setElementData ( p, "vip.time", tonumber ( getAccountData ( p, "vip.time" ) ) ) 
                    startVip ( p ) 
            end 
        end 
    end 
end 
) 
  

Link to comment
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), 
function () 
for i, p in ipairs ( getElementsByType ( "player" ) ) do 
local account = getPlayerAccount (p) 
if (account ) then 
if ( getAccountName ( account ) ) then  <------------- this line 
if ( getAccountData ( p , "vip" ) ) then 
setElementData ( p, "vip", true ); 
setElementData ( p, "vip.time", tonumber ( getAccountData ( getAccountName ( p ), "vip.time" ) ) ); 
startVip ( p ); 
end 
end 
end 
end 
); 

Link to comment
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), 
function () 
for i, p in ipairs ( getElementsByType ( "player" ) ) do 
local account = getPlayerAccount (p) 
if (account ) then 
if ( getAccountName ( account ) ) then  <------------- this line 
if ( getAccountData ( p , "vip" ) ) then 
setElementData ( p, "vip", true ); 
setElementData ( p, "vip.time", tonumber ( getAccountData ( getAccountName ( p ), "vip.time" ) ) ); 
startVip ( p ); 
end 
end 
end 
end 
); 

Din't you copied my code?

Link to comment
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), 
function () 
for i, p in ipairs ( getElementsByType ( "player" ) ) do 
local account = getPlayerAccount (p) 
if (account ) then 
if ( getAccountName ( account ) ) then  <------------- this line 
if ( getAccountData ( p , "vip" ) ) then 
setElementData ( p, "vip", true ); 
setElementData ( p, "vip.time", tonumber ( getAccountData ( getAccountName ( p ), "vip.time" ) ) ); 
startVip ( p ); 
end 
end 
end 
end 
); 

Din't you copied my code?

Are you mad? keep calm

1 reply is enough kid.

Link to comment

Well, how could you can get an account data of a player element ? you should pass the account instead

addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() , 
    function () 
        for i, p in ipairs ( getElementsByType ( "player" ) ) do 
            local account = getPlayerAccount (p) 
            if not ( isGuestAccount( account ) ) then 
                --if ( getAccountData ( p , "vip" ) ) then 
                   if ( getAccountData ( account , "vip" ) ) 
                    setElementData ( p, "vip", true ) 
                    setElementData ( p, "vip.time", tonumber ( getAccountData ( p, "vip.time" ) ) ) 
                    startVip ( p ) 
            end 
        end 
    end 
end 
) 
  

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...