While and Now

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

User avatar
alividerci
Posts: 561
Joined: 11 Feb 2012, 07:03

While and Now

Post by alividerci » 17 Sep 2014, 18:26

I dont know what's up??? it me write "Too many resourses", why?

Code: Select all

/// In PlayLoop when player spawned
declare VerificatorWeaponGetDelay for Player = True;
		declare DelayGetWeapons for Player = 0;
		if(VerificatorWeaponGetDelay){
				DelayGetWeapons(Player, 100);
				VerificatorWeaponGetDelay = False;
		}
declare CountRepeats for Player;
while(CountRepeats <= 10){
			if(Now > DelayGetWeapons){ ///Here warning and stoping script
			if(Net_Combo_AmmoMax["Rocket"] < 10) PickUpWeapon(Player, "Rocket");
			if(Net_Combo_AmmoMax["Arrow"] < 7) PickUpWeapon(Player, "Arrow");
			if(Net_Combo_AmmoMax["Nucleus"] < 5) PickUpWeapon(Player, "Nucleus");
CountRepeats += 1;
VerificatorWeaponGetDelay = True;
			}
		}
///In functions
Void DelayGetWeapons(CSmPlayer _Player, Integer _Time){
declare DelayGetWeapons for _Player = 0;
DelayGetWeapons = Now + _Time;
}
Last edited by alividerci on 18 Sep 2014, 06:38, edited 1 time in total.

User avatar
TMarc
Posts: 15381
Joined: 05 Apr 2011, 19:10
Location: Europe
Contact:

Re: While and Now

Post by TMarc » 17 Sep 2014, 21:12

you do 2x "declare DelayGetWeapons for Player = 0;", even inside the function DelayGetWeapons.
This looks strange.

And I'm not sure if you have to add a incrementation of CountRepeats in the while loop.

Please give a screenshot of the exact error message.
maniaplanet forum global moderator

Link list with FAQ, Support, Wiki, Tutorials, Community activities, and much more.

System specs: Intel i7-970 12GB RAM, nVidia RTX 2060 6GB, Creative SB X-Fi, 2xSSD 1xHDD
Discord: TMarc#3002

User avatar
steeffeen
Translator
Translator
Posts: 2472
Joined: 14 Oct 2012, 16:22
Location: Germany

Re: While and Now

Post by steeffeen » 17 Sep 2014, 21:34

Code: Select all

while(CountRepeats <= 10){
[...]
}
is simply an infinite loop, that's all
    Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

    ManiaControl, FancyManiaLinks

    User avatar
    TMarc
    Posts: 15381
    Joined: 05 Apr 2011, 19:10
    Location: Europe
    Contact:

    Re: While and Now

    Post by TMarc » 17 Sep 2014, 21:50

    infinite loops are bad if there is no relaxation point, like a sleep or waiting call.
    Here there are only a few if's, therefore I think the error "too many resources" is either a overrun or a check if cpu runtime is exceeding.
    maniaplanet forum global moderator

    Link list with FAQ, Support, Wiki, Tutorials, Community activities, and much more.

    System specs: Intel i7-970 12GB RAM, nVidia RTX 2060 6GB, Creative SB X-Fi, 2xSSD 1xHDD
    Discord: TMarc#3002

    oliverde8
    Posts: 1345
    Joined: 16 Jun 2010, 07:33
    Location: in a Blue Box

    Re: While and Now

    Post by oliverde8 » 17 Sep 2014, 22:13

    well the infinite loop is probably the cause of Too many resources,
    When a script spends more then a certain amount of resources(not sure how the resources are counted) during a single frame it stops and makes that error.

    putting a yield in the infinite loop will probably fix the to many resources error but I doubt the code would do what it was intended to do, :)
    Image
    Developper for The next generation, Clean and Powerfull controller eXpansion for your SM & TM server . Working on eXpansion² with full MP4 support and many other awesome features...

    User avatar
    alividerci
    Posts: 561
    Joined: 11 Feb 2012, 07:03

    Re: While and Now

    Post by alividerci » 18 Sep 2014, 06:35

    sry i forgot rewrite code, look again

    User avatar
    alividerci
    Posts: 561
    Joined: 11 Feb 2012, 07:03

    Re: While and Now

    Post by alividerci » 18 Sep 2014, 06:40

    oliverde8 wrote:well the infinite loop is probably the cause of Too many resources,
    When a script spends more then a certain amount of resources(not sure how the resources are counted) during a single frame it stops and makes that error.

    putting a yield in the infinite loop will probably fix the to many resources error but I doubt the code would do what it was intended to do, :)
    yield - not good solution because it stopped on a small time other scripts

    oliverde8
    Posts: 1345
    Joined: 16 Jun 2010, 07:33
    Location: in a Blue Box

    Re: While and Now

    Post by oliverde8 » 18 Sep 2014, 06:45

    I said yield would solve the error but it wouldn't behave as you wish, it was to explain the resource error that I talked about it.
    You need to fix your while
    Image
    Developper for The next generation, Clean and Powerfull controller eXpansion for your SM & TM server . Working on eXpansion² with full MP4 support and many other awesome features...

    User avatar
    steeffeen
    Translator
    Translator
    Posts: 2472
    Joined: 14 Oct 2012, 16:22
    Location: Germany

    Re: While and Now

    Post by steeffeen » 18 Sep 2014, 10:07

    a yield wouldn't have solved it because the script would be freaking stuck in the infinite loop
    now it's fine and the loop isn't infinite anymore because the loop counter increases, there's no need for a yield at all
    but it will probably only be executed once because the loop counter won't be reset

    btw don't edit old posts because you mess up the whole history
      Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

      ManiaControl, FancyManiaLinks

      GabrielM
      Posts: 243
      Joined: 13 Jan 2012, 16:53

      Re: While and Now

      Post by GabrielM » 18 Sep 2014, 15:51

      steeffeen wrote:btw don't edit old posts because you mess up the whole history
      Indeed, i was like "hmmm... I don't see why it's an infinite loop.. maybe he's edited his post, but that would be weird..." :D

      Post Reply

      Return to “ManiaScript”

      Who is online

      Users browsing this forum: No registered users and 2 guests