Clydian Posted December 6, 2015 Posted December 6, 2015 function setLevel(playerS,cmd,name,amount) local player = getPlayerFromName(PlayerS) local account = getPlayerAccount(playerS) local accName = getAccountName(account) if isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) then if getElementType(player) == "player" and tonumber(amount) then setElementData(player,"Level",getElementData(player,"Level") + amount) outputChatBox("Your level was increased by "..getPlayerName(playerS).." ("..amount.."%)",player,0,255,0) outputChatBox(getPlayerName(player).."'s level was increased.",playerS,0,255,0) else outputChatBox("Failed to give because the player/amount was wrong.",playerS,255,255,0) end end end addCommandHandler("setLevel",setLevel,false,false) any ideas why it wont work? DebugScript3 says" WARNING" DG_Levels/server.lua"70" Bad argument @ 'getPlayerFromName' [Expected string at argument 1, got nil]
Booo Posted December 6, 2015 Posted December 6, 2015 function setLevel(playerS,cmd,name,amount) local player = getPlayerFromName(PlayerS) local account = getPlayerAccount(playerS) local accName = getAccountName(account) if isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) then if getElementType(player) == "player" and tonumber(amount) then setElementData(player,"Level",getElementData(player,"Level") + amount) outputChatBox("Your level was increased by "..getPlayerName(playerS).." ("..amount.."%)",player,0,255,0) outputChatBox(getPlayerName(player).."'s level was increased.",playerS,0,255,0) else outputChatBox("Failed to give because the player/amount was wrong.",playerS,255,255,0) end end end addCommandHandler("setLevel",setLevel,false,false) any ideas why it wont work? DebugScript3 says" WARNING" DG_Levels/server.lua"70" Bad argument @ 'getPlayerFromName' [Expected string at argument 1, got nil] Because of the small and capital letters function setLevel(playerS,cmd,name,amount) local player = getPlayerFromName(PlayerS)
Clydian Posted December 6, 2015 Author Posted December 6, 2015 function setLevel(playerS,cmd,name,amount) local player = getPlayerFromName(PlayerS) local account = getPlayerAccount(playerS) local accName = getAccountName(account) if isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) then if getElementType(player) == "player" and tonumber(amount) then setElementData(player,"Level",getElementData(player,"Level") + amount) outputChatBox("Your level was increased by "..getPlayerName(playerS).." ("..amount.."%)",player,0,255,0) outputChatBox(getPlayerName(player).."'s level was increased.",playerS,0,255,0) else outputChatBox("Failed to give because the player/amount was wrong.",playerS,255,255,0) end end end addCommandHandler("setLevel",setLevel,false,false) any ideas why it wont work? DebugScript3 says" WARNING" DG_Levels/server.lua"70" Bad argument @ 'getPlayerFromName' [Expected string at argument 1, got nil] Because of the small and capital letters function setLevel(playerS,cmd,name,amount) local player = getPlayerFromName(PlayerS) Didnt fix it
SpecT Posted December 6, 2015 Posted December 6, 2015 This should work, you messed everything. function setLevel(thePlayer,cmd,toPlayer,amount) local toPlayer = getPlayerFromName(toPlayer) local account = getPlayerAccount(thePlayer) local accName = getAccountName(account) if isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) then if getElementType(toPlayer) == "player" and tonumber(amount) then setElementData(toPlayer,"Level",getElementData(toPlayer,"Level") + amount) outputChatBox("Your level was increased by "..getPlayerName(thePlayer).." ("..amount.."%)",toPlayer,0,255,0) outputChatBox(getPlayerName(thePlayer).."'s level was increased.",thePlayer,0,255,0) else outputChatBox("Failed to give because the player/amount was wrong.",thePlayer,255,255,0) end end end addCommandHandler("setLevel",setLevel,false,false) Also to set a level to the player you need to use his full nick (including color code if there is). So you should use getPlayerFromPartialName and replace getPlayerFromName[/with] with [wiki]getPlayerFromPartialName.
Clydian Posted December 6, 2015 Author Posted December 6, 2015 This should work, you messed everything. function setLevel(thePlayer,cmd,toPlayer,amount) local toPlayer = getPlayerFromName(toPlayer) local account = getPlayerAccount(thePlayer) local accName = getAccountName(account) if isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) then if getElementType(toPlayer) == "player" and tonumber(amount) then setElementData(toPlayer,"Level",getElementData(toPlayer,"Level") + amount) outputChatBox("Your level was increased by "..getPlayerName(thePlayer).." ("..amount.."%)",toPlayer,0,255,0) outputChatBox(getPlayerName(thePlayer).."'s level was increased.",thePlayer,0,255,0) else outputChatBox("Failed to give because the player/amount was wrong.",thePlayer,255,255,0) end end end addCommandHandler("setLevel",setLevel,false,false) Also to set a level to the player you need to use his full nick (including color code if there is). So you should use getPlayerFromPartialName and replace getPlayerFromName[/with] with [wiki]getPlayerFromPartialName. Thank you very much, and i will try to change it, see how it works
Clydian Posted December 6, 2015 Author Posted December 6, 2015 This should work, you messed everything. function setLevel(thePlayer,cmd,toPlayer,amount) local toPlayer = getPlayerFromName(toPlayer) local account = getPlayerAccount(thePlayer) local accName = getAccountName(account) if isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) then if getElementType(toPlayer) == "player" and tonumber(amount) then setElementData(toPlayer,"Level",getElementData(toPlayer,"Level") + amount) outputChatBox("Your level was increased by "..getPlayerName(thePlayer).." ("..amount.."%)",toPlayer,0,255,0) outputChatBox(getPlayerName(thePlayer).."'s level was increased.",thePlayer,0,255,0) else outputChatBox("Failed to give because the player/amount was wrong.",thePlayer,255,255,0) end end end addCommandHandler("setLevel",setLevel,false,false) Also to set a level to the player you need to use his full nick (including color code if there is). So you should use getPlayerFromPartialName and replace getPlayerFromName[/with] with [wiki]getPlayerFromPartialName. acually just tested it and still wont work
SpecT Posted December 6, 2015 Posted December 6, 2015 What's the problem ? Any errors from debugscript ?
Clydian Posted December 6, 2015 Author Posted December 6, 2015 What's the problem ? Any errors from debugscript ? same error as it showed before
SpecT Posted December 7, 2015 Posted December 7, 2015 Are you sure you use the command right ? example: /setLevel Steve 21
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