News: Welcome back to Bullworth! If you haven't already, you will need to reset your password..


Author Topic: Not running through the full loop  (Read 2484 times)

0 Members and 1 Guest are viewing this topic.

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Not running through the full loop
« on: March 06, 2016, 02:13:06 AM »
Code: [Select]
local areas = {
{name = "The Hole", camLookA = 8, camLookX = -772, camLookY = -134, camLook = 6, camSetX = -778, camSetY = -778, camSetZ = 13, music = "MS_RussellInTheHole"},
{name = "Main Building", camLookA = 2, camLookX = -628, camLookY = -312, camLookZ = -0, camSetX = -629, camSetY = -318, camSetZ = 10, music = "MS_FinalShowdown03High"},
{name = "Football Field", camLookA = 0, camLookX = -27, camLookY = -73, camLookZ = 2, camSetX = -12, camSetY = -109, camSetZ = 5, "MS_JockBossBattle"},
{name = "Old Observatory", camLookA = 0, camLookX = 34, camLookY = -134, camLookZ = 9, camSetX = 19, camSetY = -122, camSetZ = 10, "MS_EpicConfrontationHigh"},
{name = "THE WHOLE CAMPUS (GATES CLOSED!)", camLookA = 0, camLookX = 215, camLookY = -73, camLookZ = 9, camSetX = 271, camSetY = 73, camSetZ = 7, music = "MS_BikeActionHigh"},
}
local areaSelectionIndex = 1
local shouldStartInit = 1

function MissionSetup()
AreaTransitionXYZ(0, 270, -110, 6)
PlayerSetHealth(PedGetMaxHealth(gPlayer))
PlayerSetControl(0)
TextPrintString("test version", 3, 1)
Wait(3000)
PedSetFlag(gPlayer, 113, true)
PedSetFlag(gPlayer, 87, true)
PedSetFlag(gPlayer, 9, true)
PedSetFlag(gPlayer, 21, true)
shouldStart = true
end

function MissionCleanup()
collectgarbage()
end

function main()
while shouldStart do
if shouldStartInit == 1 then
PedSetEffectedByGravity(gPlayer, false)
AreaTransitionXYZ(areas[areaSelectionIndex].camLookA, areas[areaSelectionIndex].camLookX, areas[areaSelectionIndex].camLookY, areas[areaSelectionIndex].camLookZ)
CameraSetXYZ(areas[areaSelectionIndex].camSetX, areas[areaSelectionIndex].camSetY, areas[areaSelectionIndex].camSetZ)
CameraLookAtXYZ(areas[areaSelectionIndex].camLookX, areas[areaSelectionIndex].camLookY, areas[areaSelectionIndex].camLookZ)
SoundPlayStream(areas[areaSelectionIndex].music..".rsm", 0.5)
shouldStartInit = nil
end
F_SelectFightingArena()
Wait(0)
end
end

function F_SelectFightingArena()
if IsButtonPressed(0, 0) then
Wait(100)
areaSelectionIndex = areaSelectionIndex - 1
if areaSelectionIndex < 1 then
areaSelectionIndex = table.getn(areas)
end
AreaTransitionXYZ(areas[areaSelectionIndex].camLookA, areas[areaSelectionIndex].camLookX, areas[areaSelectionIndex].camLookY, areas[areaSelectionIndex].camLookZ)
CameraSetXYZ(areas[areaSelectionIndex].camSetX, areas[areaSelectionIndex].camSetY, areas[areaSelectionIndex].camSetZ)
CameraLookAtXYZ(areas[areaSelectionIndex].camLookX, areas[areaSelectionIndex].camLookY, areas[areaSelectionIndex].camLookZ)
SoundPlayStream(areas[areaSelectionIndex].music..".rsm", 0.5)
elseif IsButtonPressed(1, 0) then
Wait(100)
areaSelectionIndex = areaSelectionIndex + 1
if areaSelectionIndex > table.getn(areas) then
areaSelectionIndex = 1
end
AreaTransitionXYZ(areas[areaSelectionIndex].camLookA, areas[areaSelectionIndex].camLookX, areas[areaSelectionIndex].camLookY, areas[areaSelectionIndex].camLookZ)
CameraSetXYZ(areas[areaSelectionIndex].camSetX, areas[areaSelectionIndex].camSetY, areas[areaSelectionIndex].camSetZ)
CameraLookAtXYZ(areas[areaSelectionIndex].camLookX, areas[areaSelectionIndex].camLookY, areas[areaSelectionIndex].camLookZ)
SoundPlayStream(areas[areaSelectionIndex].music..".rsm", 0.5)
end
TextPrintString("SELECT ARENA\n<"..areas[areaSelectionIndex]..">", 0, 1)
TextPrintString("~dleft~/~dright~ - Navigate Menu (L/R)\n~SPRINT~ - Select Arena", 0, 2)
end

