Author Topic: Coding Error  (Read 1088 times)

Code: [Select]
function serverCmdDelete(%admin, %target)
{
if(!admin.isadmin) return;
%target = findclientbyname(%target)
%target.player.delete;
}
I'm still new to coding, and I can't find what's wrong with this.
Please help.

The only possible use I see for this is to deliberately delete people's players, thus causing an eyesore rendering glitch.

I'm not going to help with this goal.

Like seriously, all I see you doing with this is proudly over-using it just to show off what you can do while saying "hurr durr derp look how smart I am look wat i can do" but w/e you'll find out how to fix this soon enough. I'll just tell people not to join your server.

Code: [Select]
function serverCmdDelete(%admin, %target)
{
if(!%admin.isadmin) return;
%target = findclientbyname(%target);
%target.player.delete();
}

Hey, that's pretty much all I really know. I only want to learn things, not to abuse it on other players.

And, I'll find something better that needs help, once I make something with an error...

Also, in case you have console spam with the command, here is a better version of the function, before doing anything it checks to see if the player exists, otherwise, it moves on.

Code: [Select]
function serverCmdDelete(%admin, %target)
{
if(!%admin.isadmin) return;
%target = findclientbyname(%target);
if(isObject(%target))
%target.player.delete();
}

You should be calling the first argument %client or %this or whatever but %admin is a bad choice, the client can also be a nonadmin
You should also check whether the player does actually exist
Code: [Select]
function servercmdDelete(%client, %target)
{
    if(!%client.isAdmin)
        return;
    if(isObject(%player = findClientByName(%target).player))
        %player.delete();
}

hey, when I learned the basic coding all i did was make shady stuff like this lol, helped me learn a bit.

hey, when I learned the basic coding all i did was make shady stuff like this lol, helped me learn a bit.
Should we be afraid of you?