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


Author Topic: This code doesn't work  (Read 2704 times)

0 Members and 1 Guest are viewing this topic.

Offline Enderman

  • What i'm doing right now?
  • Full Member
  • ***
  • Posts: 293
  • Gender: Male
  • I'm no longer do mods for Bully ...
    • View Profile
    • bully-board.com
This code doesn't work
« on: August 23, 2014, 08:59:00 AM »
I do Johnny Boss Style because i finding 3 hit combo if anyone have it please give me that code :)
This code:
GlobalImportScript("SObjTest.lua")
ImportScript("Library/LibTable.lua")
ImportScript("SZone.lua")

  l_0_0 = 60

MissionSetup = function()
  local l_1_0 = 270 -- X coords
  local l_1_1 = -110 -- Y coords
  local l_1_2 = 6.4000000953674 -- Z coords
  AreaTransitionXYZ(0, l_1_0, l_1_1, l_1_2)

  PedSetTypeToTypeAttitude(1, 13, 2)
  PedSetTypeToTypeAttitude(2, 13, 2)
  PedSetTypeToTypeAttitude(3, 13, 1)
  PedSetTypeToTypeAttitude(4, 13, 4)
  PedSetTypeToTypeAttitude(5, 13, 1)
  PedSetTypeToTypeAttitude(6, 13, 2)
  PedSetTypeToTypeAttitude(11, 13, 2)
 
  Johnny = PedCreateXYZ(23, l_1_0 +1, l_1_1 +1, l_1_2 +1)
  PedRecruitAlly(gplayer, Darby)
  Peanut = PedCreateXYZ(21, l_1_0 +2, l_1_1 +2, l_1_2 +2)
  PedRecruitAlly(Johnny, Peanut)
 
  PlayerSetHealth(2000)
  PedSetHealth(Johnny, 300)
  PedSetHealth(Peanut, 200)
 
  end

F_MissionSetup = function()

  LoadAnimationGroup("G_Johnny")
  LoadActionTree("G_Johnny")
  LoadActionTree("G_Melee_A")
  LoadActionTree("G_Striker_A")
 
  PlayerSetControl(1)
 
  CameraFollowPed(gPlayer)
 
  ClockSet(8, 30)
 
  ClockSetTickRate(0.0060000000521541)
 
  LaunchScript("SObjTest.lua")

end



MissionCleanup = function()
  ClearTextQueue()
  EnablePOI()
  gMissionRunning = false
  shared.gMissionEventFunction = nil
  WeatherRelease()
  PlayerSetControl(1)
  PlayerSetPunishmentPoints(0)
end



main = function()
  F_MissionSetup()
  gMissionRunning = true
  while gMissionRunning do
  if IsButtonPressed(15,0) then
  PedSetActionTree(gPlayer, "/Global/G_Striker_A", "Act/Anim/G_Striker_A.act")
  elseif IsButtonPressed(10,0) and IsButtonPressed(8,0) then
  PedSetActionTree(gPlayer, "/Global/G_Melee_A", "Act/Anim/G_Melee_A.act")
  elseif IsButtonPressed(3,0) then
  PedSetActionNode(gPlayer, "/Global/G_Johnny/Offense/Special/SpecialActions/Grapples/Dash", "Act/Anim/G_Johnny.act")
  elseif IsButtonPressed(9,0) then
  PedSetActionNode(gPlayer, "/Global/G_Johnny/Offense/Medium/HeavyAttacks/RoundHouseKick", "Act/Anim/G_Johnny.act")
  elseif IsButtonPressed(14,0) then
  PedSetActionTree(gPlayer, "/Global/G_Johnny", "Act/Act/Anim/G_Johnny.act")
  PedLoadAITree(gPlayer, "/Global/JohnnyAI", "Act/AI/AI_JOHNNY_3_B.act")
  end
  UpdateTextQueue()
    Wait(0)
  end
end

When i play in boy dorm it's turn black tell me why please :(

Offline WhenLifeGivesYouLemons

  • xfire: 1emonthatsme
  • Sr. Member
  • ***
  • Posts: 971
  • Gender: Male
  • 波動バースト
    • View Profile
Re: This code doesn't work
« Reply #1 on: August 23, 2014, 02:11:48 PM »
There is no such code as PedLoadAITree which probably makes it crash.


Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: This code doesn't work
« Reply #2 on: August 23, 2014, 05:54:46 PM »
A good way to find out what in your code dosen't work is to put a bunch of TextPrintStrings in it so you see the last part that worked before it crashed.

TextPrintString("start of script",1,1)
PedSetPosXYZ(gPlayer,270,-110,7)
TextPrintString("about to give weapon",1,1)
PedSetWeapon(gPlayer,305,50)
TextPrintString("about to spawn Pete",1,1)
PedCreateXYZ(134,270,-108,7)
TextPrintString("about to start mission",1,1)
PlayDaStupidMission("Russelllz Bowss Battle")
TextPrintString("about to give reward",1,1)
PlayerAddMoney(gPlayer,5000)
TextPrintString("script ended",1,1)

It can be a pain sometimes to do that but I do it for my scripts and it helps a lot. Obviously, the function PlayDaStupidMission is not a real function there so the script will crash. You will see on the screen "about to start mission" as that was the last thing printed before the script crashed so you will know that the function PlayDaStupidMission caused the problem.

Another way is to replace parts of code with comments to see how the script works without them.

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: This code doesn't work
« Reply #3 on: September 10, 2014, 11:07:13 PM »
I took a look at your script. There are a few errors, and PedLoadAITree was supposed to be PedSetAITree. Like I said, a lot of stuff here was very useless.

