Jump to content

getAccountName


SkatCh

Recommended Posts

Posted

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]

Failure is simply an opportunity to begin again more intelligently - Henry Ford

Posted

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 

Posted

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 
); 

Failure is simply an opportunity to begin again more intelligently - Henry Ford

Posted
  
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 
) 
  

Posted
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 
); 

A unique GangWar gamemode waiting for you!
Click here for more information.

560x95_FFFFFF_FF9900_000000_000000.png

Posted
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?

Posted

by Anubhav on 27 Aug 2014, 12:48

by XeoN- on 27 Aug 2014, 12:49

Keep calm , we posted in the same time nobody copied your code.

By the way , my code isn't 100% like your.

A unique GangWar gamemode waiting for you!
Click here for more information.

560x95_FFFFFF_FF9900_000000_000000.png

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

Posted

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 
) 
  

Posted

guys i alredy fixed it thx every one for help . :) topic can be locked.

Failure is simply an opportunity to begin again more intelligently - Henry Ford

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

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