Bully-Board

Bully Modding Section => Modding Questions/Help => Modding Questions/Help Archives => Topic started by: Gustavinzaum on December 06, 2013, 11:27:07 AM

Title: A little help with STimeCycle?
Post by: Gustavinzaum on December 06, 2013, 11:27:07 AM
Hello bully modders, today I want a little help with my STimeCycle's lua script...
Alright, here's the deal
I'm trying to spawn a Bif ped in a right local, It works, but it spawn alot of Bifs, I want to know if you guys have the answer to fix this, making it spawn only 1 Bif.
Here's my script, without the whole rest

Code: [Select]
main = function()
  Wait(500)
  LoadAnimationGroup("Boxing")
  repeat
    Prep()
  Wait(0)
  until not Alive
end

Prep = function()

if IsButtonPressed(0, 1) then

Bif = PedCreateXYZ(33, 94, -116, 6)

PedSetPedToTypeAttitude(Bif, 13, 0)

PedSetActionTree(Bif,"/Global/P_Bif","Act/Anim/P_Bif.act")

LoadActionTree("P_Bif")
LoadAnimationGroup("Boxing")
end
end
Title: Re: A little help with STimeCycle?
Post by: c00ld0c26 on December 06, 2013, 12:14:55 PM
Code: [Select]
main = function()
LoadAnimationGroup("Boxing")
  Wait(500)
  repeat
  Wait(0)
    Prep()
  until not Alive
end

Prep = function()

if IsButtonBeingPressed(0, 1) then

Bif = PedCreateXYZ(33, 94, -116, 6)

PedSetPedToTypeAttitude(Bif, 13, 0)

PedSetActionTree(Bif,"/Global/P_Bif","Act/Anim/P_Bif.act")

LoadActionTree("P_Bif")
LoadAnimationGroup("Boxing")
end
end

Fixed :

You placed the Prep() function between the repeat function, which repeats the function endlessly until it gets to the condition setted which is : not Alive

Another thing is the : IsButtonPressed, which will also make the game spawn a lot of bifs if you press the button for a long time, so I changed it to IsButtonBeingPressed, so when you press 1 time it will work but it wont repeat itself when you hold it.
Title: Re: A little help with STimeCycle?
Post by: Gustavinzaum on December 06, 2013, 12:28:55 PM
Thanks alot!!!!