Author Topic: I Bugged up my Script and I Don't Know Why.  (Read 606 times)

So me and Nullable where on titanpad adding a timer and some more rolls and when I went to type /rtd it wouldn't come up with any message that RTD had rolled and I got a random effect.

halp
//********Source Code*************//
Code: [Select]
$RTD::Interval = 5 * 60 * 1000;
//Roll the dice and stuff.
//By Brickybob
//Nullable for fixing everything I managed to screw up and for adding the time script.
//Headcrab Zombie for fixing predator.
//And to everyone on Coding Help for fixing stuff.
//For reference: /c1 is for red, bad effects.
// /c4 is light blue, good effects.
// /c2 is for yellow, neutral effects.
function servercmdrtd(%client) {
    %lastRTDDelta = getSimTime() - %client.lastRTD;
    if (%client.lastRTD != 0 && %client.lastRTD > %lastRTDDelta - $RTD::Interval) {
        messageClient(%client, '', "You need to wait" SPC mCeil($RTD::Interval - %lastRTDDelta / 60000) SPC "minutes before you can roll again.");
    }
    %roll = getRandom(0, 15);
    switch(%roll) {
        case 0:
            announce(%client.name SPC "rolled a 0 and \c4GOT NOTHING!");
        case 1:
            %client.player.changedatablock(PlayerQuakeArmor);
            announce(%client.name SPC "rolled a 1 and \c2became a Quake dude.");
            //Evenin' mondays!
        case 2:
            %client.player.setHealth(2);
            announce(%client.name SPC "rolled a 2 and \c1got his health set to 2!");
        case 3:
            %client.player.addHealth(25);
            announce(%client.name SPC "rolled a 3 and \c4got +25 health!");
        case 4:
            %client.player.hideNode("ALL");
            announce(%client.name SPC "rolled a 4 and \c4became a PREDATOR!");
        case 5:
            %client.player.addVelocity(0 SPC 0 SPC 200);
            announce(%client.name SPC "rolled a 5 and \c1was sent to the moon!");
        case 6:
            %client.player.changedatablock(PlayerFuelJet);
            announce(%client.name SPC "rolled a 6 and \c1won nerfed jets!");
        case 7:
            %client.player.setPlayerScale(0.2 SPC 0.2 SPC 0.2);
            announce(%client.name SPC "rolled a 7 and \c2became a smurf.");
        case 8:
            %client.player.setPlayerScale(2 SPC 2 SPC 2);
            announce(%client.name SPC "rolled a 8 and \c2became a giant!");
        case 9:
            RTD_addItem(%client, RocketLauncherItem);
            announce(%client.name SPC "rolled a 9 and \c4won a Rocket Launcher!");
        case 10:
            %client.player.changedatablock(PlayerDemigod);
            announce(%client.name SPC "rolled a 10 and \c4became a Demigod!  (500 HP, fast as Quake dude)");  //500 HP beast.
        case 11:
            %client.player.changedatablock(PlayerCripple);
            announce(%client.name SPC "rolled a 11 and \c1became immobile!  (100 HP, can not move.)");
        case 12:
            %client.player.kill();
            announce(%client.name SPC "rolled a 12 and \c1was slain!");
        case 13:
            RTD_timeBombTick(%client);
            announce(%client.name SPC "rolled a 13 and \c1is now a armed timebomb!");
        case 14:
            %client.player.changedatablock(PlayerBoostedHP);
            announce(%client.name SPC "rolled a 14 and \c4got boosted health! (200 HP, default movement.);
    }
    %client.lastRTD = getSimTime();
}
function RTD_timeBombTick(%cl, %tick) {
//    %explodeTick = 10;
    %explodeTick = getRandom(10, 60);
    if (%explodeTick - %tick > 0) {
        schedule(RTD_timeBombTick(%cl, %tick + 1);
        %cl.bottomPrint(%explodeTick - %tick @ "...", 3);
    } else {
        // Fire explosion
    }
}
function RTD_addItem(%cl, %item) {
    %item = %item.getID();
    for (%i = 0;%i < 5;%i++) {
        if (isObject(%cl.player.tool[%i]))
            continue;
        
        %cl.player.tool[%i] = %item;
        messageClient(%cl, 'MsgItemPickup', "", %i, %item);
        break;
    }
}

Code: [Select]
$RTD::Interval = 5 * 60 * 1000;
//Roll the dice and stuff.
//By Brickybob
//Nullable for fixing everything I managed to screw up and for adding the time script.
//Headcrab Zombie for fixing predator.
//And to everyone on Coding Help for fixing stuff.
//For reference: /c1 is for red, bad effects.
// /c4 is light blue, good effects.
// /c2 is for yellow, neutral effects.
function servercmdrtd(%client) {
    %lastRTDDelta = getSimTime() - %client.lastRTD;
    if (%client.lastRTD != 0 && %client.lastRTD > %lastRTDDelta - $RTD::Interval) {
        messageClient(%client, '', "You need to wait" SPC mCeil($RTD::Interval - %lastRTDDelta / 60000) SPC "minutes before you can roll again.");
    }
    %roll = getRandom(0, 15);
    switch(%roll) {
        case 0:
            announce(%client.name SPC "rolled a 0 and \c4GOT NOTHING!");
        case 1:
            %client.player.changedatablock(PlayerQuakeArmor);
            announce(%client.name SPC "rolled a 1 and \c2became a Quake dude.");
            //Evenin' mondays!
        case 2:
            %client.player.setHealth(2);
            announce(%client.name SPC "rolled a 2 and \c1got his health set to 2!");
        case 3:
            %client.player.addHealth(25);
            announce(%client.name SPC "rolled a 3 and \c4got +25 health!");
        case 4:
            %client.player.hideNode("ALL");
            announce(%client.name SPC "rolled a 4 and \c4became a PREDATOR!");
        case 5:
            %client.player.addVelocity(0 SPC 0 SPC 200);
            announce(%client.name SPC "rolled a 5 and \c1was sent to the moon!");
        case 6:
            %client.player.changedatablock(PlayerFuelJet);
            announce(%client.name SPC "rolled a 6 and \c1won nerfed jets!");
        case 7:
            %client.player.setPlayerScale(0.2 SPC 0.2 SPC 0.2);
            announce(%client.name SPC "rolled a 7 and \c2became a smurf.");
        case 8:
            %client.player.setPlayerScale(2 SPC 2 SPC 2);
            announce(%client.name SPC "rolled a 8 and \c2became a giant!");
        case 9:
            RTD_addItem(%client, RocketLauncherItem);
            announce(%client.name SPC "rolled a 9 and \c4won a Rocket Launcher!");
        case 10:
            %client.player.changedatablock(PlayerDemigod);
            announce(%client.name SPC "rolled a 10 and \c4became a Demigod!  (500 HP, fast as Quake dude)");  //500 HP beast.
        case 11:
            %client.player.changedatablock(PlayerCripple);
            announce(%client.name SPC "rolled a 11 and \c1became immobile!  (100 HP, can not move.)");
        case 12:
            %client.player.kill();
            announce(%client.name SPC "rolled a 12 and \c1was slain!");
        case 13:
            RTD_timeBombTick(%client);
            announce(%client.name SPC "rolled a 13 and \c1is now a armed timebomb!");
        case 14:
            %client.player.changedatablock(PlayerBoostedHP);
            announce(%client.name SPC "rolled a 14 and \c4got boosted health! (200 HP, default movement.");
    }
    %client.lastRTD = getSimTime();
}
function RTD_timeBombTick(%cl, %tick) {
//    %explodeTick = 10;
    %explodeTick = getRandom(10, 60);
    if (%explodeTick - %tick > 0) {
        schedule(RTD_timeBombTick(%cl, %tick + 1);
        %cl.bottomPrint(%explodeTick - %tick @ "...", 3);
    } else {
        // Fire explosion
    }
}
function RTD_addItem(%cl, %item) {
    %item = %item.getID();
    for (%i = 0;%i < 5;%i++) {
        if (isObject(%cl.player.tool[%i]))
            continue;
       
        %cl.player.tool[%i] = %item;
        messageClient(%cl, 'MsgItemPickup', "", %i, %item);
        break;
    }
}
Thank god for syntax highlighting.

Code: [Select]

Thank god for syntax highlighting.
What do you use for your scripting?  Mine doesn't give highlights.

Edit: Copy and pasted into rollthedice.cs and it still doesn't work.
« Last Edit: December 06, 2011, 06:33:22 PM by brickybob »

What do you use for your scripting?  Mine doesn't give highlights.

Edit: Copy and pasted into rollthedice.cs and it still doesn't work.
I use whatever I use, doesn't matter.
Post your console.log.

I use whatever I use, doesn't matter.
Post your console.log.
k

Edit: The part you are looking for is:
Code: [Select]
Loading Add-On: Server_RTD (CRC:-1949257597)
Add-Ons/Server_RTD/rollthedice.cs Line: 69 - Syntax error.
>>> Some error context, with ## on sides of error halt:
            announce(%client.name SPC "rolled a 14 and \c4got boosted health! (200 HP, default movement.");

    }

    %client.lastRTD = getSimTime();

}

function RTD_timeBombTick(%cl, %tick) {

//    %explodeTick = 10;

    %explodeTick = getRandom(10, 60);

    if (%explodeTick - %tick > 0) {

        schedule(RTD_timeBombTick(%cl, %tick + 1);##
##
        %cl.bottomPrint(%explodeTick - %tick @ "...", 3);

    } else {

        // Fire explosion

    }

}

function RTD_addItem(%cl, %item) {

    %item = %item.getID();

    for (%i = 0;%i < 5;%i++) {

        if (isObject(%cl.player.tool[%i]))

            continue;
>>> Error report complete.

ADD-ON "Server_RTD" CONTAINS SYNTAX ERRORS
(probably)
« Last Edit: December 06, 2011, 07:41:39 PM by brickybob »

Quote
Code: [Select]
schedule(RTD_timeBombTick(%cl, %tick + 1);

Basically, there is an extra schedule( in front of a function call. There are two fixes:

Almost certainly wrong:
Code: [Select]
RTD_timeBombTick(%cl, %tick + 1);

Probably what you wanted:
Code: [Select]
schedule([some delay, in 1000ths of a second], 0, RTD_timeBombTick, %cl, %tick + 1);


Looks like half a change, which someone forgot to finish.