stefutz101 Posted August 20, 2015 Posted August 20, 2015 Hi i want to make make a script what help me to set lvl to a player addCommandHandler("setlvl", function(playerSource, cmd, thePlayeracc, amount) local nume = getAccountName ( getPlayerAccount ( playerSource )) if isObjectInACLGroup ( "user." .. nume, aclGetGroup ( "Admin" )) then if thePlayeracc then if tonumber(amount) then setAccountData(thePlayeracc, "lvl" , amount) outputChatBox("I-ai setat lvl lui ".. thePlayeracc.."la "..amount , playerSource) end end end end ) warning at setaccount data expected account at argument 1 , got string "...". how i cant get account name for a another player ?
Walid Posted August 20, 2015 Posted August 20, 2015 Try to use getPlayerFromPartialName if you don't know how post here again. function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
stefutz101 Posted August 20, 2015 Author Posted August 20, 2015 No , i want a script what set player lvl to level . But i have 1 warning : expected account at argument 1 , but argument 1 is Playeraccount . Player account its writed by me when i use command . Syntax : /setlvl But thancks for that script i need that to the future scripts
Walid Posted August 20, 2015 Posted August 20, 2015 (edited) lol i already gave you the solution but i think you want me to do it for you anyways this how you can do it : addCommandHandler("setlvl", function(player, cmd, playerToAdd, amount) local account = getPlayerAccount ( player) if account and isGuestAccount(account) then local accountName = getAccountName (account) if isObjectInACLGroup ( "user." ..accountName, aclGetGroup ( "Admin" )) then local playerToAdd = getPlayerFromPartialName(playerToAdd) if (isElement(playerToAdd)) then local playerAccount = getPlayerAccount(playerToAdd) if tonumber(amount) then setAccountData(playerAccount, "lvl" , tonumber(amount)) outputChatBox("I-ai setat lvl lui "..getAccountName(playerAccount).." la "..amount ,player,0,255,0) end else outputChatBox("No player with that name", player, 255, 0, 0) end end end end ) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Syntax : /setlvl Edited August 20, 2015 by Guest Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
stefutz101 Posted August 20, 2015 Author Posted August 20, 2015 Oh thancks , but i dont want the solution i just dont know why i had that warning . Btw dont work " if isObjectInACLGroup ( "user." .. nume, aclGetGroup ( "Admin" )) then" there is the problem replaced with accountName didn't work
Walid Posted August 20, 2015 Posted August 20, 2015 Oh thancks , but i dont want the solution i just dont know why i had that warning . Btw dont work" if isObjectInACLGroup ( "user." .. nume, aclGetGroup ( "Admin" )) then" there is the problem replaced with accountName didn't work it's working fine check my code i edit it. Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
stefutz101 Posted August 20, 2015 Author Posted August 20, 2015 I just test script nothing happer , no errors , no warnings , nothing writed in chat .
DNL291 Posted August 21, 2015 Posted August 21, 2015 The value stored in the account must be a string. Also, the if statement at line 4 is checking if it's a guest account. I've edited Walid's code, so try this: addCommandHandler( "setlvl", function(player, cmd, playerToAdd, amount) if tonumber(amount) and not isGuestAccount(getPlayerAccount(player)) then if isObjectInACLGroup ( "user." ..getAccountName( getPlayerAccount(player) ), aclGetGroup ( "Admin" )) then local playerToAdd = getPlayerFromPartialName(playerToAdd) if (isElement(playerToAdd)) and not isGuestAccount(getPlayerAccount(playerToAdd)) then setAccountData(getPlayerAccount(playerToAdd), "lvl" , tostring(amount)) outputChatBox("I-ai setat lvl lui "..getAccountName(getPlayerAccount(playerToAdd)).." la "..tostring(amount), player,0,255,0) else outputChatBox("No player with that name or that player isn't logged in", player, 255, 0, 0) end end end end ) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Please do not PM me with scripting related question nor support, use the forums instead.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now