Author Topic: Need help scripting a resizeme command!  (Read 1007 times)

I don't understand what is wrong with this script and why it's halting, please help me. I put ##s where the console said it's halting. This is my first script.
Code: [Select]
//RP Enhancements v0 patch 3
//Made by Frogger3140
//Current Commands: /ResizeMe

package RP_Enhancements
{
if(##i##sFile("Add-Ons/Script_FFC/server.cs"))
if(isFile("Add-Ons/System_ReturnToBlockland/server.cs"))
{
RTB_registerPref("Resize Me", "RP Enhancements", "RPE::ResizeMe", "int 0 1", "Script_RPE", 1, 0, 0);
}
else
{
$RPE::ResizeMe = 1;
}
}
function serverCmdResizeMe(%client,%ResizerX,%ResizerY,%ResizerZ)
if($RPE::ResizeMe == 1)
{
%client.player.setPlayerScale(%ResizerX SPC %ResizerY SPC %ResizerZ)
echo(%client SPC " used the resizeme command to resize to" %ResizerX SPC "," SPC %ResizerY SPC "," SPC "," %ResizerZ "!");
}
else
{
messageClient(%client,''."ResizeMe is disabled!"
}
}
else
{
error("RP_Enhancements Conflict: Please remove Fooly Fun Commands for this to work!");
}
}
};
activatepackage(RP_Enhancements);
« Last Edit: November 25, 2010, 09:39:04 PM by frogger3140 »

« Last Edit: November 25, 2010, 09:47:56 PM by frogger3140 »

Here's the console bit:

Code: [Select]
Loading Add-On: Script_RPE (CRC:1732878549)
Add-Ons/Script_RPE/RPEnhancements.cs Line: 7 - Syntax error.
>>> Some error context, with ## on sides of error halt:
/RP Enhancements v0 patch 3
//Made by Frogger3140
//Current Commands: /ResizeMe

package RP_Enhancements
{
^if(##i##sFile("Add-Ons/Script_FFC/server.cs"))
^^if(isFile("Add-Ons/System_ReturnToBlockland/server.cs"))

^^^{

^^^^RTB_registerPref("Resize Me", "RP Enhancements", "RPE::ResizeMe", "int 0 1", "Script_RPE", 1, 0, 0);
^^^}
^^else
^^^{
^^^^$RPE::ResizeMe = 1;
^^^}
^^}
>>> Error report complete.

ADD-ON "Script_RPE" CONTAINS SYNTAX ERRORS
« Last Edit: November 25, 2010, 09:52:46 PM by frogger3140 »

too tired to help right now nvm
« Last Edit: November 25, 2010, 10:35:30 PM by SpreadsPlague »

i think you might need a function inside the package, although i could be wrong

Trying to read through your messy indentation:

Why is there a random if inside the package, but outside of a function?
Whats with the second else at the end of the function?
You're missing a { between the serverCmdResizeme(...) and the if

This is the fix?

Code: [Select]
//RP Enhancements v0 patch 3.3
//THIS ADD-ON WILL NOT WORK WITH FFC
//Made by Frogger3140
//Current Commands: /ResizeMe

package RP_Enhancements
{
if(isFile("Add-Ons/System_ReturnToBlockland/server.cs"))
{
RTB_registerPref("Resize Me", "RP Enhancements", "RPE::ResizeMe", "int 0 1", "Script_RPE", 1, 0, 0);
}
else
{
$RPE::ResizeMe = 1;
}
}
function serverCmdResizeMe(%client,%ResizerX,%ResizerY,%ResizerZ)
{
if($RPE::ResizeMe == 1)
{
%client.player.setPlayerScale(%ResizerX SPC %ResizerY SPC %ResizerZ)
echo(%client SPC " used the resizeme command to resize to" %ResizerX SPC "," SPC %ResizerY SPC "," SPC "," %ResizerZ "!");
}
else
{
messageClient(%client,''."ResizeMe is disabled!"
}
}
};
activatepackage(RP_Enhancements);


EDIT: Still getting the error, tried to fix the code
Trying to read through your messy indentation:

Why is there a random if inside the package, but outside of a function?
Whats with the second else at the end of the function?
You're missing a { between the serverCmdResizeme(...) and the if
I needed a FFC Check because FFC will conflict with this command, and that's why there's the random if and second else.
EDIT: Error handling is being too harsh, removing the FFC Check,
EDIT: NOW THE RTB CHECK IS HALTING, that's loving it, rewriting the stuff.
Code: [Select]

package RP_Enhancements
{
if(##i##sFile("Add-Ons/System_ReturnToBlockland/server.cs"))
{
RTB_registerPref("Resize Me", "RP Enhancements", "RPE::ResizeMe", "int 0 1", "Script_RPE", 1, 0, 0);
}
else
{
$RPE::ResizeMe = 1;
}
}
function serverCmdResizeMe(%client,%ResizerX,%ResizerY,%ResizerZ)
>>> Error report complete.

ADD-ON "Script_RPE" CONTAINS SYNTAX ERRORS
« Last Edit: November 26, 2010, 11:46:45 AM by frogger3140 »

Packages might only be able to contain functions. Put them before/after the package.
There should be a line with a { after the line with function serverCmdResizeMe(%client,%ResizerX,%ResizerY,%ResizerZ)
You cannot have more than one else.
You cannot conditionally define functions, except by conditionally execing a file, or possibly conditionally activating a package.
Your test for FFC was wrong, it would cause an error if FFC was NOT there.

Code: [Select]

package RP_Enhancements
{
    function serverCmdResizeMe(%client,%ResizerX,%ResizerY,%ResizerZ)
    {
        if($RPE::ResizeMe == 1)
        {
            %client.player.setPlayerScale(%ResizerX SPC %ResizerY SPC %ResizerZ)
            echo(%client SPC " used the resizeme command to resize to" %ResizerX SPC "," SPC %ResizerY SPC "," SPC "," %ResizerZ "!");
        }
        else
        {
            messageClient(%client,''."ResizeMe is disabled!"
        }
    }
};

if(!isFile("Add-Ons/Script_FFC/server.cs"))
{
    activatepackage(RP_Enhancements);

    if(isFile("Add-Ons/System_ReturnToBlockland/server.cs"))
    {
        RTB_registerPref("Resize Me", "RP Enhancements", "RPE::ResizeMe", "int 0 1", "Script_RPE", 1, 0, 0);
    }
    else
    {
        $RPE::ResizeMe = 1;
    }
}
else
{
    error("RP_Enhancements Conflict: Please remove Fooly Fun Commands for this to work!");
}


Consider checking if FFC was disabled if it existed, not just if it existed. Also, this code looks abusable and doesn't seem to add anything to the game, so I would not reccomend releasing it publicly.

Packages might only be able to contain functions.
This is true. Packages are strictly for functions.

Quote
        {
            messageClient(%client,''."ResizeMe is disabled!"
        }
Forgot to put the ); at the end, and also, should the ''. be there, or not? Or should the period be a ,?
Hmmm
Quote
       {
            messageClient(%client,"ResizeMe is disabled!");
        }


Take the package out completely

Also, this code looks abusable and doesn't seem to add anything to the game, so I would not reccomend releasing it publicly.
I think I'll give up on this.