Jump to content

/kill help


ThaD4N13L

Recommended Posts

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

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

/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

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