Jump to content

/kill help


ThaD4N13L

Recommended Posts

Posted
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?

Posted

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.

Posted
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
Posted
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
Posted

/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

Posted
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.

Posted

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.

Posted
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

Posted
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.

Posted

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

  • 3 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...