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

for loop help

HOT
broken avatar :(
Created 12 years ago
by Ege115
0 Members and 1 Guest are viewing this topic.
4,309 views
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
I try to make so to get a gun you will have to kill 3 zombies inside a trigger radius and it will continue its function.

So I made a for loop that will loop 3 times and checked if the zombies are touching the trigger, and then it waits till the zombie will die, then it will give an upgraded m9. But after 3 kills, it doesn't continue its function, why doesn't it do that?
Code Snippet
Plaintext
#include maps\_utility;
#include common_scripts\utility;
#include maps\_zombiemode_utility;

main()
{
place1 = GetEnt("place1","targetname");
place1 thread function("m9");
}

function(weap)
{
ice_model = GetEnt("ice_model","targetname");

while(isDefined(self))
{
ice_model hide();

self waittill("trigger", player);

currentWeapon = player GetCurrentWeapon();
if(currentWeapon == weap)
{
self trigger_off();

player takeweapon(currentweapon);
ice_model show();
for(j=0;j<50;j++)
{
zombs = getaispeciesarray("axis","all");
for(k=0;k<zombs.size;k++)
{
if(zombs[k] istouching(ice_radius))
{
zombs[k] waittill("death");
}
self trigger_on();
ice_model setmodel("zombie_3rd_perk_bottle_doubletap");
self waittill("trigger", player);
player giveweapon(currentweapon + "_upgraded");
player SwitchToWeapon(currentweapon + "_upgraded");
ice_model hide();
}
}
}
}
}
The trigger does disables itself and takes the weapon but it doesn't count the kills. :-\
Thanks in advance.

Edit: it is a trigger_radius that checks if the zombies are touching the trigger, and a trigger_use that will take the weapon and after 3 kills the triger_use will give a weapon.
Last Edit: May 18, 2014, 06:14:50 pm by Ege115
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 7 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
this code is a mess man ._. theres a method to do what you want using zombiemode_spawner and it only takes 10 lines of code
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
this code is a mess man ._. theres a method to do what you want using zombiemode_spawner and it only takes 10 lines of code
Uhm, can I maybe get some more details? Because I am lost. Have no idea how I would do that.
broken avatar :(
×
broken avatar :(
Location: usYork, SC
Date Registered: 15 March 2014
Last active: 7 years ago
Posts
214
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
WaW Scriptor
Signature
WaW Scriptor
×
PROxFTW's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
PROxFTW's Contact & Social LinksPROxFTWPROxFTWPROxFTWPROxFTW
The reason for this based on your script is it waits for all the zombies to die. Ill work on a script to hopefully fix this if you would like.
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
The reason for this based on your script is it waits for all the zombies to die. Ill work on a script to hopefully fix this if you would like.
Oh, I would really apreciate that, thank you. :)
I try to learn as much scripting as possible but as you all may notice it doesn't work out very well.
Last Edit: May 18, 2014, 09:12:20 pm by Ege115
broken avatar :(
×
broken avatar :(
Location: usYork, SC
Date Registered: 15 March 2014
Last active: 7 years ago
Posts
214
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
WaW Scriptor
×
PROxFTW's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
PROxFTW's Contact & Social LinksPROxFTWPROxFTWPROxFTWPROxFTW
I don't know what you have ice_radius defined to so just add that somewhere in function. This should work if not just let me know and I can try to adjust it a bit. Made basically off of your script.
Also don't worry you will get the hang of coding fast. I remember trying to first code. But good luck.
Code Snippet
Plaintext
Main()
{
Place1 = GetEnt( "place1", "targetname" );
place1 thread function( "m9" );
}

function( Weap )
{
ice_model = GetEnt( "ice_model", "targetname" );
KillCount = 0;//Maybe throw in while loop if it keeps running over and over otherwise here will be fine
while( IsDefined( self ) )
{
ice_model hide();
self waittill( "trigger", Player );
CurrWeap = Player GetCurrentWeapon();
if( CurrWeap == Weap )
{
self trigger_off();
Player takeweapon( CurrWeap );
ice_model show();
Zombs = GetAISpeciesArray( "axis", "all" );
for(;;)
{
for( i = 0; i < Zombs.size; i++ )
{
if( Zombs[i] IsTouching( ice_radius ) )
Zombs[i] waittill( "Death" );
else
continue;
KillCount += 1;
if( KillCount == 3 )
break;
wait .05;
}
if( KillCount == 3 )
break;
wait .05;
}
self trigger_on();
ice_model SetModel( "zombie_3rd_perk_bottle_doubletap" );
self waittill( "trigger", Player );
Player GiveWeapon( CurrWeap + "_upgraded" );
Player SwitchToWeapon( CurrWeap + "_upgraded" );
ice_model hide();
}
//If you only want to run this once add the if( KillCount == 3 ) break;
wait .05;
}
}
Edit: Saw a possible bug so just fixed it.
Last Edit: May 18, 2014, 09:26:25 pm by PROxFTW
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
I don't know what you have ice_radius defined to so just add that somewhere in function. This should work if not just let me know and I can try to adjust it a bit. Made basically off of your script.
Also don't worry you will get the hang of coding fast. I remember trying to first code. But good luck.
Code Snippet
Plaintext
Main()
{
Place1 = GetEnt( "place1", "targetname" );
place1 thread function( "m9" );
}

function( Weap )
{
ice_model = GetEnt( "ice_model", "targetname" );
KillCount = 0;//Maybe throw in while loop if it keeps running over and over otherwise here will be fine
while( IsDefined( self ) )
{
ice_model hide();
self waittill( "trigger", Player );
CurrWeap = Player GetCurrentWeapon();
if( CurrWeap == Weap )
{
self trigger_off();
Player takeweapon( CurrWeap );
ice_model show();
Zombs = GetAISpeciesArray( "axis", "all" );
for(;;)
{
for( i = 0; i < Zombs.size; i++ )
{
if( Zombs[i] IsTouching( ice_radius ) )
Zombs[i] waittill( "Death" );
else
continue;
KillCount += 1;
if( KillCount == 3 )
break;
wait .05;
}
if( KillCount == 3 )
break;
wait .05;
}
self trigger_on();
ice_model SetModel( "zombie_3rd_perk_bottle_doubletap" );
self waittill( "trigger", Player );
Player GiveWeapon( CurrWeap + "_upgraded" );
Player SwitchToWeapon( CurrWeap + "_upgraded" );
ice_model hide();
}
//If you only want to run this once add the if( KillCount == 3 ) break;
wait .05;
}
}
Edit: Saw a possible bug so just fixed it.
Hmm, it does the same as mine did, it took the weapon, but didn't enable the trigger after 3 zombie kills.
Any ideas? Your script looks right to me.
broken avatar :(
×
broken avatar :(
Location: usYork, SC
Date Registered: 15 March 2014
Last active: 7 years ago
Posts
214
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
WaW Scriptor
×
PROxFTW's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
PROxFTW's Contact & Social LinksPROxFTWPROxFTWPROxFTWPROxFTW
My best bet and this is what I usually do when I run into errors where something is incorrectly function is adding
self iPrintLn( "1" ); then 2... and it helps to figure if something is going on wrong. But try that out possibly. Even though you have not tried it just yet does it show the model after?
Edit: Also make sure you have ice_radius defined or in "".
Last Edit: May 18, 2014, 10:05:56 pm by PROxFTW
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
Have you tried running developer and developer_script?
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
Okey I added iprintln and I added it after were you check if the zombies are touching the trigger. And ingame it doesn't checks if the zombies are touching the trigger apperently because the iprintln doesn't show.

It works until the model shows and it takes the weapon too. But it seems to stop at between the istouching check and where the for loop starts.
broken avatar :(
×
broken avatar :(
Location: usYork, SC
Date Registered: 15 March 2014
Last active: 7 years ago
Posts
214
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
WaW Scriptor
×
PROxFTW's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
PROxFTW's Contact & Social LinksPROxFTWPROxFTWPROxFTWPROxFTW
What is ice_radius set to. What I mean by this is it in "" or is it defined like ice_radius = Whatever;
My second guess would be is it only checks Zomb[0] then stops like that but I don't believe it will do this.
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
  ::)

Like i said, use developer and developer_script. If there is a scripting error then there is a chance that it'll show with developer commands enabled.
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
  ::)

Like i said, use developer and developer_script. If there is a scripting error then there is a chance that it'll show with developer commands enabled.
It didn't work. no errors came.

What is ice_radius set to. What I mean by this is it in "" or is it defined like ice_radius = Whatever;
My second guess would be is it only checks Zomb[0] then stops like that but I don't believe it will do this.
The ice_radius is this, and the kvp's in radian is correct, and it is a trigger radius I use for that.
Code Snippet
Plaintext
ice_radius = getent("ice_radius","targetname");
broken avatar :(
×
broken avatar :(
Location: usYork, SC
Date Registered: 15 March 2014
Last active: 7 years ago
Posts
214
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
WaW Scriptor
×
PROxFTW's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
PROxFTW's Contact & Social LinksPROxFTWPROxFTWPROxFTWPROxFTW
What I am thinking is it isn't registering IsTouching then. Only Reason that I can think of from here.
broken avatar :(
  • n123q45
  • Deleted Member
×
broken avatar :(
n123q45
This user is deleted :(
thats waw for you. :) see if this can help you http://www.zeroy.com/script/entity/istouching.htm bt i am not able to see whats wrong

 
Loading ...