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


Author Topic: A little help with STimeCycle?  (Read 2014 times)

0 Members and 1 Guest are viewing this topic.

Offline Gustavinzaum

  • Jr. Member
  • **
  • Posts: 34
    • View Profile
A little help with STimeCycle?
« 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

Offline c00ld0c26

  • The D0c
  • Can't Get Enough
  • *****
  • Posts: 5,137
  • Gender: Male
  • Just a dood doing dood things.
    • View Profile
    • My channel.
Re: A little help with STimeCycle?
« Reply #1 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.

Offline Gustavinzaum

  • Jr. Member
  • **
  • Posts: 34
    • View Profile
Re: A little help with STimeCycle?
« Reply #2 on: December 06, 2013, 12:28:55 PM »
Thanks alot!!!!