Author Topic: AAAK has a syntax in line three, need help on how to fix it  (Read 768 times)

I've been learning how to script, and thanks to AGlassOfMilks getWords Tutorial, and Placid for help with the end of the script and editing, We have created an Auto Admin Ask Kicker,(Or AAAK for short.)

Yes, the name just came to me, then I found out that their was a failed add-on named this.

When I run this script, it says everything is fine except for line three, which contains a syntax error.

Could someone help me out?  I don't see what's wrong with thie line.

Code: [Select]
package AutoAdminAskKicker
{
    %string = "Can I have admin?";
    getWords(%string,1,4);
        if(%client.isadmin)
        return;
            {
            findclientbyname(%name);
            %name.player.delete("Sorry, No Asking For Admin");
    }
};
activatepackage (AutoAdminAskKicker);
« Last Edit: August 17, 2009, 05:05:10 PM by trumpetfan »

        if(%client.isadmin);
        }
        return;
        {


        if(%client.isadmin);
        }
        return;
        {


So those two curly brackets are unneeded?

Either that, or they need to be swapped out?

So those two curly brackets are unneeded?
Well, I actually didn't think of that.

They're backwards.

No, you don't need them anyway.


I don't know where to start with this one.

This has more than one syntax error, and many many logic errors.

Syntax:
Remove else
%string="Can I have admin?" requires both a semi colon at the end and a rethinking as you cannot use a localized variable like a global variable.
Your use of getWords is confounding, remove function:: and %client,%name, You also need to have it set a variable.
findclientbyname(%name) is not putting that into a variable.
%name.delete("Sorry, no asking for admin"); is deleting a string variable
} { brackets are backwards

Logic errors:
Everything.
For some reason every new scripter throws every last thing into a package.

-snip-
Alright.
I was told by someone to package the script alot.

I think I'm at the point where I think I can script, but I'm actually really bad.
Thanks for your help, I'm reworking on it.
« Last Edit: August 17, 2009, 01:38:05 PM by trumpetfan »

For some reason every new scripter throws every last thing into a package.
I never did that.

Ontop of what rkynick said:

Variables, local or global, cannot be put into a package unless in a function. Only functions can be put into packages.
Your function isn't being called correctly, though getWords is already a function.
Proper syntax for a function would be:
function namehere(%all,%local,%vars)
{
...
not function::namehere(%jibberish,"not even local");
...

If statements do not have semicolons at the end.
The only things that have semicolons are:
-Datablocks.
-Packages.
-Objects.
-Calling a function. (ex, function();)
-Separating the for statement ( ex, for([Set the value];[check the value];[change the value])  )
-Setting a value. (ex, %localVar = value;)

Things that do not have a semicolon:
-Functions
-Calling functions within an argument. (ex, function(calledfunction()[No semicolon here]);
-Values within an argument.
-Functions and values within a while, or if statement.
-If
-While
-For (the ending part)

And well, I don't even feel like picking through the rest.

I never did that.
So you consider yourself a very new scripter?

The problem, kalph, is that your case is not relevant. I should not have to explain to you that I am speaking in relevance to new scripters of the current time.

Alright.
I was told by someone to package the script alot.
The main issue is that there's no logic involved. You have bits and pieces right but in the wrong places.

Code: [Select]
Package AAAK
{
 function servercmdmessagesent(%client,%msg){
   parent::servercmdmessagesent(%client,%msg);
   //write a code between these two lines in which %msg is checked to see if it
   //includes "Can I have admin?" and then do whatever to the player who said it.
 }
};
activatepackage(AAAK);

That is how you should probably start off.

Lemme explain:

First, for this we need a package because we are adding a bit of code to an already existent function. There's reasoning to the use of packages.
Our function servercmdmessagesent is the function that is called when the player says something. This is important: before you were just throwing things together. Now we actually have a relevant function involved.
Our variables are grounded: They exist for once.
Parent::servercmdmessagesent is needed so that the script doesn't break chatting. This calls the original function. For example, in this case calling Parent::servercmdmessageset sends the message out.


Also: listen to chrono

Alright.

I'm very new, and I wanted to try this.

I'm going to the pool, I'll be back.