steadyfi Posted February 24, 2015 Posted February 24, 2015 (edited) Hello all. I've got a little problem with a script. Im trying to make a command to set a player as Premium. I'm using setAccountData but when I try it tells me that it expected ELEMENT but it got a STRING Is there any way i can get a Element and not a string ? Code (Server-Side): --[[ ## Set Premium ]]-- function setPremium(playerSource, cmd, target, kit) if target and kit then local targetAccount = getPlayerAccount(target) if targetAccount and not isGuestAccount(targetAccount) then setAccountData(targetAccount, "premium_kit", kit) outputChatBox("Player "..target.." has been added as Premium with kit: "..kit.." !", playerSource) end else outputChatBox("Player not found or error accrued" ,playerSource, 255, 0, 0) end end addCommandHandler("premium", setPremium) Error: WARNING: basics\modules\utils_server.lua:84: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got string 'Steady'] Thanks Edited February 24, 2015 by Guest My Work: OpenTeams | DayZ Admin Panel | vAuth Must-Have Library: MTA Lua Async ApocalipZ Owner coming back soon!
KaduRo Posted February 24, 2015 Posted February 24, 2015 addCommandHandler parameters :- arg1, arg2, ...: Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain nil. You can deal with a variable number of arguments using the vararg expression, as shown in Server Example 2 below. so target is a string that contain "nil" , defined it as a player i guess ?
steadyfi Posted February 24, 2015 Author Posted February 24, 2015 addCommandHandler parameters :- arg1, arg2, ...: Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain nil. You can deal with a variable number of arguments using the vararg expression, as shown in Server Example 2 below. so target is a string that contain "nil" , defined it as a player i guess ? Yes, the variable target is the player element. But it doesn't return nil, it is returning as a string and I need a element My Work: OpenTeams | DayZ Admin Panel | vAuth Must-Have Library: MTA Lua Async ApocalipZ Owner coming back soon!
Banex Posted February 24, 2015 Posted February 24, 2015 --[[ ## Set Premium ]]-- function setPremium(playerSource, cmd, target, kit) if getPlayerFromName(target) and kit then local targetAccount = getPlayerAccount(getPlayerFromName(target)) if targetAccount and not isGuestAccount(targetAccount) then setAccountData(targetAccount, "premium_kit", kit) outputChatBox("Player "..target.." has been added as Premium with kit: "..kit.." !", playerSource) end else outputChatBox("Player not found or error accrued" ,playerSource, 255, 0, 0) end end addCommandHandler("premium", setPremium) Not worry about the future. Very soon it will come.
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