TroyBoy Posted February 19, 2012 Share Posted February 19, 2012 how can i do command that the health point the player write in the server will be the health of his? Link to comment
Kenix Posted February 19, 2012 Share Posted February 19, 2012 Server addCommandHandler( 'health', function( player ) outputChatBox( 'Your health is '..tostring( math.floor( getElementHealth( player ) ) )..'!',player,0,255,0 ) end ) Link to comment
TroyBoy Posted February 19, 2012 Author Share Posted February 19, 2012 not to get the player health to set the player health from the health i write to give him in the server Link to comment
Gr0x Posted February 19, 2012 Share Posted February 19, 2012 not to get the player health to set the player health from the health i write to give him in the server in english, please? Link to comment
Castillo Posted February 19, 2012 Share Posted February 19, 2012 You mean give the player health? example: player has 50 HP, and you write /health 20 and the player health will be 70 HP? if so: addCommandHandler( 'health', function( player, cmd, theHealth ) local theHealth = tonumber(theHealth) if (theHealth) then setElementHealth(player, getElementHealth( player ) + theHealth) outputChatBox( 'Your health is now '..tostring( math.floor( getElementHealth( player ) ) )..'!',player,0,255,0 ) end end ) Link to comment
TroyBoy Posted February 19, 2012 Author Share Posted February 19, 2012 /sethp (player) 50 will set is health to 50 i want to give the player health of what i choose if i write /sethp (player) 37 it will set is hp to 37 ok Link to comment
Gr0x Posted February 19, 2012 Share Posted February 19, 2012 So use: addCommandHandler( 'health', function( player, cmd, theHealth ) local theHealth = tonumber(theHealth) if (theHealth) then setElementHealth(player, theHealth) outputChatBox( 'Your health is now '..tostring( math.floor( getElementHealth( player ) ) )..'!',player,0,255,0 ) end end ) Link to comment
TroyBoy Posted February 20, 2012 Author Share Posted February 20, 2012 ty and how can i do that its not matter if the command i write in the server will be in big letters or small like in the script i write this: addCommandHandler( 'hi', and in the server i will can do the command like this /Hi or /HI or /hI Link to comment
Discord Moderators Zango Posted February 20, 2012 Discord Moderators Share Posted February 20, 2012 Fourth parameter in addCommandHandler. Also, don't you want (admins) to be able to set health of other people, and not only themselves? How about this: function setHealthCmd (player, cmd, ...) local targetPlayer local health = tonumber(arg[2]) or 100 if (arg[1]) then targetPlayer = getPlayerFromName (arg[1]) if not targetPlayer then if ((not arg[2]) and tonumber(arg[1])) then health = tonumber (arg[1]) targetPlayer = player else outputChatBox (string.format('Invalid player `%s`', arg[1]), player, 255, 0, 0) return end end else targetPlayer = player end setElementHealth (targetPlayer, health) outputChatBox (string.format('`%s` has set your health to %s', getPlayerName(player), health), targetPlayer, 0, 255, 0) end addCommandHandler ('sethp', setHealthCmd, true, false) It will set your health if you specify no player or a number alone. As you can read on the wiki page, the third parameter is whether to block access for everyone but those with access to the command in acl.xml. Link to comment
Micro Posted February 21, 2012 Share Posted February 21, 2012 function hel(player, command) outputChatBox ("* ("..getPlayerName(player)..") say /myhealth he is health : ("..getElementHealth(player)..")", player, 255, 12, 15) end addCommandHandler("myhealth", hel) Link to comment
drk Posted February 21, 2012 Share Posted February 21, 2012 function hel(player, command) outputChatBox ("* ("..getPlayerName(player)..") say /myhealth he is health : ("..getElementHealth(player)..")", player, 255, 12, 15) end addCommandHandler("myhealth", hel) WTF! Can you speak English and tabulate your code? Your code: function health(player,cmd) outputChatBox("* ("..getPlayerName(player..") typed /myhealth. His health is: "..getElementHealth(player),root,255,12,15,false) end addCommandHandler('myhealth',health) Link to comment
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