Author Topic: I don't get whats wrong with this code.  (Read 1225 times)

I made a quick admin-prefix addon for my server, but the console keeps saying that pretty much all the lines are wrong. What's the problem here?
Code: [Select]
function gameconnection::autoAdminCheck(%client)
{
parent::autoAdminCheck(%client);
messageclient(%client, '', "\c6 Welcome!");
if(%client.isAdmin)
{
%client.clanPrefix = "\c4[\c6Admin\c4]";
}
}

Only thing I can see that you did wrong is that you didn't package it. Also, I'm not sure if the parent needs to be returned or not.

Also, I'm not sure if the parent needs to be returned or not.
Yes, it does.

If you were trying to execute it manually, you may have had an issue with the .zip discovery or w/e. You should do discoverFile("path/to/file.zip"); or setModPaths(getModPaths()); before executing a script within a .zip file that's changed since the game started up.

If you try to overwrite a function and parent it you need to package it. It's weird, but I think it's so multiple packaged add-ons can modify the same function.

It's packaged (but i didn't show) but I'm not entirely sure what you mean by 'returning the parent'. Whenever I make modifications I exit out of blockland then come back in.

It's packaged (but i didn't show) but I'm not entirely sure what you mean by 'returning the parent'. Whenever I make modifications I exit out of blockland then come back in.
Like this:
Code: [Select]
function gameConnection::pooOnYouShmoo(%client)
{
      %parent = parent::pooOnYouShmoo(%client);

      //Code here

      return %parent;
}

Oh, duh. Well, I'll try it and see how it goes w/ returning the parent.

Whenever I make modifications I exit out of blockland then come back in.
Is the script in a .zip file? Are you re-executing it afterward?

If you were trying to execute it manually, you may have had an issue with the .zip discovery or w/e. You should do discoverFile("path/to/file.zip"); or setModPaths(getModPaths()); before executing a script within a .zip file that's changed since the game started up.


Code: [Select]
Package AdminPrefix{
function gameconnection::autoAdminCheck(%client)
{
messageclient(%client, '', "\c6 Welcome!");
if(%client.isAdmin)
{
%client.clanPrefix = "\c4[\c6Admin\c4]";
}
        parent::autoAdminCheck(%client);
}
};

This should work

Code: [Select]
Package AdminPrefix{
function gameconnection::autoAdminCheck(%client)
{
messageclient(%client, '', "\c6 Welcome!");
if(%client.isAdmin)
{
%client.clanPrefix = "\c4[\c6Admin\c4]";
}
        parent::autoAdminCheck(%client);
}
};

This should work
I'll give you a tip why that won't work at all. What do you think sets isAdmin?

I'll give you a tip why that won't work at all. What do you think sets isAdmin?
He's right.

Put the parent::autoAdminCheck(%client); before the rest of your code

I'll give you a tip why that won't work at all. What do you think sets isAdmin?
Stop being so damn smart zebo. Although he is right. You could schedule another function to call after AutoAdminCheck has finished its biz.

Code: [Select]
Package AdminPrefix{

Package is one of the only words (if not the only) in torquescript that is case sensitive. It must be all lowercase. package

Package is one of the only words (if not the only) in torquescript that is case sensitive. It must be all lowercase. package

Well forget..

Stop being so damn smart zebo. Although he is right. You could schedule another function to call after AutoAdminCheck has finished its biz.
Stop making codes when you don't know what you doing, and you don't know if it works