ThaD4N13L Posted November 26, 2011 Share Posted November 26, 2011 function commitSuicide ( sourcePlayer ) -- kill the player and make him responsible for it killPed ( sourcePlayer, sourcePlayer ) -- shows the kill msg outputChatBox (theTarget .. "has suicided.", getRootElement(), 255, 255, 255, true ) end -- attach our handler to the "kill" command addCommandHandler ( "kill", commitSuicide ) is this right to show the output chatbox of the person who has used the command? Link to comment
12p Posted November 26, 2011 Share Posted November 26, 2011 I would suggest function commitSuicide ( cmd ) if cmd == "kill" then -- kill the player and make him responsible for it killPed ( source, source ) -- shows the kill msg outputChatBox ( getPlayerName ( source ) .. " killed himself.", getRootElement(), 255, 255, 255, true ) end end -- attach our handler to the "kill" command addEventHandler ( "onPlayerCommand", getRootElement ( ), commitSuicide ) Try it. Link to comment
mjau Posted November 26, 2011 Share Posted November 26, 2011 i think there is a inbuilt /kill comand too you might have to cancel that first Link to comment
ThaD4N13L Posted November 26, 2011 Author Share Posted November 26, 2011 Naw theres not and thanks it works btw I am going to need much more help since I am learning lua . Link to comment
Castillo Posted November 26, 2011 Share Posted November 26, 2011 i think there is a inbuilt /kill comand too you might have to cancel that first That command is on some gamemodes, but is not a built-on command. P.S: Really DanChris? if so, good luck . Link to comment
qaisjp Posted November 27, 2011 Share Posted November 27, 2011 I would suggest function commitSuicide ( cmd ) if cmd == "kill" then -- kill the player and make him responsible for it killPed ( source, source ) -- shows the kill msg outputChatBox ( getPlayerName ( source ) .. " killed himself.", getRootElement(), 255, 255, 255, true ) end end -- attach our handler to the "kill" command addEventHandler ( "onPlayerCommand", getRootElement ( ), commitSuicide ) Try it. Why use an event when you can use a function? Link to comment
CapY Posted November 27, 2011 Share Posted November 27, 2011 So he can see the chat output . Link to comment
qaisjp Posted November 27, 2011 Share Posted November 27, 2011 So he can see the chat output . What? Link to comment
CapY Posted November 27, 2011 Share Posted November 27, 2011 When you type /kill, you don't see any chat output, like: "playername killed himself", but with this script, you can. Link to comment
qaisjp Posted November 27, 2011 Share Posted November 27, 2011 /kill is in the freeroam.... function commitSuicide ( ) -- kill the player and make him responsible for it killPed ( source, source ) -- shows the kill msg outputChatBox ( getPlayerName ( source ) .. " killed himself.", getRootElement(), 255, 255, 255, true ) end -- attach our handler to the "kill" command addCommandHandler ( "kill", commitSuicide ) will do the same thing using events for that is useless Link to comment
12p Posted November 27, 2011 Share Posted November 27, 2011 using events for that is useless Isn't useless. It's just a different way to do it and may be easier to create multiple command handlers using one function only. Link to comment
Aibo Posted November 27, 2011 Share Posted November 27, 2011 multiple command handlers can use single function just fine: function herpDerp(player, command) if command == "herp" then -- insert your fabulous shit here © elseif command == "derp" then -- insert your fabulous shit here © end end addCommandHandler("herp", herpDerp) addCommandHandler("derp", herpDerp) i also dont see the point of using event and not the command handler. if player types "/anything" it wont show in the chat either way, because it's a command. people should be pointing out the errors in the posted script (like undefined "theTarget" var), and not offering new and exciting ways to do stuff. it confuses people. in my opinion, anyway. Link to comment
ThaD4N13L Posted November 27, 2011 Author Share Posted November 27, 2011 I think I'll use Qais's btw thanks guy(s). Link to comment
ThaD4N13L Posted November 27, 2011 Author Share Posted November 27, 2011 i think there is a inbuilt /kill comand too you might have to cancel that first That command is on some gamemodes, but is not a built-on command. P.S: Really DanChris? if so, good luck . I only seen it on ShoDown RP but I am out of that RP its got over the limit of RP people don't Rp anymore exept on vG /: so Link to comment
12p Posted November 27, 2011 Share Posted November 27, 2011 multiple command handlers can use single function just fine: function herpDerp(player, command) if command == "herp" then -- insert your fabulous :~ here © elseif command == "derp" then -- insert your fabulous :~ here © end end addCommandHandler("herp", herpDerp) addCommandHandler("derp", herpDerp) It makes +2 lines of code per command. Link to comment
Aibo Posted November 27, 2011 Share Posted November 27, 2011 well good luck adding ACL for those commands then. seriously, command handlers are there for a reason. Link to comment
12p Posted November 27, 2011 Share Posted November 27, 2011 if hasObjectPermissionTo ( "user."..getAccountName(getPlayerAccount(player)), "command.ban" ) then It will take less time (just 1 file to edit) and probably less lines. But yea, it is easier to just add command handlers lol Link to comment
qaisjp Posted November 28, 2011 Share Posted November 28, 2011 I think I'll use Qais's btw thanks guy(s). Great Link to comment
ThaD4N13L Posted December 18, 2011 Author Share Posted December 18, 2011 I think I'll use Qais's btw thanks guy(s). Great NP 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