Try this one:
Code: [Select]
--[[ DO NOT EDIT:
  F_MissionSetup function removed, as well as a few other useless functions.
 
  Script Imports removed, because those are pretty pointless
 
  gMissionRunning and Cleanup removed, those are most useful in missions!
]]

function MissionSetup()
  T_Johnny = {} -- Declares a table T_Johnny
  T_JN = {} -- Declares a table T_JN
  AreaTransitionXYZ(0, 270, -110, 7)
  PlayerSetHealth(2000) 
  Wait(50)
  PedSetTypeToTypeAttitude(1, 13, 2)
  PedSetTypeToTypeAttitude(2, 13, 2)
  PedSetTypeToTypeAttitude(3, 13, 1)
  PedSetTypeToTypeAttitude(4, 13, 4)
  PedSetTypeToTypeAttitude(5, 13, 1)
  PedSetTypeToTypeAttitude(6, 13, 2)
  PedSetTypeToTypeAttitude(11, 13, 2)
  Johnny = PedCreateXYZ(23, 270 +1, -110 +1, 7 +1)
  PedRecruitAlly(gplayer, Darby)
  Peanut = PedCreateXYZ(21, 270 +2, -110 +2, 7 +2)
  PedRecruitAlly(Johnny, Peanut)
  PedSetHealth(Johnny, 300)
  PedSetHealth(Peanut, 200)
-- Trees: 
  table.insert(T_Johnny,{Tree = "/Global/G_Striker_A", TreeLoc = "Act/Anim/G_Striker_A.act"})
  table.insert(T_Johnny,{Tree = "/Global/G_Melee_A", TreeLoc = "Act/Anim/G_Melee_A.act"})
  table.insert(T_Johnny,{Tree = "/Global/G_Johnny", TreeLoc = "Act/Act/Anim/G_Johnny.act"})
  table.insert(T_Johnny,{Tree = "/Global/JohnnyAI", TreeLoc = "Act/AI/AI_JOHNNY_3_B.act"}) -- this is actually an AI
-- Nodes:
  table.insert(T_JN,{Node = "/Global/G_Johnny/Offense/Special/SpecialActions/Grapples/Dash", NL = "Act/Anim/G_Johnny.act"})
  table.insert(T_JN,{Node = "/Global/G_Johnny/Offense/Medium/HeavyAttacks/RoundHouseKick", NL = "Act/Anim/G_Johnny.act"})
end

function TL_Buttons()
if IsButtonPressed(15,0) then
      PedSetActionTree(gPlayer, T_Johnny[1].Tree, T_Johnny[1].TreeLoc)
elseif IsButtonPressed(10,0) and IsButtonPressed(8,0) then
  PedSetActionTree(gPlayer, T_Johnny[2].Tree, T_Johnny[2].TreeLoc)
elseif IsButtonPressed(3,0) then
  PedSetActionNode(gPlayer, T_JN[1].)
elseif IsButtonPressed(9,0) then
      PedSetActionNode(gPlayer, T_JN[2].Node, T_JN[2].NL)
elseif IsButtonPressed(14,0) then
      PedSetActionTree(gPlayer, T_Johnny[3].Tree, T_Johnny[3].TreeLoc)
      PedSetAITree(gPlayer, T_Johnny[4].Tree, T_Johnny[4].TreeLoc)
    end
end

function main()
  LoadAnimationGroup("G_Johnny")
  LoadActionTree("G_Johnny")
  LoadActionTree("G_Melee_A")
  LoadActionTree("G_Striker_A")\
  repeat
    TL_Buttons()
  Wait(0)
  until not Alive
end

DOWNLOAD

Offline Enderman

  • What i'm doing right now?
  • Full Member
  • ***
  • Posts: 293
  • Gender: Male
  • I'm no longer do mods for Bully ...
    • View Profile
    • bully-board.com
Re: This code doesn't work
« Reply #4 on: September 11, 2014, 06:33:17 AM »
Thanks for the code but it's still black :(

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: This code doesn't work
« Reply #5 on: September 11, 2014, 03:20:32 PM »
1) You should put code tags around your code
2) What is GlobalImportScript?

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: This code doesn't work
« Reply #6 on: September 28, 2014, 04:35:00 PM »
1) You should put code tags around your code
2) What is GlobalImportScript?
It globally loads the script, so you can use it anywhere in YOUR script. eg: You import it in the MissionSetup() function, you can still launch it and use it in the main() function.

EXAMPLE:
Code: [Select]
function MissionSetup()
  AreaTransitionXYZ(0,270,-110,6)
  PlayerSetHealth(500)
  GlobalImportScript("SObjTest.lua)
end

function main()
  LaunchScript("SObjTest.lua")
  repeat
  Wait(0)
  until not Alive
end
I'm pretty sure that's how it works.

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: This code doesn't work
« Reply #7 on: September 28, 2014, 04:47:57 PM »
I always put the regular ImportScript in my MissionSetup and it still works in other functions.
I don't think GlobalImportScript is a function, but it may just be that I have never seen it before.

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: This code doesn't work
« Reply #8 on: September 28, 2014, 05:45:32 PM »
I always put the regular ImportScript in my MissionSetup and it still works in other functions.
I don't think GlobalImportScript is a function, but it may just be that I have never seen it before.
I never import scripts in ArcRace1. Only in STimeCycle, and I just use ImportScript and works perfectly fine. I saw global importScript on one of Mad's released sources.