Author Topic: Script being obnoxious?  (Read 3369 times)

Alright, so I'm making a script for a Gun Game so I don't have to event it all. But the script is being uncooperative and I can't find out why. When I type /gungameon nothing happens and I checked the console.log and found this...
Code: [Select]
function serverCmdgungameon(%client)

{

^if(%client.isSuperAdmin)

^^{

^^^chatMessageAll(%client, "\c6Gun Game Enabled!", 3);

^^^activatePackage(GunGame);

^^}

};##
##


function serverCmdgungameoff(%client)

{

^if(%client.isSuperAdmin)

^^{

^^^deactivatePackage(GunGame);

^^^chatMessageAll(%client, "\c6Gun Game Disabled!", 3);

^^}

};



package GunGame

{^^

^function twoscore(%client,%player)

^{

^^if(%client.score == 2)
>>> Error report complete.

Now if I fiddle around with the script, I end up with this...
Code: [Select]
function serverCmdgungameon(%client)

{

^if(%client.isSuperAdmin)

^^{

^^^chatMessageAll(%client, "\c6Gun Game Enabled!", 3)

^^^activatePackage(##G##unGame)

^^}

};



function serverCmdgungameoff(%client)

{

^if(%client.isSuperAdmin)

^^{

^^^deactivatePackage(GunGame);

^^^chatMessageAll(%client, "\c6Gun Game Disabled!", 3);

^^}

};



package GunGame

{^^

^function twoscore(%client,%player)

^{

^^if(%client.score == 2)
>>> Error report complete.
What am I doing wrong?

How is the script being obnoxious?

It's called "I don't know where semicolons go."

Put them after statements and not after function declarations.

How is the script being obnoxious?

It's called "I don't know where semicolons go."

Put them after statements and not after function declarations.
Ah, I'm new to scripting so I don't know some things. :)
I'll try that out, thanks.

Also, would it be more efficient to make a new function for every 2 score? Or is there a way to shorten it?

I don't know what you're trying to accomplish, but if you're making twenty billion functions to handle every possible difference in events, chances are you're not doing it right.

I don't know what you're trying to accomplish, but if you're making twenty billion functions to handle every possible difference in events, chances are you're not doing it right.
Trying to make it so for every two points a client gets, he gets a better gun. I'm asking whether to use multiple functions for each one or if you can shorten.
Again, I'm really new to scripting and this is probably the first full script with a use, so I'm making a lot of mistakes. =/
« Last Edit: April 29, 2011, 12:17:13 AM by Daenth »

switch(%client.score)
{
   case 2: %image = GunImage;
   case 4: %image = GunAkimboImage;
}


or...


if(isObject($GunMod::GunUnlock[%client.score]))
   %image = $GunMod::GunUnlock[%client.score];


The latter is probably better because it does not need to be hardcoded and is not limited to 2-score incriments. Meaning, if you wanted to make the leap between Gun and Guns Akimbo 4 steps, you'd only need to make $GunMod::GunUnlock[6] Guns Akimbo instead of [4].

I don't think that would be a problem though.

Wouldn't it just work like an empty statement?

I don't know too much on Torque Script, but I know that in C++ (which I barely know), this would work. It seems somewhat similar.

switch(%client.score)
{
   case 2: %image = GunImage;
   case 4: %image = GunAkimboImage;
}


or...


if(isObject($GunMod::GunUnlock[%client.score]))
   %image = $GunMod::GunUnlock[%client.score];


The latter is probably better because it does not need to be hardcoded and is not limited to 2-score incriments. Meaning, if you wanted to make the leap between Gun and Guns Akimbo 4 steps, you'd only need to make $GunMod::GunUnlock[6] Guns Akimbo instead of [4].
Alright, I'll go ahead and try that. Thanks.

aww sad I worked on this a bit a few months ago.  Ill challenge you to make a better one!

switch(%client.score)
{
   case 2: %image = GunImage;
   case 4: %image = GunAkimboImage;
}


or...


if(isObject($GunMod::GunUnlock[%client.score]))
   %image = $GunMod::GunUnlock[%client.score];


The latter is probably better because it does not need to be hardcoded and is not limited to 2-score incriments. Meaning, if you wanted to make the leap between Gun and Guns Akimbo 4 steps, you'd only need to make $GunMod::GunUnlock[6] Guns Akimbo instead of [4].
Alright, I'm confused. I attempted to add that part of the script in many ways and I failed. How would you add it in?

aww sad I worked on this a bit a few months ago.  Ill challenge you to make a better one!
I made this a long time ago :D

Alright, I'm confused. I attempted to add that part of the script in many ways and I failed. How would you add it in?
Scratch that, I managed to figure it out. But using this, would they get the gun from the previous "case" if they were at like 5? Would it use case 4? Or would I have to do case 1: %item = gunItem.getID(); and case 2: %item = gunItem.getID();?

EDIT: Another quick question...
How would you make so when a player uses a grenade, he gets another back after 500MS?
« Last Edit: April 29, 2011, 11:51:33 PM by Daenth »

you go into the function where the grenade is thrown, and do something like this:

%client.grenaderegen = schedule(500, false, 'eval', "function to add grenade");

but regenerating grenades every half second is pretty overpowered.

Also, if you want it so the grenade regereration cancels if they pick up another grenade, you package the function where the grenade is picked up and do this:

if(isEventPending(%client.grenaderegen))
   cancel(%client.grenageregen);
« Last Edit: May 03, 2011, 04:59:27 PM by Nexus »

Alright, so I'm making a script for a Gun Game so I don't have to event it all. But the script is being uncooperative and I can't find out why. When I type /gungameon nothing happens and I checked the console.log and found this...
Code: [Select]
function serverCmdgungameon(%client)

{

^if(%client.isSuperAdmin)

^^{

^^^chatMessageAll(%client, "\c6Gun Game Enabled!", 3);

^^^activatePackage(GunGame);

^^}

[b]};##
##[/b]


function serverCmdgungameoff(%client)

{

^if(%client.isSuperAdmin)

^^{

^^^deactivatePackage(GunGame);

^^^chatMessageAll(%client, "\c6Gun Game Disabled!", 3);

^^}

};



package GunGame

{^^

^function twoscore(%client,%player)

^{

^^if(%client.score == 2)
>>> Error report complete.

Now if I fiddle around with the script, I end up with this...
Code: [Select]
function serverCmdgungameon(%client)

{

^if(%client.isSuperAdmin)

^^{

^^^chatMessageAll(%client, "\c6Gun Game Enabled!", 3)

^^^activatePackage(##G##unGame)

^^}

};



function serverCmdgungameoff(%client)

{

^if(%client.isSuperAdmin)

^^{

^^^deactivatePackage(GunGame);

^^^chatMessageAll(%client, "\c6Gun Game Disabled!", 3);

^^}

};



package GunGame

{^^

^function twoscore(%client,%player)

^{

^^if(%client.score == 2)
>>> Error report complete.
What am I doing wrong?
There aren't semicolons at the end of functions. Hope that helps.

You're about a week late on that response, and thank you for quoting the entire OP.