Author Topic: Rollname function syntax error?  (Read 735 times)

Hi, im making a script add-on and I'm getting a syntax error for 'line 45' which is the for loop part. The ## is the part where the console command marked the syntax error.

Basically it rolls up to 3 random names.

Code: [Select]
function serverCmdRollName(%client, %amount) {
    if(getSimTime()-%client.lastCooldownDice < $pref::Server::DiceCooldown) {
        messageclient(%client, '', "<color:DDDDDD>You have to wait!");
        return;
    }
    %client.lastCooldownDice = getSimTime();

    %people = ClientGroup.GetCount()-1;
    %amount = %amount < 1 ? 1 : (%amount > 3 ? 3:%amount);

    %min = 0;
    %max = %people;

    for(%i = 0; %i < %amount; ##i++)
    {
        %num = getRandom(0, %people);
        if(%list $= "")
            %list = "<color:ff0000>"@%num;
        else
            %list = %list@"\c6, <color:ff0000>"@num;
    }
    messageAll('', '<color:D20000>%1<color:DDDDDD> has rolled <color:ff0000>%2<color:DDDDDD>!', %client.getPlayerName(), %list);
}

The code seems fine though, why is my console command doing this?
« Last Edit: August 21, 2016, 04:29:57 AM by Timestamp »

You forgot a % before i++


Okay, I also have a syntax error in the } bracket ending part, but i also see nothing wrong??:


Code: [Select]
function serverCmdRollName(%client, %amount) {
    if(getSimTime()-%client.lastCooldownDice < $pref::Server::DiceCooldown) {
        messageclient(%client, '', "<color:DDDDDD>You have to wait!");
        return;
    }
    %client.lastCooldownDice = getSimTime();

    %people = ClientGroup.GetCount()-1;
    %amount = %amount < 1 ? 1 : (%amount > 3 ? 3:%amount);

    %min = 0;
    %max = %people;

    for(%i = 0; %i < %amount; ##%i++)
    {
        %num = getRandom(0, %people);
        if(%list $= "")
            %list = "<color:ff0000>"@%num;
        else
            %list = %list@"\c6, <color:ff0000>"@num;
    }
    messageAll('', '<color:D20000>%1<color:DDDDDD> has rolled <color:ff0000>%2<color:DDDDDD>!', %client.getPlayerName(), %list);
}##
« Last Edit: August 21, 2016, 05:52:49 AM by Timestamp »


Your post still shows that the % is still missing.
If you're executing from a zip without restarting Blockland, make sure you use setModPaths(getModPaths()); to update the zip contents.
This can cause a lot of issues if you don't.
Other than that I don't see what could be causing the issue.


Your post still shows that the % is still missing.
If you're executing from a zip without restarting Blockland, make sure you use setModPaths(getModPaths()); to update the zip contents.
This can cause a lot of issues if you don't.
Other than that I don't see what could be causing the issue.

i don't know how it didn't save the % but anyway