UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

bad syntax on an 'else' statement?

broken avatar :(
Created 10 years ago
by AlecKeaneDUB
0 Members and 1 Guest are viewing this topic.
1,651 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 9 months ago
Posts
191
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Let's all just light up a blunt, and make stuff.
×
AlecKeaneDUB's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
AlecKeaneDUB's Contact & Social LinksAlecKeaneDUBaleckeanedubAlecKeaneDUB
So I have the code for bluntstuffy's soul chests and I get an error when trying to change one simple thing. Here is the part of code that supposedly has an error:
Code Snippet
Plaintext
chest_anims()
{
     players = getplayers();
     if(players.size > 1)
          {
               chest_1_kills = 100;
          }
     else
          {
               chest_1_kills = 10;
          }
     chest_2_kills = 25; //this chest isnt used
     chest_3_kills = 45; //this chest isnt used
     chest_4_kills = 65; //this chest isnt used
     chest_5_kills = 90; //this chest isnt used
     chest_6_kills = 140; //this chest isnt used
The error I get is a bad syntax on the 'else' statement, but I dont see what's wrong with it. The entire script works perfectly if I remove the 'if' and 'else' statements but I need this change in my map. I've also tried changing the else statement above to:
Code Snippet
Plaintext
else if(players.size <= 1)
But then I get bad syntax on the whole 'else if' line.

Thanks in advance for anyone who can help me :)
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 9 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Not sure if it'll fix it but the brackets should be down one level so that they line up with the if and else statements.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 9 months ago
Posts
191
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Let's all just light up a blunt, and make stuff.
×
AlecKeaneDUB's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
AlecKeaneDUB's Contact & Social LinksAlecKeaneDUBaleckeanedubAlecKeaneDUB
Not sure if it'll fix it but the brackets should be down one level so that they line up with the if and else statements.
gave it a shot...no luck :(
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 5 years ago
Posts
6,877
Respect
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
If you want scripts / features made for you, then contact me by PM or email / skype etc
it will cost you tho so if you have no intention of reciprocating don't even waste my time ;)
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
shouldnt this :

players = getplayers();

be :

players = get_players();

And do you have the second parenthesis? the "}" to close the function?

Code Snippet
Plaintext
chest_anims()
{
     players = get_players();
     if(players.size > 1)
     {
               chest_1_kills = 100;
     }
     else
     {
               chest_1_kills = 10;
     }
     chest_2_kills = 25; //this chest isnt used
     chest_3_kills = 45; //this chest isnt used
     chest_4_kills = 65; //this chest isnt used
     chest_5_kills = 90; //this chest isnt used
     chest_6_kills = 140; //this chest isnt used
} // HERE, not sure why that would throw the error on the else statement though?

or try this :

Code Snippet
Plaintext
chest_anims()
{
     players = get_players();
     chest_1_kills = 10;
     if(players.size > 1)
     {
               chest_1_kills = 100;
     }
     chest_2_kills = 25; //this chest isnt used
     chest_3_kills = 45; //this chest isnt used
     chest_4_kills = 65; //this chest isnt used
     chest_5_kills = 90; //this chest isnt used
     chest_6_kills = 140; //this chest isnt used
}
Last Edit: April 10, 2015, 04:13:51 am by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 9 months ago
Posts
191
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Let's all just light up a blunt, and make stuff.
×
AlecKeaneDUB's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
AlecKeaneDUB's Contact & Social LinksAlecKeaneDUBaleckeanedubAlecKeaneDUB
shouldnt this :

players = getplayers();

be :

players = get_players();

And do you have the second parenthesis? the "}" to close the function?

Code Snippet
Plaintext
chest_anims()
{
     players = get_players();
     if(players.size > 1)
     {
               chest_1_kills = 100;
     }
     else
     {
               chest_1_kills = 10;
     }
     chest_2_kills = 25; //this chest isnt used
     chest_3_kills = 45; //this chest isnt used
     chest_4_kills = 65; //this chest isnt used
     chest_5_kills = 90; //this chest isnt used
     chest_6_kills = 140; //this chest isnt used
} // HERE, not sure why that would throw the error on the else statement though?
not sure about the getplayers(); I have it the same way I do above in one of my other scripts and it works fine. And yeah I have the closing parenthesis its just farther down because this is only the first segment of the chest_anims() thread
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 5 years ago
Posts
6,877
Respect
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
You might not have seen my edit, try this

Code Snippet
Plaintext
chest_anims()
{
     players = get_players();
     chest_1_kills = 10;
     if(players.size > 1)
     {
               chest_1_kills = 100;
     }
     chest_2_kills = 25; //this chest isnt used
     chest_3_kills = 45; //this chest isnt used
     chest_4_kills = 65; //this chest isnt used
     chest_5_kills = 90; //this chest isnt used
     chest_6_kills = 140; //this chest isnt used

Otherwise, if you send your script over ill take a look. Its stuffys soul chests right?

also, can you show us a screenshot of the error cod is throwing?
Last Edit: April 10, 2015, 04:26:38 am by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 9 months ago
Posts
191
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Let's all just light up a blunt, and make stuff.
×
AlecKeaneDUB's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
AlecKeaneDUB's Contact & Social LinksAlecKeaneDUBaleckeanedubAlecKeaneDUB
You might not have seen my edit, try this

Code Snippet
Plaintext
chest_anims()
{
     players = get_players();
     chest_1_kills = 10;
     if(players.size > 1)
     {
               chest_1_kills = 100;
     }
     chest_2_kills = 25; //this chest isnt used
     chest_3_kills = 45; //this chest isnt used
     chest_4_kills = 65; //this chest isnt used
     chest_5_kills = 90; //this chest isnt used
     chest_6_kills = 140; //this chest isnt used

Otherwise, if you send your script over ill take a look. Its stuffys soul chests right?

also, can you show us a screenshot of the error cod is throwing?
I fixed the error but thanks anyway guys :)  it ended up being an error with the zone_manager and idk how that managed to happen, but its all good now. So thanks again

 
Loading ...