SkatCh Posted August 27, 2014 Share Posted August 27, 2014 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
Saml1er Posted August 27, 2014 Share Posted August 27, 2014 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
SkatCh Posted August 27, 2014 Author Share Posted August 27, 2014 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
Anubhav Posted August 27, 2014 Share Posted August 27, 2014 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
xeon17 Posted August 27, 2014 Share Posted August 27, 2014 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
Anubhav Posted August 27, 2014 Share Posted August 27, 2014 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
xeon17 Posted August 27, 2014 Share Posted August 27, 2014 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. Link to comment
SkatCh Posted August 27, 2014 Author Share Posted August 27, 2014 nvm keep calm guys. anyways i will try it . Link to comment
Anubhav Posted August 27, 2014 Share Posted August 27, 2014 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
50p Posted August 27, 2014 Share Posted August 27, 2014 There is no need to fight over simple stuff. Copying the code? The code that author of the topic needed help with? Cool down. Don't go offtopic. Link to comment
Anubhav Posted August 27, 2014 Share Posted August 27, 2014 I've reported him instead of posting shits.. I am realy sorry if I did something wrong here Link to comment
Karoffe Posted August 27, 2014 Share Posted August 27, 2014 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
SkatCh Posted August 27, 2014 Author Share Posted August 27, 2014 guys i alredy fixed it thx every one for help . topic can be locked. Link to comment
Recommended Posts