Author Topic: Need help scripting.  (Read 6796 times)

Oops, I forgot the 'd' in findclientbyname. That should fix the first one.
For the second one, I'm pretty sure vectorDist doesn't exist, and your math would be wrong anyway
use vectorLen(vectorSub(%player1pos,%player2pos));

This script does not even seem to do anything.
I type in /Kill Zefoo and it does not kill me.
« Last Edit: June 27, 2012, 03:56:41 PM by zefoo »

Why are these scripts not working?
Code: [Select]
function serverCmdKill(%client,%targetName)
{
    Echo("Killing " & %targetname)
    if(%client.isAdmin)
    {
        finclientbyname(%targetname).player.kill();
    }
    if(%client.isSuperAdmin)
    {
        finclientbyname(%targetname).player.kill();
    }
}
Code: [Select]
function serverCmdKill(%client,%targetName)
{
    Echo(Killing SPC %targetname)
    if(%client.isAdmin || %client.isSuperAdmin)
        findClientByName(%targetname).player.kill();
}
The problem with your script was that you misspelled findClientByName, also you can compact the script by adding the || to the if statement.
|| means or, so the if statement there means if the client is an admin OR if the client is a super admin.

Code: [Select]
function serverCmdKill(%client,%targetName)
{
    Echo(Killing SPC %targetname)
    if(%client.isAdmin || %client.isSuperAdmin)
        findClientByName(%targetname).player.kill();
}
The problem with your script was that you misspelled findClientByName, also you can compact the script by adding the || to the if statement.
|| means or, so the if statement there means if the client is an admin OR if the client is a super admin.
But even if i type in /Kill Zefoo when the FindClientByName is spelled correctly it does not work.

This script does not even seem to do anything.
I type in /Kill Zefoo and it does not kill me.

Also, isAdmin returns true for super admins so he doesn't even need the other one

I'm pretty sure vectorDist doesn't exist

What? It's a default function..

Why does this sctipt
Code: [Select]
function serverCmdKill(%client,%targetName)
{
    Echo("Killing " & %targetname)
    if(%client.isAdmin)
    {
        findclientbyname(%targetname).kill();
    }
}
Not kill me when I type /Kill Zefoo
?

You need findclientbyname(target).player.kill();

because you need to use the .player part

Code: [Select]
function serverCmdKill(%client,%targetName)
{
    Echo("Killing " & %targetname)
    if(%client.isAdmin)
    {
        findclientbyname(%targetname).player.kill();
    }
}

also you could check if the client has a player object by doing this

Code: [Select]
function serverCmdKill(%client,%targetName)
{
    Echo("Killing " & %targetname)
    if(%client.isAdmin && isObject(findclientbyname(%targetname).player))
    {
        findclientbyname(%targetname).player.kill();
    }
else
    {
        announce("Invalid player!");
    }
}

« Last Edit: June 27, 2012, 04:11:05 PM by Wordy »

because you need to use the .player part
So this should kill me when I type in /Kill Zefoo?
Code: [Select]
function serverCmdKill(%client,%targetName)
{
    Echo("Killing " & %targetname)
    if(%client.isAdmin)
    {
        findclientbyname(%targetname).player.kill();
    }
}


yes, but it wouldn't echo properly, you don't use the & symbol to put 2 strings together, you use @


yes, but it wouldn't echo properly, you don't use the & symbol to put 2 strings together, you use @
And it's missing an ; and for the person's name you would want Echo("Killing " @ findClientByName(%targetname).name);

didn't notice that
So you noticed neither the & nor the missing semicolon?