Author Topic: Doesn't do Anything  (Read 1123 times)

I made a blink script, all of the syntax is correct is just doesn't "do" anything. It's supposed to bottom print each number.
Here's the code.
Code: [Select]
function Blink_Timer(%client)
{

if($blinkTimer == 20)
{
$blinkTimer--;
%blinking20 = commandtoClient(%client, 'BottomPrint, $blink20);
schedule(1000,0,%blinking);
}
if($blinkTimer == 19)
{
$blinkTimer--;
%blinking19 = commandtoClient(%client, 'BottomPrint, $blink19);
schedule(1000,0,%blinking19);
}
if($blinkTimer == 18)
{
$blinkTimer--;
%blinking18 = commandtoClient(%client, 'BottomPrint, $blink18);
schedule(1000,0,%blinking18);
}
if($blinkTimer == 17)
{
$blinkTimer--;
%blinking17 = commandtoClient(%client, 'BottomPrint, $blink17);
schedule(1000,0,%blinking17);
}
if($blinkTimer == 16)
{
$blinkTimer--;
%blinking16 = commandtoClient(%client, 'BottomPrint, $blink16);
schedule(1000,0,%blinking16);
}
if($blinkTimer == 15)
{
$blinkTimer--;
%blinking15 = commandtoClient(%client, 'BottomPrint, $blink15);
schedule(1000,0,%blinking15);
}
if($blinkTimer == 14)
{
$blinkTimer--;
%blinking14 = commandtoClient(%client, 'BottomPrint, $blink14);
schedule(1000,0,%blinking14);
}
if($blinkTimer == 13)
{
$blinkTimer--;
%blinking13 = commandtoClient(%client, 'BottomPrint, $blink13);
schedule(1000,0,%blinking13);
}
if($blinkTimer == 12)
{
$blinkTimer--;
%blinking12 = commandtoClient(%client, 'BottomPrint, $blink12);
schedule(1000,0,%blinking12);
}
if($blinkTimer == 11)
{
$blinkTimer--;
%blinking11 = commandtoClient(%client, 'BottomPrint, $blink11);
schedule(1000,0,%blinking11);
}
if($blinkTimer == 10)
{
$blinkTimer--;
%blinking10 = commandtoClient(%client, 'BottomPrint, $blink10);
schedule(1000,0,%blinking10);
}
if($blinkTimer == 9)
{
$blinkTimer--;
%blinking9 = commandtoClient(%client, 'BottomPrint, $blink9);
schedule(1000,0,%blinking9);
}
if($blinkTimer == 8)
{
$blinkTimer--;
%blinking8 = commandtoClient(%client, 'BottomPrint, $blink8);
schedule(1000,0,%blinking8);
}
if($blinkTimer == 7)
{
$blinkTimer--;
%blinking7 = commandtoClient(%client, 'BottomPrint, $blink7);
schedule(1000,0,%blinking7);
}
if($blinkTimer == 6)
{
$blinkTimer--;
%blinking6 = commandtoClient(%client, 'BottomPrint, $blink6);
schedule(1000,0,%blinking6);
}
if($blinkTimer == 5)
{
$blinkTimer--;
%blinking5 = commandtoClient(%client, 'BottomPrint, $blink5);
schedule(1000,0,%blinking5);
}
if($blinkTimer == 4)
{
$blinkTimer--;
%blinking4 = commandtoClient(%client, 'BottomPrint, $blink4);
schedule(1000,0,%blinking4);
}
if($blinkTimer == 3)
{
$blinkTimer--;
%blinking3 = commandtoClient(%client, 'BottomPrint, $blink3);
schedule(1000,0,%blinking3);
}
if($blinkTimer == 2)
{
$blinkTimer--;
%blinking2 = commandtoClient(%client, 'BottomPrint, $blink2);
schedule(1000,0,%blinking2);
}
if($blinkTimer == 1)
{
$blinkTimer--;
%blinking1 = commandtoClient(%client, 'BottomPrint, $blink1);
schedule(1000,0,%blinking1);
}

if($blinkTimer == 0)
{
$blinkTimer = 20;
return;
}

}

(You can probably tell I'm a beginner.)
« Last Edit: January 02, 2014, 11:18:12 AM by Czar »

You might want to make all those if statements a switch

I'm not sure this will work:
Code: [Select]
%blinking20 = commandtoClient(%client, 'BottomPrint, $blink20);
schedule(1000,0,%blinking);
you need to set it to
Code: [Select]
%blinking20 = commandtoClient(%client, 'BottomPrint, $blink20);
schedule(1000,0,%blinking20);

Also a better way to do it would be
Code: [Select]
schedule(1000,0,'commandtoClient',%client,'BottomPrint',$blink20);although in your code the variable $blink20 is not set so it prints nothing

You might want to make all those if statements a switch

I'm not sure this will work:
Code: [Select]
%blinking20 = commandtoClient(%client, 'BottomPrint, $blink20);
schedule(1000,0,%blinking);
you need to set it to
Code: [Select]
%blinking20 = commandtoClient(%client, 'BottomPrint, $blink20);
schedule(1000,0,%blinking20);

Also a better way to do it would be
Code: [Select]
schedule(1000,0,'commandtoClient',%client,'BottomPrint',$blink20);although in your code the variable $blink20 is not set so it prints nothing


I did declare the variables. I just didn't show it.
They're here:

Code: [Select]
$blink1 = "<color:FFFFFFF>Blink Level: 1";
$blink2 = "<color:FFFFFFF>Blink Level: 2";
$blink3 = "<color:FFFFFFF>Blink Level: 3";
$blink4 = "<color:FFFFFFF>Blink Level: 4";
$blink5 = "<color:FFFFFFF>Blink Level: 5";
$blink6 = "<color:FFFFFFF>Blink Level: 6";
$blink7 = "<color:FFFFFFF>Blink Level: 7";
$blink8 = "<color:FFFFFFF>Blink Level: 8";
$blink9 = "<color:FFFFFFF>Blink Level: 9";
$blink10 = "<color:FFFFFFF>Blink Level: 10";
$blink11 = "<color:FFFFFFF>Blink Level: 11";
$blink12 = "<color:FFFFFFF>Blink Level: 12";
$blink13 = "<color:FFFFFFF>Blink Level: 13";
$blink14 = "<color:FFFFFFF>Blink Level: 14";
$blink15 = "<color:FFFFFFF>Blink Level: 15";
$blink16 = "<color:FFFFFFF>Blink Level: 16";
$blink17 = "<color:FFFFFFF>Blink Level: 17";
$blink18 = "<color:FFFFFFF>Blink Level: 18";
$blink19 = "<color:FFFFFFF>Blink Level: 19";
$blink20 = "<color:FFFFFFF>Blink Level: 20";
$blinkTimer = 20;

I did declare the variables. I just didn't show it.
They're here:
Ok then
Code: [Select]
schedule(1000,0,'commandtoClient',%client,'BottomPrint',$blink20);should work, all you need to do is replace the
Code: [Select]
%blinking20 = commandtoClient(%client, 'BottomPrint, $blink20);
schedule(1000,0,%blinking);

Nonononono... all of that code is complete nonsense.

There's basically 2 ways to achieve what you're trying to do.

Code: [Select]
function printCountdown(%client, %num)
{
%time = 0;
for(%i = %num; %i > 0; %i--)
{
schedule(%time, 0, commandToClient,%client,'bottomPrint', "<color:FFFFFFF>Blink Level: " + %i, 1);
%time += 1000;
}
}
Creates schedules for all messages at once, increasing the time until the message is sent by one second every time.

Code: [Select]
function printCountdown(%client, %num)
{
commandToClient(%client, 'bottomPrint', "<color:FFFFFFF>Blink Level: " + %num, 1);
if(%num > 0)
schedule(1000,0,printCountdown,%client,%num-1);
}
Send a message, and if the current count is > 0 it calls itself again one second later with a count one less.

Both can be used the same way: printCountdown(%client, 20);

Nonononono... all of that code is complete nonsense.

There's basically 2 ways to achieve what you're trying to do.

Code: [Select]
function printCountdown(%client, %num)
{
%time = 0;
for(%i = %num; %i > 0; %i--)
{
schedule(%time, 0, commandToClient,%client,'bottomPrint', "<color:FFFFFFF>Blink Level: " + %i, 1);
%time += 1000;
}
}
Creates schedules for all messages at once, increasing the time until the message is sent by one second every time.

Code: [Select]
function printCountdown(%client, %num)
{
commandToClient(%client, 'bottomPrint', "<color:FFFFFFF>Blink Level: " + %num, 1);
if(%num > 0)
schedule(1000,0,printCountdown,%client,%num-1);
}
Send a message, and if the current count is > 0 it calls itself again one second later with a count one less.

Both can be used the same way: printCountdown(%client, 20);


Now I'll I have to do is get it to loop every time the number reaches 0.

Now I'll I have to do is get it to loop every time the number reaches 0.
Code: [Select]
function printCountdown(%client, %num)
{
commandToClient(%client, 'bottomPrint', "<color:FFFFFFF>Blink Level: " + %num, 1);
if(%num >= 0)
schedule(1000,0,printCountdown,%client,%num-1);
else
schedule(1000,0,printCountdown,%client,20);
}

Code: [Select]
function printCountdown(%client, %num)
{
commandToClient(%client, 'bottomPrint', "<color:FFFFFFF>Blink Level: " + %num, 1);
if(%num >= 0)
schedule(1000,0,printCountdown,%client,%num-1);
else
schedule(1000,0,printCountdown,%client,20);
}

:/
Doesn't shown anything.

:/
Doesn't shown anything.
Well replace + %num with @ %num

Lol, been working with other languages Zeblote?

Infidel!