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


Author Topic: Script help  (Read 4167 times)

0 Members and 1 Guest are viewing this topic.

Offline AWiseMelon

  • Jr. Member
  • **
  • Posts: 42
  • Gender: Male
    • View Profile
Script help
« on: April 03, 2016, 02:34:34 PM »
So this is a script I'm making just to mess around with LUA and learn as I go:

MissionSetup = function()
local l_1_0 = 277.3605042
local l_1_1 = -139.8320007
local l_1_2 = 6.10990

PlayerSetHealth(1000)
AreaTransitionXYZ(0,l_1_0, l_1_1, l_1_2 )

end

SpawnEnemy1 = function()
local l_1_0 = 269.8130188
local l_1_1 = -140.7661591
local l_1_2 = 6.10990

PedCreateXYZ(26, l_1_0, l_1_1, l_1_2)
PedAttack(Lucky,gPlayer,1)

end

SpawnEnemy2 = function()
local l_1_0 = 209.5122375
local l_1_1 = -138.3591766
local l_1_2 = 6.10990

PedCreateXYZ(28, l_1_0, l_1_1, l_1_2)
PedAttack(Ricky,gPlayer,1)

end

WinMission = function()
if PedGetHealth(Lucky) <= 0 and if PedGetHealth(Ricky) <= 0 then -- Dunno what to do at this part either.



MissionCleanup = function()
 end
 
  main = function()
  SpawnEnemy1()
  SpawnEnemy2()
 
end


But everytime I start the script by going to the Arcade machine, I spawn at the location I set and so does Lucky and Ricky, then the game crashes and I'm not sure why can someone tell me what it is, i'm sure it is something REALLY obvious lmao :P

Offline Bellic19

  • Sr. Member
  • ***
  • Posts: 933
  • Gender: Male
    • View Profile
Re: Script help
« Reply #1 on: April 03, 2016, 02:58:01 PM »
M8, when you spawn a ped you must give it a name. Like this:
Lucky = PedCreateXYZ(26, l_1_0, l_1_1, l_1_2)

Offline AWiseMelon

  • Jr. Member
  • **
  • Posts: 42
  • Gender: Male
    • View Profile
Re: Script help
« Reply #2 on: April 03, 2016, 03:05:18 PM »
Yeah, thanks, I managed to fix it up a bit and it actually works now:

MissionSetup = function()
local X = 277.3605042
local Y = -139.8320007
local Z = 6.10990

PlayerSetHealth(1000)
AreaTransitionXYZ(0,X, Y, Z)

 Ricky = nil
 Lucky = nil
 
 Ricky = PedCreateXYZ(28, 209.51, -138.35, 6.10)
 Lucky = PedCreateXYZ(26, 269.81, -140.76, 6.10)
   PedAttack(Ricky,gPlayer,1)
   PedAttack(Lucky,gPlayer,1)
end

WinMission = function()
if PedisDead(Ricky) and (Lucky) then
 TextPrintString("You have beaten the Greasers",4,1)
end
end


MissionCleanup = function()
end
 
  main = function()
 WinMission()
 end

I think my Co-ords for Ricky are messed up because I think he's stuck in the building cuz I can hear him throwing eggs lmfao

Offline AWiseMelon

  • Jr. Member
  • **
  • Posts: 42
  • Gender: Male
    • View Profile
Re: Script help
« Reply #3 on: April 03, 2016, 03:16:43 PM »
Alright, they spawn beside each other now and attack me, but, when they punch me I don't get hit, Jimmy doesn't even flinch, it's weird and I have no idea on how to fix it.

Offline AWiseMelon

  • Jr. Member
  • **
  • Posts: 42
  • Gender: Male
    • View Profile
Re: Script help
« Reply #4 on: April 03, 2016, 03:55:19 PM »
Alright, now I'm having more problems. The "You Passed" text appears without me having to defeat the greasers, i still get spawned and so do they:

MissionSetup = function()
local X = 277.3605042
local Y = -139.8320007
local Z = 6.10990

PlayerSetHealth(1000)
AreaTransitionXYZ(0,X, Y, Z)

 Ricky = nil
 Lucky = nil
 
 Ricky = PedCreateXYZ(28, 265.51, -138.35, 6.10)
 Lucky = PedCreateXYZ(26, 269.81, -140.76, 6.10)
   PedAttack(Ricky,gPlayer,1)
   PedAttack(Lucky,gPlayer,1)
end

WinMission = function()
if PedIsDead(Ricky) and PedIsDead(Lucky) then
 TextPrintString("You have beaten the Greasers", 4, 1)
end
end


MissionCleanup = function()
end
 
  main = function()
 WinMission()
 Wait(3000)
 MissionSucceed()
 end

Offline AWiseMelon

  • Jr. Member
  • **
  • Posts: 42
  • Gender: Male
    • View Profile
Re: Script help
« Reply #5 on: April 03, 2016, 04:02:11 PM »
Nevermind, I manged to get it by looking at this thread:

http://www.bully-board.com/index.php?topic=23740.0

Thank you :biggrin: :cool:

Offline Bellic19

  • Sr. Member
  • ***
  • Posts: 933
  • Gender: Male
    • View Profile
Re: Script help
« Reply #6 on: April 03, 2016, 04:06:49 PM »
Fixed:

Code: [Select]

MissionSetup = function()
local X = 277.3605042
local Y = -139.8320007
local Z = 6.10990

PlayerSetHealth(1000)
AreaTransitionXYZ(0,X, Y, Z)

 Ricky = nil
 Lucky = nil
 
 Ricky = PedCreateXYZ(28, 265.51, -138.35, 6.10)
 Lucky = PedCreateXYZ(26, 269.81, -140.76, 6.10)
   PedAttack(Ricky,gPlayer,1)
   PedAttack(Lucky,gPlayer,1)
end

WinMission = function()
if PedIsDead(Ricky) and PedIsDead(Lucky) then
 TextPrintString("You have beaten the Greasers", 4, 1)
end
end


MissionCleanup = function()
end
 
  main = function()
  if PedIsDead(Ricky) and PedIsDead(Lucky) then
 WinMission()
 Wait(3000)
 MissionSucceed()
 end
  end

Offline Bellic19

  • Sr. Member
  • ***
  • Posts: 933
  • Gender: Male
    • View Profile
Re: Script help
« Reply #7 on: April 03, 2016, 04:07:16 PM »
Nevermind, I manged to get it by looking at this thread:

http://www.bully-board.com/index.php?topic=23740.0

Thank you :biggrin: :cool:
Oh shit I didn't see that. Oh well

Offline AWiseMelon

  • Jr. Member
  • **
  • Posts: 42
  • Gender: Male
    • View Profile
Re: Script help
« Reply #8 on: April 03, 2016, 04:24:08 PM »
Also I figured out why when they attack me it doesn't hurt, it's because the save game i'm on the greasers are at 100% with me so obviously they're not suppose to attack me unless I provoke them, so you have to make them hate you using this :

PedSetPedToTypeAttitude(Lucky, 13, 0)-- "Lucky" is the ped, "13" is the faction(Player faction) and "0" is how they feel about you (0 means they hate you)