Lloyd Logan Posted August 2, 2012 Share Posted August 2, 2012 Right so I take the simple setPedArmour FOR EXAMPLE!! function givePlayerArmor ( player, command ) setPedArmor ( player, 100 ) -- Set player's armor to 100 when he types the command 'addarmor' end addCommandHandler ( "addarmor", givePlayerArmor ) function removePlayerArmor ( player, command ) setPedArmor ( player, 0 ) -- Set player's armor to 0 when he types the command 'removearmor' end addCommandHandler ( "removearmor", removePlayerArmor ) Okay Now I change it so It works with health... function setPlayerHealth ( player, command ) setElementHealth ( player, 100 ) -- Set player's health to 100 when he types the command 'health100' end addCommandHandler ( "health100", setPlayerHealth ) function setPlayerHealth ( player, command ) setElementHealth ( player, 0 ) -- Set player's health to 0 when he types the command 'dienow' end addCommandHandler ( "dienow", removePlayerArmor ) (ignore anymistakes in the script!!) Now my question is.... Instead of Typing set health 100, (as in a solid number) how can i make it so they choose the health, as in health "then what they type for their health" i think its VAR but i am not sure, example but defo wrong!!! setElementHealth ( player, var ) -- Set player's health to 0 when he types the command 'dienow' addCommandHandler ( "dienow", "var" , removePlayerArmor ) Sorry for the stupid questions but you guys on the forums keep me alive!!! Link to comment
ernst Posted August 2, 2012 Share Posted August 2, 2012 this? addCommandHandler("health", function(thePlayer, cmd, amount) setElementHealth(thePlayer, amount) end) /health 50 sets your health to 50 Link to comment
Lloyd Logan Posted August 2, 2012 Author Share Posted August 2, 2012 this? addCommandHandler("health", function(thePlayer, cmd, amount) setElementHealth(thePlayer, amount) end) /health 50 sets your health to 50 Dont think thats right, ??? Link to comment
ernst Posted August 2, 2012 Share Posted August 2, 2012 How do you mean? is it not what you want? Link to comment
Lloyd Logan Posted August 2, 2012 Author Share Posted August 2, 2012 How do you mean? is it not what you want? I mean the layout of it and i do not know how to edit it, hence the reaason i am asking, but thank you for your help right now, i do appreciate it Link to comment
ernst Posted August 2, 2012 Share Posted August 2, 2012 Do you mean that you want it like this: function setHealth(thePlayer, cmd, amount) setElementHealth(thePlayer, amount) end addCommandHandler("health", setHealth) ? Link to comment
TAPL Posted August 2, 2012 Share Posted August 2, 2012 function setHealth(thePlayer, cmd, amount) setElementHealth(thePlayer, tonumber(amount)) end addCommandHandler("health", setHealth) Link to comment
qaisjp Posted August 2, 2012 Share Posted August 2, 2012 thePlayer - the person who wrote the command [server side script btw] cmd - a STRING of what the cmd is (this currently is "health") amount - (any variables after cmd are the variables a user type in after command) We convert amount to number and stop if not a number We check if its <0 or >255 and stopif so We set the health function setHealth(thePlayer, cmd, amount) amount=tonumber(amount); if not amount then return end if (amount<0) or (amount>255) then return end setElementHealth(thePlayer, amount) end addCommandHandler("health", setHealth) 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