GerardWay Posted July 6, 2014 Posted July 6, 2014 Hey, how could i make a command that sets a players ElementData named "level" to whichever number is specified? for example, if I typed it '/level Fontaine 100' ingame, it would set Fontaine's level to 100. Any help is appreciated!
Addlibs Posted July 6, 2014 Posted July 6, 2014 (edited) addCommandHandler("level", function(cmdSrc, cmd, player, level) local pla = getPlayerFromName(player) if player and pla then if level and tonumber(level) then setElementData(pla, "level", tonumber(level)) outputChatBox("Set "..getPlayerName(pla).."'s level to "..tonumber(level), cmdSrc, 0, 255, 0) else outputChatBox("Error: Invalid level specified.", cmdSrc, 255, 0, 0) end else outputChatBox("Error: Player '"..player.."' not found.", cmdSrc, 255, 0, 0) end end) Edited July 6, 2014 by Guest
Max+ Posted July 6, 2014 Posted July 6, 2014 addCommandHandler("level", function(cmdSrc, cmd, player, level) local pla = getPlayerFromName(player) if player and pla then if level and tonumber(level) then setElementData(pla, "level", tonumber(level)) outputChatBox("Set "..getPlayerName(pla).."'s level to "..tonumber(level), cmdSrc, 0, 255, 0) else outputChatBox("Error: Invalid level specified.", cmdSrc, 255, 0, 0) end else outputChatBox("Error: Player '"..player.."' not found.", cmdSrc, 255, 0, 0) end end Worng , you have many mistakes ,
Arnold-1 Posted July 6, 2014 Posted July 6, 2014 function setLevel(player,cmd,player2,level) if hasObjectPermissionTo(player,"function.kickPlayer") then if player2 and level then if tonumber(level) then local plyElement = getPlayerFromName(player2) if plyElement then setElementData(plyElement,"level",level) outputChatBox("You have successfuly changed the level of "..player2.." to "..level..".",player,200,100,100) outputChatBox("Your Level was changed to "..level.." By "..player..".",player2,200,100,100) else outputChatBox("Player Not Found.",player,200,100,100) end else outputChatBox("Invaild Level.",player,200,100,100) end else outputChatBox("setlevel: Syntax /setlevel ",200,100,100) end end end addCommandHandler("setlevel",setLevel)
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