Author Topic: Need Help...Kill Command!  (Read 1729 times)

Ok so I have NO idea what is wrong with this...I have tried everything.  Can someone please look at this and see what is wrong.
Code: [Select]
package KillMessage {
function serverCmdKill(%client, %player) {
Parent::serverCmdKill(%client, %player);
if(trim(%player) $= "")
return;
else if(%client.isAdmin == true && isObject((%player = findClientByName(%player)))) {
//echo("ServercmdSelf Delete(findclientbyname("@ %player.name @"));");
if(isObject(%player.player))
chatMessageAll(%client, "\c3" @ %player.name @ "\c6 was force killed by \c3" @ %client.name @ "\c6.");
}
}
};
activatePackage(KillMessage);
Thanks,
General Hack

What I'm having trouble with is where the %player goes...The target.
Shouldn't it post it in there and do that command in console?

You haven't even mentioned what the problem your having is, what you're trying to accomplish. You just start off with "I have been trying for hours. Help me, here's the code." But what is the problem you're having with it?

Code: [Select]
function serverCmdKill(%client, %player) {
    if(!isObject(%pplayer = findClientByName(%player).player) || !%client.isSuperAdmin)
        return;
    %pplayer.kill();
    chatMessageAll(%client, "\c3" @ %pplayer.client.getPlayerName() @ "\c6 was force killed by \c3" @ %client.getPlayerName() @ "\c6.");
}

You only need to package it if the command is already there. I know there is one, but you haven't said if you have it.

Errors in your code:
  • You don't need to check for blank text since you're getting and checking the client of the name given. If it's blank, it wouldn't work anyway.
  • You should only allow supers to do this. You don't want regular admins able to, since people usually use that for simply loading builds.

MegaScientifical
Thank you very much. That was a good idea to make only SuperAdmins be able to do it.
Thanks again,
General Hack

MegaScientifical
Thank you very much. That was a good idea to make only SuperAdmins be able to do it.
Thanks again,
General Hack

Just letting you know, there was a slight error in MegsScientificals code. He has 2 Ps in player. Just letting you know, just incase your copy + Pasteing it.

Just letting you know, there was a slight error in MegsScientificals code. He has 2 Ps in player. Just letting you know, just incase your copy + Pasteing it.
It doesn't matter because he's using %var = findclientbyname(%player);

It doesn't matter because he's using %var = findclientbyname(%player);

Didnt read it good enough...thought he was useing %player throught the whole thing, and not makeing a new var.
Also, Didn't i make it clear i want NOTHING to do with you anymore?

Didnt read it good enough...thought he was useing %player throught the whole thing, and not makeing a new var.
Also, Didn't i make it clear i want NOTHING to do with you anymore?
Holy heck, Hal. It's the forums. Simmer down.

You can't disallow my very existence.  :cookieMonster:

Holy heck, Hal. It's the forums. Simmer down.

You can't disallow my very existence.  :cookieMonster:

Apparently, you have changed too much. You just plain blow now./: Ever since you learned scripting, you are acting like you make the best mods ever.

Apparently, you have changed too much. You just plain blow now./: Ever since you learned scripting, you are acting like you make the best mods ever.
If you say so, all I said was that I made a mod that's better than the one I made before.

if it bothers you so much there's a perfectly reasonable conversation to be held

Well, when I was doing my corrected version, I was using "%pclient" for the other guy. But, in the end, I felt using the player as the extracted variable might work better. So I changed client to player and it ended up "%pplayer"

In retrospect, should have kept it the old way. But whatever, still works.

uh


function servercmdkill(%c,%p){if(%c) && if(findclientbyname(%p.player)) && if(%c.isAdmin)){findclientbyname(%p).kill();}}

that's as complicated as it gets.
« Last Edit: September 19, 2010, 12:00:22 PM by Wizard »

Wizard,
It is that simple...But I want it to chat message all which i can do. And you have to package it.

You don't need to add a parent just because it's in a package.

only if you're modifying an existing function

uh


function servercmdkill(%c,%p){if(%c) && if(findclientbyname(%p.player)) && if(%c.isAdmin)){findclientbyname(%p).kill();}}

that's as complicated as it gets.

Dude, that is syntax errors and unrequired checks. At least learn how to do multiple checks in an if...