Author Topic: Warning script. Line 37 Syntax error.  (Read 781 times)

I have made this warning script for me to try out what I know. But unfortunately I am getting a syntax error on line 37.

Code: [Select]


//////////////////////////////////////////////
///////////Warn Clients              ///////////
///////////By Darren         ///////////
//////////////////////////////////////////////

package WarningScript
{
function ServerCmdWarnClient(%cl,%name)
        {
                if(%cl.isAdmin)
                        {
                            if(%name.isWarned=1)
                            {
                                MessageClient(%cl,"This user has already been warned.");
                            }
                            else
                            {
                                MessageClient(%name,"\c3You have been warned by a member of the moderating team.");
                                MessageClient(%name,"\c3Fail to come to terms with your warning and therefore will result in a \c4ban\3.");
                                %name.isWarned=1;
                            }
}
        }

function ServerCmdUnwarnClient(%cl,%name)
        {
               if(%cl.isAdmin)
{
                        MessageClient(%name,"\c3 You have been unwarned.");
                        %name.isWarned=0;
}
       }

Function ServerCmdCheckWarning(%cl,%name)   // LINE 37 STARTS HERE.
        {
                if(%cl.isAdmin)
{
                        if(%name.isWarned=1)
{
                                MessageClient(%cl," "@%name@"is on a warning");
}
                else
{
                                MessageClient(%cl," "@%name@"is not on a warning."); // ...
}
}
        }
        
function ServerCmdCheckStatus(%cl)
        {
                if(%cl.isWarned=1)
                {
                        messageclient(%cl,"\c3You are on a warning. \c7Be careful upon your next actions.");
                }
                else
                {
                        Messageclient(%cl,"\c3You're not on a warning.");
                }
        }
};
ActivatePackage(WarningScript);

function deactivatewarningscript()
    {
        deactivatePackage(WarningScript);
    }


They may be many errors in here, but this is my first script I have made.

Thank you.
« Last Edit: January 29, 2012, 09:35:01 AM by Wordy »

Your formatting is wat

i think it's because you capitalized function

Your formatting is wat
yes, i agree. I was using titan pad at the time.
i think it's because you capitalized function
yes, it was. thank you.

You shouldn't use the assignment operator for boolean expressions.

You shouldn't use the assignment operator for boolean expressions.
how do you mean?

how do you mean?
You're doing if(%name.isWarned=1)
This is setting isWarned to 1, it's not checking if it's already equal to 1. You want to change the = to ==
So if(%name.isWarned==1), or since you're checking a boolean value you can drop the == part and just use if(%name.isWarned), just like how you're doing admin checks

Just a heads up, I find it cleaner to make boolean values actually boolean. If you set something to true or false instead of 1, it lets you know when you're working with very big projects that that variable is binary.

You capitalized the f in function, for one. Don't do that.

do not confuse %name with a client; they are completely different

%name is what you type in
a client is an object id number
what you will need to do is %targetclient = findclientbyname(%name);
It is also reccommended that you do a check to make sure that the %targetclient exists after finding it.

do not confuse %name with a client; they are completely different

%name is what you type in
a client is an object id number
what you will need to do is %targetclient = findclientbyname(%name);
It is also reccommended that you do a check to make sure that the %targetclient exists after finding it.
That helps. Thanks.