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

fail scripting help

HOT
broken avatar :(
Created 12 years ago
by daedra descent
0 Members and 1 Guest are viewing this topic.
6,411 views
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 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
SO i'm failing epically to get a basic script to execute(again). this is only a test script that i want to turn into something more, but if i can't even get this to work, then whats the point?

Thanks in advance for any help/info.

Code Snippet
Plaintext
distance_affect()
{
players = get_players();
for(i = 0; i < players.size; i++)
if( !players[i] HasWeapon( "zombie_colt" ) )
{
players[i] set_zombie_var( "zombie_score", 2000 );
}
}
Last Edit: December 22, 2013, 08:20:00 am by daedra descent
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
Signature
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
Try this:

Code Snippet
Plaintext
if( players[i] HasWeapon( "zombie_colt" ) == false)



Code Snippet
Plaintext
if( !players[i] HasWeapon( "zombie_colt" ) )
this one doesn't look right to me... Think the ! is in the wrong position.. not sure..
Last Edit: December 22, 2013, 08:38:31 am by BluntStuffy
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Try this:

Code Snippet
Plaintext
if( players[i] HasWeapon( "zombie_colt" ) == false)



Code Snippet
Plaintext
if( !players[i] HasWeapon( "zombie_colt" ) )
this one doesn't look right to me... Think the ! is in the wrong position.. not sure..

It was taken from the _zombiemode.gsc, but i'll try what you suggested.

_zombiemode.gsc
Code Snippet
Plaintext
	players = get_players();

for (i = 0; i < players.size; i++)
{
if (!players[i].is_zombie)
{
if( !players[i] HasWeapon( "stielhandgranate" ) )
{
players[i] GiveWeapon( "stielhandgranate" );
players[i] SetWeaponAmmoClip( "stielhandgranate", 0 );
}

broken avatar :(
×
broken avatar :(
Location: usCali(fornia)
Date Registered: 21 December 2013
Last active: 6 years ago
Posts
417
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Signature
The sound of God is the screech of tires, lights and magnets, bolts and wires. Strayed from the road, this very one, still to come. The sound of tires is the sound of God, the electric version.
×
mrpeanut188's Groups
mrpeanut188's Contact & Social Linksmrpeanut188mrpeanut1881337p34nut
Try this:
Code Snippet
Plaintext
if( players[i] !HasWeapon( "zombie_colt" ) )
Because the ! means false, try saying it out loud, might help.
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
People, the ! is perfectly fine the way it was:
Code Snippet
Plaintext
if( !players[i] HasWeapon( "zombie_colt" ) )
If you wanted, you could add brackets to make it clearer, but it's not needed:
Code Snippet
Plaintext
if( !( players[i] HasWeapon( "zombie_colt" ) ) )
However, this is wrong:
Code Snippet
Plaintext
players[i] set_zombie_var( "zombie_score", 				2000 );
There are no player specific zombie vars in WaW. If you want to set the players score, use this:
Code Snippet
Plaintext
players[i].score = 2000;
// The line below is to show how much was taken away / added, remove if you don't want this.
players[i] maps\_zombiemode_score::set_player_score_hud();

- Phil.
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
 :( ooops, srry daedra. Always best to wait for YaPhil i guess. my bad...
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
People, the ! is perfectly fine the way it was:
Code Snippet
Plaintext
if( !players[i] HasWeapon( "zombie_colt" ) )
If you wanted, you could add brackets to make it clearer, but it's not needed:
Code Snippet
Plaintext
if( !( players[i] HasWeapon( "zombie_colt" ) ) )
However, this is wrong:
Code Snippet
Plaintext
players[i] set_zombie_var( "zombie_score", 				2000 );
There are no player specific zombie vars in WaW. If you want to set the players score, use this:
Code Snippet
Plaintext
players[i].score = 2000;
// The line below is to show how much was taken away / added, remove if you don't want this.
players[i] maps\_zombiemode_score::set_player_score_hud();

- Phil.

No dice either way. The hasweapon check isn't working, because when i place a print before the test, it shows up on the screen, but not after. and yes i changed the zombie_colt into something else.
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
Code Snippet
Plaintext
distance_affect()
{
players = get_players();
for(i = 0; i < players.size; i++){
         if !(players[i] HasWeapon( "zombie_colt" ) )
         {
           players[i].score = 2000;
           players[i] maps\_zombiemode_score::set_player_score_hud();
         }
        }
}
This should be correct.
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
Ray1235, generally, C style languages require brackets around if. IF that's the case with GSC too (which I think it is), yours won't work too.

The hasweapon check isn't working, because when i place a print before the test, it shows up on the screen, but not after. and yes i changed the zombie_colt into something else.
My code should be correct, both in syntax and semantics. However, you probably are calling the code too soon (before _zombiemode::main()), when the players are not yet connected and initialized.
Also, your code doesn't contain a loop (other than the for), so it only iterates over all players once, then terminates. I don't know if you want it that way.

- Phil.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Ray1235, generally, C style languages require brackets around if. IF that's the case with GSC too (which I think it is), yours won't work too.
My code should be correct, both in syntax and semantics. However, you probably are calling the code too soon (before _zombiemode::main()), when the players are not yet connected and initialized.
Also, your code doesn't contain a loop (other than the for), so it only iterates over all players once, then terminates. I don't know if you want it that way.

- Phil.

I added a wait right before that function is called, turns out thats part of the issue. Now it's giving me a potential infinite loop in script warning after i added the loop.

I really think that the hasweapon check just isn't working right, because no matter what i spawn with i always get the debug text "working".

EDIT: Dafuq is up with the quote?

Function calls:
Code Snippet
Plaintext
	level.zone_manager_init_func = ::dlc3_zone_init;
level thread DLC3_threadCalls2();
level thread initammobox();
level thread power_switch_revive();
level thread power_switch_doubletap();
wait(5);
level thread distance_affect();

Function:
Code Snippet
Plaintext
distance_affect()
{
players = get_players();
for(i = 0; i < players.size; i++)
iprintlnbold("testing...");
for( ;; )
{
if( players[i] HasWeapon( "dp28" ) )
{
players[i].score = 2000;
players[i] maps\_zombiemode_score::set_player_score_hud();

iprintlnbold("working...");
// players[i] TakeWeapon( "zombie_colt" );
// players[i] GiveMaxAmmo();
}
}
}

Last Edit: December 22, 2013, 03:43:09 pm by daedra descent
Marked as best answer by daedra descent 12 years ago
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
First of all, never do an infinite loop without any wait()s.
Second of all, you probably want to put the player loop inside infinite loop, not the other way (it won't work).
Something like this:
Code Snippet
Plaintext
distance_affect()
{
    iprintlnbold("testing...");
    for( ;; )
    {
        players = get_players();
        for(i = 0; i < players.size; i++)
        {
            if( players[i] HasWeapon( "dp28" ) )
            {
                players[i].score = 2000;
                players[i] maps\_zombiemode_score::set_player_score_hud();
                iprintlnbold("working...");
            }
        }
        wait(0.5);
    }
}

- Phil.
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
i'm really NOT trying to be a smartass here, and i hope you don't mind i'm replying again. I'm just REALLY curious,
Doesn't this:

Code Snippet
Plaintext
if( !players[i] HasWeapon( "zombie_colt" ) )

have the exact same outcome as this:

Code Snippet
Plaintext
if( players[i] HasWeapon( "zombie_colt" ) == false)

why would you want to use the first over the last, is there any practical difference at all? (it's less typing i guess)
I know that line isn't the issue anymore, like i said i'm just really curious
Last Edit: December 22, 2013, 03:57:46 pm by BluntStuffy
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
First of all, never do an infinite loop without any wait()s.
Second of all, you probably want to put the player loop inside infinite loop, not the other way (it won't work).
Something like this:
Code Snippet
Plaintext
distance_affect()
{
    iprintlnbold("testing...");
    for( ;; )
    {
        players = get_players();
        for(i = 0; i < players.size; i++)
        {
            if( players[i] HasWeapon( "dp28" ) )
            {
                players[i].score = 2000;
                players[i] maps\_zombiemode_score::set_player_score_hud();
                iprintlnbold("working...");
            }
        }
        wait(0.5);
    }
}

- Phil.

Well, it works but it isn't exactly what i was looking for.

I want the code to execute only one when you receive the weapon, and then re-repeat when you get it a second time, etc.

But in the situation that i'm going to use this in, it won't matter because i have to take the weapon way anyway.
Last Edit: December 22, 2013, 04:09:27 pm by daedra descent
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
@daedra descent
Well, I didn't know what you wanted to achieve with this, so I just changed the code as little as possible to make it work.  :)
@BluntStuffy
There is no difference in semantics and performance should be equal too.
It kinda comes down to personal preference, although the explicit comparison of boolean variables with a boolean literal is considered unneccessary often. For example, the checkstyle tool, which does automated coding convention checks on Java code has an option to issue a warning if such explicit comparisons are used.

- Phil.
Last Edit: December 22, 2013, 04:21:21 pm by YaPh1l
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
@daedra descent
Well, I didn't know what you wanted to achieve with this, so I just changed the code as little as possible to make it work.  :)
@BluntStuffy
There is no difference in semantics and performance should be equal too.
It kinda comes down to personal preference, although the explicit comparison of boolean variables with a boolean literal is considered unneccessary often. For example, the checkstyle tool, which does automated coding convention checks on Java code has an option to issue a warning if such explicit comparisons are used.

- Phil.

Basically i want to add powerups to the random box by making the powerups "weapons", however i just relized that its going to be a bit more complicated than that because the "weapon" would replace the current weapon that the player has.

 
Loading ...