Author Topic: My chat script  (Read 480 times)

Ok i was making a script that Puts admin/SuperAdmin in front of the players name and this is what i have so far
Code: [Select]
pacakge AdminChat {
findclientbyname(%name);
if(!%name.isSuperAdmin)
%name.clanprefix=("/c4[/c2SuperAdmin/c4]");
else
if(!%name.isAdmin)
%name.clanprefix=("/c4[/c2Admin/c4]");
else
%name.clanprefix=("/c4[/c2Guest/c4]");
}
ActivatePackage AdminChat
is there any problem cause it wont work on my server
Code: [Select]
package AdminChat {
GameConnection::autoSuperAdminCheck
findclientbyname(%name)
%name.clanprefix=("/c4[/c2SuperAdmin/c4]");
else
GameConnection::autoAdminCheck
%name.clanprefix=("/c4[/c2Admin/c4]");
else
%name.clanprefix=("/c4[/c2Guest/c4]");
}
ActivatePackage("AdminChat");
//Would this work?
« Last Edit: August 29, 2009, 10:33:59 AM by Pah1023 »

You can't have code in a package like that, packages hold functions which contain code. You need to create a function with that code in, that is called maybe in the GameConnection::autoAdminCheck method.

Ok i was making a script that Puts admin/SuperAdmin in front of the players name and this is what i have so far

pacakge AdminChat {
   findclientbyname(%name);
   if(!%name.isSuperAdmin)

The line in the bold is where you messed up.
with if statements, if you have a ! before everything, you're basicly saying
if(%name.isnotSuperAdmin)

So, to start, get rid of the ! for the if statements.

Code: [Select]
pacakge* AdminChat {
findclientbyname(%name);
if(!%name.isSuperAdmin) //Wouldn't this make it if he ISN'T a superadmin?
%name.clanprefix=("/c4[/c2SuperAdmin/c4]");
else
if(!%name.isAdmin) // ''
%name.clanprefix=("/c4[/c2Admin/c4]");
else
%name.clanprefix=("/c4[/c2Guest/c4]");
}
ActivatePackage(AdminChat);
is there any problem cause it wont work on my server
Code: [Select]
package AdminChat {
GameConnection::autoSuperAdminCheck
findclientbyname(%name)
%name.clanprefix=("/c4[/c2SuperAdmin/c4]");
else
GameConnection::autoAdminCheck
%name.clanprefix=("/c4[/c2Admin/c4]");
else
%name.clanprefix=("/c4[/c2Guest/c4]");
}
ActivatePackage("AdminChat");
//This is all wrong. ._.
EDIT: Whops, forgot to fix.

package is spelled package not pacakge
all you need is this: (not sure about the clanprefix part)

Code: [Select]
package adminchat
{
   function GameConnection::AutoAdminCheck(%client)
   {
        if(%client.isadmin)
        {
            GameConnection.clanprefix="[SUPER-ADMIN]";
        }
        else if(%client.issuperadmin)
       {
            GameConnection.clanprefix="[ADMIN]";
        }
        else
        {
            GameConnection.clanprefix="[GUEST]";
        }
   }
};
activatepackage(AdminChat);
Do not copy and paste this, i had to use spaces for tabs.
« Last Edit: August 29, 2009, 11:38:23 AM by Placid »

EDIT: Whops, forgot to fix.

package is spelled package not pacakge
all you need is this: (not sure about the clanprefix part)

Code: [Select]
package adminchat
{
   function GameConnection::AutoAdminCheck(%client)
   {
        if(%client.isadmin)
        {
            GameConnection.clanprefix="[SUPER-ADMIN]";
        }
        else if(%client.issuperadmin)
       {
            GameConnection.clanprefix="[ADMIN]";
        }
        else
        {
            GameConnection.clanprefix="[GUEST]";
        }
   }
};
activatepackage(AdminChat);
Do not copy and paste this, i had to use spaces for tabs.
nvm got it to work thanks though