Everything's working. But when the loop in the main() function starts, it DOES do the stuff i made it do(the test thing) but it wont launch the function I called in it.

If that's hard to understand maybe try the mod. see what i mean.

The table isn't messed up, because in the first part of the loop, that works, and it calls everything on that table. But it seems that the function I called in the loop isn't being executed.

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Not running through the full loop
« Reply #1 on: March 06, 2016, 02:40:40 AM »
Simple mistake, you tried to print a table.
TextPrintString("SELECT ARENA\n<"..areas[areaSelectionIndex]..">", 0, 1)

Perhaps you meant to do this:
TextPrintString("SELECT ARENA\n<"..areas[areaSelectionIndex].name..">", 0, 1)

I notice that you make the script wait for 0.1 seconds after one of the selection buttons are pressed. This I assume would lead to a delay before showing the arena. You should consider calling wait at the end of the if statement instead.

I notice this chunk of code being used multiple times, think about giving it its own function to make the script look a little neater. Perhaps call it F_InitializeArena or F_SetupArena:
  AreaTransitionXYZ(areas[areaSelectionIndex].camLookA, areas[areaSelectionIndex].camLookX, areas[areaSelectionIndex].camLookY, areas[areaSelectionIndex].camLookZ)
  CameraSetXYZ(areas[areaSelectionIndex].camSetX, areas[areaSelectionIndex].camSetY, areas[areaSelectionIndex].camSetZ)
  CameraLookAtXYZ(areas[areaSelectionIndex].camLookX, areas[areaSelectionIndex].camLookY, areas[areaSelectionIndex].camLookZ)
  SoundPlayStream(areas[areaSelectionIndex].music..".rsm", 0.5)

Other than that the script looks alright. Is it going to be something like Fight Club?

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: Not running through the full loop
« Reply #2 on: March 06, 2016, 04:01:41 AM »
OMFG YOU'RE RIGHT...

Yeah I am aware of how those tables work like that.

BUT when i started typing the code, the table was originally just NAMES, it was like this:

table = {
"thing1",
"thing2",
}

it was like that. and i dunno what its gonna be. it has an area selector i know that. :laugh:

It would be cool to do that but im not tryna copy ur ideas. so i gotta think.

My MAIN idea, or first idea was to just have a random ped from the full ped list, high af stats and u have regular stats. since jimmy is so OP u gotta keep fighting 1v1 till ur ded. but idk that sounds like shiet.
« Last Edit: March 06, 2016, 04:07:17 AM by Unknownsoldier »

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Not running through the full loop
« Reply #3 on: March 06, 2016, 05:18:35 AM »
Make a few modes possibly, have fun with it.

A mode with just 1 strong boss like you said, maybe a survival mode were enemies just come in, a level based thing like fight club, and idk be creative.

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: Not running through the full loop
« Reply #4 on: March 06, 2016, 01:55:03 PM »
yyyeaaa.....