1
Bully Modding Archives / Re: Working on Bully SE: Local Multiplayer v3
« on: December 19, 2015, 10:53:15 AM »In the start of main...wow, adding a wait(500) isn't a bad idea. and it just fixed a bug! i had a bug that needs to reload save game so it can run the model select but now, that bug has been fixed.Code: [Select]local safehouse = CreateThread("F_Safehouses")
local model = CreateThread("F_SelectModels")
repeat
TextPrintString("~BULLY_CREST~ ~dleft~/~dright~ = Switch models ~BULLY_CREST~ - ~BULLY_CREST~ ~TAG_START~ - Select model - ~BULLY_CREST~ ~ATTACK~ - Winter Outfit ~BULLY_CREST~",1,2)
TextPrintString("~BULLY_CREST~ Local Multiplayer Mod v3 by UltimateGamer9 ~BULLY_CREST~",1,1)
F_SetupModels()
F_SetupModels2()
Wait(0)
until IsButtonBeingPressed(7,1) and IsButtonBeingPressed(7,0)
I really suggest adding a Wait(500) before all of that so the game has some time to initialize (since STimeCycle starts before the game is even finished initializing), and additionally a huge problem is that you call F_SetupModels and F_SetupModels2 repeatedly. To begin with, it already seems like a waste of memory to set up 2 tables with the same contents, but even worse you add to them repeatedly every single frame! Since there are 258 peds, and you add all the peds to 2 tables every frame, that means 516 things are getting added to memory every single frame! On top of that, every table you add seems to hold 2 string values, we're gonna say on average maybe 15 bytes for each table since there's 2 strings? (Although there is probably more...). Now that means that 7,740 bytes (over 7 kilobytes) are being added to memory every frame, and with the game running at 30 frames per second, that means 232,200 bytes (232.2 kb) are being added to memory every second. So... yeah, the game will probably crash from memory limitations.
I kinda got carried away with numbers there so lemme just summarize it for you:
Add Wait(500) to the start of your main function, this will give the game time to initialize before your script starts doing crap.
Only set up your tables one time, not repeatedly. Take the calls to F_SetupModels and F_SetupModels2 out of that repeat loop. Also F_SetupWeapons in the other repeat loop.
WOOP WOOP!