Author Topic: Fake Admin Command  (Read 2827 times)

I'm trying to learn how to script, and I am starting off with some pretty simple things. I tried to turn the console command
Code: [Select]
messageall('MsgAdminForce', "\c2PersonsName has become Super Admin (Auto)");  

Into a Server Command but I failed. Here is the script, can you tell me what is wrong?

Code: [Select]
function serverCmdFakeAdmin (%client,%target)
{
if(%client.isAdmin == true && isObject(findclientbyname(%target)))
{
messageall('MsgAdminForce', "\c2findeclientbyname(%target).name@" has become Super Admin (Auto)"); 

messageall('MsgAdminForce', "\c2"@findclientbyname(%target).getPlayerName()@" has become Super Admin (Auto)");

Strange, it still does not work :/


What are you typing in-game?

c2findeclientbyname
Is there supposed to be an e? You have put one in

What are you typing in-game?

/fakeadmin [name]

c2findeclientbyname
Is there supposed to be an e? You have put one in

Must had been a typo, but I changed it to this:
Code: [Select]
messageall('MsgAdminForce', "\c2"@findclientbyname(%target).getPlayerName()@" has become Super Admin (Auto)");

Is that the entire script? If it is, you need closing brackets..

For the sake of efficiency...
Code: [Select]
function serverCmdFakeAdmin (%client,%target)
{
%target = findeclientbyname(%target);
if(%client.isAdmin && isObject(%target))
{
messageall('MsgAdminForce', "\c2"@ %target.getPlayerName() @" has become Super Admin (Auto)"); 
As you see, I made it so that your findclientbyname'ing once.
I also took away the "== true" being that that's another way to check for trueness.

Is that the entire script? If it is, you need closing brackets..

The entire script is in my first post, my above post ^ Was not the entire script if that is what you were aiming your post at.

I also tried doing what Kalphiter edited in the script and it still does not work :/ Could the problem be that I am using just plain Notepad, should I use Notepad C++?

The entire script is in my first post, my above post ^ Was not the entire script if that is what you were aiming your post at.

I also tried doing what Kalphiter edited in the script and it still does not work :/ Could the problem be that I am using just plain Notepad, should I use Notepad C++?
}



I also tried doing what Kalphiter edited in the script and it still does not work :/ Could the problem be that I am using just plain Notepad, should I use Notepad C++?
I believe you're talking about Notepad++, and although you can write scripts perfectly fine without it, I use it and would highly recommend it.

You need to add closing brackets (}) to signal the end of sections started with opening brackets ({).