ThaD4N13L Posted November 26, 2011 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?
12p Posted November 26, 2011 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.
mjau Posted November 26, 2011 Posted November 26, 2011 i think there is a inbuilt /kill comand too you might have to cancel that first
ThaD4N13L Posted November 26, 2011 Author 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 .
Castillo Posted November 26, 2011 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 .
MTA Team qaisjp Posted November 27, 2011 MTA Team 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?
MTA Team qaisjp Posted November 27, 2011 MTA Team Posted November 27, 2011 So he can see the chat output . What?
CapY Posted November 27, 2011 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.
MTA Team qaisjp Posted November 27, 2011 MTA Team 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
12p Posted November 27, 2011 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.
Aibo Posted November 27, 2011 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.
ThaD4N13L Posted November 27, 2011 Author Posted November 27, 2011 I think I'll use Qais's btw thanks guy(s).
ThaD4N13L Posted November 27, 2011 Author 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
12p Posted November 27, 2011 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.
Aibo Posted November 27, 2011 Posted November 27, 2011 well good luck adding ACL for those commands then. seriously, command handlers are there for a reason.
12p Posted November 27, 2011 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
MTA Team qaisjp Posted November 28, 2011 MTA Team Posted November 28, 2011 I think I'll use Qais's btw thanks guy(s). Great
ThaD4N13L Posted December 18, 2011 Author Posted December 18, 2011 I think I'll use Qais's btw thanks guy(s). Great NP
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