Bully-Board
Bully Modding Section => Script Modding => LUA Scripting Help => Topic started by: AWiseMelon 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
-
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)
-
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
-
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.
-
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
-
Nevermind, I manged to get it by looking at this thread:
http://www.bully-board.com/index.php?topic=23740.0 (http://www.bully-board.com/index.php?topic=23740.0)
Thank you :biggrin: :cool:
-
Fixed:
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
-
Nevermind, I manged to get it by looking at this thread:
http://www.bully-board.com/index.php?topic=23740.0 (http://www.bully-board.com/index.php?topic=23740.0)
Thank you :biggrin: :cool:
Oh shit I didn't see that. Oh well
-
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)