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


Author Topic: Local Multiplayer Tutorial  (Read 10788 times)

0 Members and 1 Guest are viewing this topic.

Offline denifarropilha

  • LUA Modder 8)
  • Jr. Member
  • **
  • Posts: 24
  • Gender: Male
  • I'm a friendly brazilian bully modder :D
    • View Profile
Re: Local Multiplayer Tutorial
« Reply #15 on: November 10, 2013, 09:32:23 AM »
This is actually a very easy thing to do. If you don't know, local is only on your device. I say device instead of computer because if you have a hacked console you can do this too.
It is actually very simple, but I still think it is cool. You can do it for multiple people to, but mind the camera is NOT split screen, it will focus on P1.
Here's how it works, only 2 things happen. You spawn a ped, and you assign control of him to another controller. FYI: If your on a computer, and using a gamepad, the keyboard is the 2nd controller.

Step 1) Learn basic Bully LUA script modding. There is a good number of tutorials out there, I recommend mine personally but whatever you think is best for you. SWEGTA has video tutorials too (Mine: http://www.bully-board.com/index.php?topic=18968.0)

Step 2) Learn how to make scripts run in free mode unless you want to only player multiplayer be activating another script (Such as Arcrace1.lur"). I'm unaware of any other tutorials on this other then mine: http://www.bully-board.com/index.php?topic=18886.0

Step 3) In the main function of your LUA script (Which is hopefully a copy of STimeCycle.lur with the modifications required to make it work, as explained in my tutorial. (The only modification you need to do is make Wait(1000) to Wait(0). If your making this in a different script (Like Arcrace1.lur, then ignore that. So in the main function, put code for spawning a ped.
Variable = PedCreateXYZ(#,x,y,z)
Replace Variable with a name for the second player, this can be anything you'd like. Even cheese-monster if you wanted to for whatever reason. This will come into play the next step.
Replace # with the model number. (List of all models in the "default.ide" file in Objects folder, or my player selector if you want to see a bit of a preview of the models to (http://www.bully-board.com/index.php?action=downloads;sa=view;down=128) you probably just need to go in the default.ide but if you don't know a name, check out my selector, it tells you all the models. Anyway, now replace x with the x co-ordinate. Same with y and z. You can use |XF|-MadmaN [AR]'s co-ord grabber mod to find them. If you want to spawn in front of boy's dorm (Because I have this code memorized) it is 270,-110,7
If you are in the STimeCycle.lur to run in free mode, put a Wait(1000) before the PedCreateXYZ()
Side note: This step should be in the main function BEFORE the repeat loop.

Step 4) Assign the ped the code for him being controlled from another controller.
PedSetControllerID(ped,#)
Replace ped with the variable assigned to PedCreateXYZ()
Replace # with the controller number.
Note: Controller 1 is actually 0, and the second is 1, third is 2, and so on.
Note: This also goes before the repeat function.

Optional Step 5) Make your ped have Jimmy's fighting style (Or any fighting style)
PedSetActionTree(ped,style,location)
Replace ped with the variable used for the second player
Replace style with the style (Found in default.ide)
Replace location with the location of the style (Found in default.ide)

Step 6) To make the ped/second player able to run/ride bikes, we need to give the ped player AI
Similar to fighting style, but with AI
PedSetAITree(ped,AI,location)
Replace ped with the variable used for the second player
Replace AI with the AI (Found in default.ide)
Replace location with the location of the AI (Found in default.ide)

Step 7) Do all the compiling things you need to do and PLAY!

Congratulations! You now have local multiplayer in Bully! That wasn't so hard was it?
Make sure to keep the other players near you, because the camera only focuses on player 1.
Have fun, message me any questions.

Oh, and if your wondering why Wait(1000) was put before spawning the ped and, it was because when in free-mode you can not INSTANTLY spawn things. I figured this out the hard way by many many failed attempts  >:(

I may make a bigger version of this with some more features for download, maybe not though... it'd have warping the players near player 1, and switching the camera, etc.

Oh, and tip: If you just followed the instructions on here, mind that the second play will NOT spawn right next to you, he will spawn at the co-ords you assigned him to! In my example, in front of the boy's dorm.

EXAMPLE (Using STimeCycle.lur/free mode method, but only showing the main function as the rest of the code stays the same)

Code: [Select]
main = function()
  SecondPlayer = PedCreateXYZ(12,270,-110,7)
  ThirdPlayer = PedCreateXYZ(75,270,-105,7)
 
  PedSetActionTree(SecondPlayer,"/Global/Player","Act/Player.act")
  PedSetActionTree(ThirdPlayer,"/Global/Player","Act/Player.act")

  PedSetAITree(SecondPlayer,"/Global/PlayerAI","Act/PlayerAI.act") 
  PedSetAITree(ThirdPlayer,"/Global/PlayerAI","Act/PlayerAI.act")

  PedSetControllerID(SecondPlayer,1)
  PedSetControllerID(ThirdPlayer,2)
 
  repeat
    Wait(0)
  until not Alive
end
to do maybe a type of splitscreen, set CameraFollowPed to 2 buttons one for each character

Offline denifarropilha

  • LUA Modder 8)
  • Jr. Member
  • **
  • Posts: 24
  • Gender: Male
  • I'm a friendly brazilian bully modder :D
    • View Profile
Re: Local Multiplayer Tutorial
« Reply #16 on: November 10, 2013, 11:03:08 AM »
Anyone know if have a way to play with 2 keyboards?

Offline Sanic

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: Local Multiplayer Tutorial
« Reply #17 on: May 24, 2015, 05:42:19 AM »
Hey mates
i know this topic is pretty old but i just found this and trying to get this to work but im getting Infinite load screens when i start the arcade machine the idea is pretty awesome i want so badly to play with my brother and i cant get it to work
heres my code :

main = function()
  SecondPlayer = PedCreateXYZ(37,270,-110,7)
  ThirdPlayer = PedCreateXYZ(23,270,-105,7)
 
  PedSetActionTree(SecondPlayer,"/Global/P_Striker_A","Act/P_Striker_A.Act")
  PedSetActionTree(ThirdPlayer,"/Global/G_Striker_A","Act/G_Striker_A.Act")

  PedSetAITree(SecondPlayer,"/Global/PlayerAI","Act/PlayerAI.act") 
  PedSetAITree(ThirdPlayer,"/Global/PlayerAI","Act/PlayerAI.act")

  PedSetControllerID(SecondPlayer,1)
  PedSetControllerID(ThirdPlayer,2)
 
  repeat
    Wait(0)
  until not Alive
end

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: Local Multiplayer Tutorial
« Reply #18 on: May 27, 2015, 12:36:20 AM »
Hey mates
i know this topic is pretty old but i just found this and trying to get this to work but im getting Infinite load screens when i start the arcade machine the idea is pretty awesome i want so badly to play with my brother and i cant get it to work
heres my code :

main = function()
  SecondPlayer = PedCreateXYZ(37,270,-110,7)
  ThirdPlayer = PedCreateXYZ(23,270,-105,7)
 
  PedSetActionTree(SecondPlayer,"/Global/P_Striker_A","Act/P_Striker_A.Act")
  PedSetActionTree(ThirdPlayer,"/Global/G_Striker_A","Act/G_Striker_A.Act")

  PedSetAITree(SecondPlayer,"/Global/PlayerAI","Act/PlayerAI.act") 
  PedSetAITree(ThirdPlayer,"/Global/PlayerAI","Act/PlayerAI.act")

  PedSetControllerID(SecondPlayer,1)
  PedSetControllerID(ThirdPlayer,2)
 
  repeat
    Wait(0)
  until not Alive
end
If I understand correctly, you're only putting the main() function in the script, without having the beginning functions. If that's the case, this one should work:
Code: [Select]
function MissionSetup()
  AreaTransitionXYZ(0, 270, -110, 7) -- you can change these coordinates if wanted
  PlayerSetHealth(PedGetMaxHealth(gPlayer)) -- custom health can be set here
  PedSetActionTree(gPlayer, "/Global/Player", "Act/Player.act")
  PedSetAITree(gPlayer,"/Global/PlayerAI","Act/PlayerAI.act")
end

function MissionCleanup()
  running = false
  collectgarbage()
end

function main()
  running = true
  L_MP()
  while running do
    Wait(0)
  end
end

function L_MP()
  local x, y, z = PlayerGetPosXYZ()
  SecondPlayer = PedCreateXYZ(37, x + 1, y + 1, z + 1)
  ThirdPlayer = PedCreateXYZ(23,x + 2, y + 2, z + 2)
  PedSetActionTree(SecondPlayer, "/Global/Player", "Act/Player.act")
  PedSetActionTree(ThirdPlayer, "/Global/Player", "Act/Player.act")
  PedSetAITree(SecondPlayer, "/Global/PlayerAI", "Act/PlayerAI.act") 
  PedSetAITree(ThirdPlayer, "/Global/PlayerAI", "Act/PlayerAI.act")
  PedSetControllerID(SecondPlayer, 1)
  PedSetControllerID(ThirdPlayer, 2)
end
reply leaving your results.  :D