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


Author Topic: How to use AreaGetVisible()  (Read 4993 times)

0 Members and 1 Guest are viewing this topic.

Offline 3gtheepic

  • Jr. Member
  • **
  • Posts: 10
  • Gender: Male
  • I'm just some kid who likes to mod.
    • View Profile
How to use AreaGetVisible()
« on: September 25, 2016, 06:44:45 PM »
In my mission, I want it to be so after you exit the boys dorm to remove a blip and start a cutscene but for some reason it does not work.

btw, here is the code

Code: [Select]
function MissionSetup()
  AreaTransitionXYZ(14,-503.7,318.9,31.4)
  backupWeapons = GetWeapons()
  PlayerSetHealth(PedGetMaxHealth(gPlayer))
  originalModelStatus = {}
  for i = 2,258 do
      originalModelStatus[i] = PedGetUniqueModelStatus(i)
    end
  PedSetUniqueModelStatus(46,-1)
  PedSetUniqueModelStatus(42,-1)
  PedSetUniqueModelStatus(44,-1)
  bustingAnims = {
{"/Global/Actions/Grapples/Front/Grapples/GrappleMoves/Adult_Takedown","Act/Globals.act"},
{"/Global/Actions/Grapples/Front/Grapples/GrappleMoves/Adult_Takedown/Hold_Cycle","Act/Globals.act"},
{"/Global/Actions/Grapples/Front/Grapples/GrappleMoves/EarGrab","Act/Globals.act"},
{"/Global/Actions/Grapples/Front/Grapples/GrappleMoves/Punishment_Hold","Act/Globals.act"},
{"/Global/Actions/Grapples/Front/Grapples/GrappleMoves/Punishment_Hold/Hold_Cycle","Act/Globals.act"},
{"/Global/Actions/Grapples/Front/Grapples/GrappleMoves/Tonfa_Impale","Act/Globals.act"},
{"/Global/Actions/Grapples/Front/Grapples/GrappleMoves/Tonfa_Impale/TonfaImpale","Act/Globals.act"}
}
    F_LoadAllAnim()
originalAttitudes = {}
originalRespects = {}
for f = 0,11 do
    table.insert(originalAttitudes,PedGetTypeToTypeAttidude(f,13))
if f ~= 0 and (f < 7 or f > 10) then
    PedSetTypeToTypeAttidude(f,13,4)
end
table.insert(originalRespects,GetFactionRespect(f))
if f ~= 0 and (f < 7 or f > 10) then
    SetFactionRespect(f,100)
end
end
originalMoney = PlayerGetMoney()
PlayerSetMoney(10000)
PedSetWeapon(gPlayer,305,50)
PedSetWeapon(gPlayer,307,50)
PedSetWeapon(gPlayer,-1)

end

function MissionCleanup()
    for f = 0,11 do
    PedSetTypeToTypeAttidude(f,originalAttitudes[f+1])
SetFactionRespect(f,originalRespects[f+1])
end
for i = 2,258 do
    PedSetUniqueModelStatus(originalModelStatus[i])
end
SoundStopStream()
CameraSetWidescreen(false)
SoundEnableSpeech()
PlayerSetControl(1)
CameraReset()
CameraReturnToPlayer()
PlayerSetHealth(PedGetMaxHealth(gPlayer))
PlayerSetMoney(originalMoney)
DisablePunishmentSystem(false)
GiveWeapons(backupWeapons)
AreaTransitionXYZ(14,-507.5,323.4,31.4)
PedFaceXYZ(gPlayer,-505.5,325.6,31.4)
end


function main()
  F_FirstCutscene()
end

function PedsFaceEachOther(ped1,ped2)
    local x,y,z = PedGetPosXYZ(ped1)
PedFaceXYZ(ped2,x,y,z)
x,y,z = PedGetPosXYZ(ped2)
PedFaceXYZ(ped1,x,y,z)
end


function AllPedsDead(peds)
    for i = 1,table.getn(peds) do
    if PedIsValid(peds[i]) and not PedIsDead(peds[i]) then
    return false
end
end
return true
end

function MakePedStrongEnemy(ped)
    GameSetPedStat(ped,12,90)
GameSetPedStat(ped,14,100)
GameSetPedStat(ped,6,0)
GameSetPedStat(ped,7,0)
GameSetPedStat(ped,8,500000)
GameSetPedStat(ped,10,math.random(90,100))
GameSetPedStat(ped,11,500000)
GameSetPedStat(ped,13,GameGetPedStat(ped,13)*1.3)
GameSetPedStat(ped,62,0)
GameSetPedStat(ped,38,100)
GameSetPedStat(ped,39,GameGetPedStat(ped,39)*1.5)
GameSetPedStat(ped,34,100)
GameSetPedStat(ped,61,math.random(70,100))
GameSetPedStat(ped,20,GameGetPedStat(ped,20)*1.17)
GameSetPedStat(ped,63,GameGetPedStat(ped,63)*0.25)
PedSetTypeToTypeAttidude(ped,13,0)
end

function F_LoadAllAnim()
    LoadAnimationGroup("Authority")
LoadAnimationGroup("Boxing")
LoadAnimationGroup("B_Striker")
LoadAnimationGroup("CV_Female")
LoadAnimationGroup("CV_Male")
LoadAnimationGroup("DO_Edgar")
LoadAnimationGroup("DO_Grap")
LoadAnimationGroup("DO_StrikeCombo")
LoadAnimationGroup("DO_Striker")
LoadAnimationGroup("F_Adult")
LoadAnimationGroup("F_BULLY")
LoadAnimationGroup("F_Crazy")
LoadAnimationGroup("F_Douts")
LoadAnimationGroup("F_Girls")
LoadAnimationGroup("F_Greas")
LoadAnimationGroup("F_Jocks")
LoadAnimationGroup("F_Nerds")
LoadAnimationGroup("F_OldPeds")
LoadAnimationGroup("F_Pref")
LoadAnimationGroup("F_Preps")
LoadAnimationGroup("G_Grappler")
LoadAnimationGroup("G_Johnny")
LoadAnimationGroup("G_Striker")
LoadAnimationGroup("Grap")
LoadAnimationGroup("J_Damon")
LoadAnimationGroup("J_Grappler")
LoadAnimationGroup("J_Melee")
LoadAnimationGroup("J_Ranged")
LoadAnimationGroup("J_Striker")
LoadAnimationGroup("LE_Orderly")
LoadAnimationGroup("Nemesis")
LoadAnimationGroup("N_Ranged")
LoadAnimationGroup("N_Striker")
LoadAnimationGroup("N_Striker_A")
LoadAnimationGroup("N_Striker_B")
LoadAnimationGroup("P_Grappler")
LoadAnimationGroup("P_Striker")
LoadAnimationGroup("PunchBag")
LoadAnimationGroup("Qped")
LoadAnimationGroup("Rat_Ped")
LoadAnimationGroup("Russell")
LoadAnimationGroup("Russell_Pbomb")
LoadAnimationGroup("Straf_Dout")
LoadAnimationGroup("Straf_Fat")
LoadAnimationGroup("Straf_Female")
LoadAnimationGroup("Straf_Male")
LoadAnimationGroup("Straf_Nerd")
LoadAnimationGroup("Straf_Prep")
LoadAnimationGroup("Straf_Savage")
LoadAnimationGroup("Straf_Wrest")
LoadAnimationGroup("TE_Female")
end


function RemoveSkateboard()
    PlayerSetPunishmentPoints(0)
if PedGetWeapon(gPlayer) == 437 then
    PedSetWeapon(gPlayer,-1)
PedSetActionNode(gPlayer,"/Global/","Act/Globals.act")
end
end

function ProtectAlly(ped)
    PedRecruitAlly(ped)
    if not PedIsValid(ped) or PedIsDead(ped) then
   local failLines = {
       "You failed to protect your ally!",
   "Dude, he was protecting you, why can't you protect him?",
   "Your ally got shreked!",
   "Look what you've done, your ally is now dead."


TextPrintString(failLines[math.random(1,table.getn(failLines))],3,1)
Wait(2000)
MissionFail()
TerminateCurrentScript()
else
    local gg = PedGetGrappleTargetPed(ped)
if PedGetFaction(gg) == 0 or PedGetFaction(gg) == 7 then
    PedSetActionNode(ped,"/Global/Actions/Grapples/GrappleReversals/StandingReversals/GrappleBreak_GIVE","Act/Globals.act")
end
end
end


function ProtectTwoAllys(ped1,ped2)
    PedRecruitAlly(ped1)
PedRecruitAlly(ped2)
if not PedIsValid(ped1) or PedIsDead(ped1) then
    local failLines2 = {
   "You failed to protect your allys!",
   "Dude, they both were protecting you, so why can't you protect them?",
   "Your allys got shreked!",
   "Look what you've done, your allys is now dead."
}
TextPrintString(failLines2[math.random(1,table.getn(failLines2))],3,1)
Wait(2000)
MissionFail()
TerminateCurrentScript()
else
    local gg2 = PedGetGrappleTargetPed(ped1)
if PedGetFaction(gg2) == 0 or PedGetFaction(gg2) == 7 then
    PedSetActionNode(ped1,"/Global/Actions/Grapples/GrappleReversals/StandingReversals/GrappleBreak_GIVE","Act/Globals.act")
end
end
if not PedIsValid(ped2) or PedIsDead(ped2) then
    local failLines2 = {
   "You failed to protect your allys!",
   "Dude, they both were protecting you, so why can't you protect them?",
   "Your allys got shreked!",
   "Look what you've done, your allys is now dead."
}
TextPrintString(failLines2[math.random(1,table.getn(failLines2))],3,1)
Wait(2000)
MissionFail()
TerminateCurrentScript()
else
    local gg3 = PedGetGrappleTargetPed(ped2)
if PedGetFaction(gg3) == 0 or PedGetFaction(gg3) == 7 then
    PedSetActionNode(ped,"/Global/Actions/Grapples/GrappleReversals/StandingReversals/GrappleBreak_GIVE","Act/Globals.act")
end
end
end


function F_FirstCutscene()
    AreaTransitionXYZ(14,-503.7,318.9,31.4)
CameraFade(500,1)
    CameraReset()
pete = PedCreateXYZ(134,-501.4,318.3,31.4)
PedsFaceEachOther(gPlayer,pete)
PlayerSetControl(0)
CameraSetWidescreen(true)
SoundDisableSpeech()
RemoveSkateboard()

CameraSetXYZ(-502.24,315.73,32.63)
TextPrintString("Jimmy: Have you heard that the townies are planning to come here, and beat everybody up?",10,2)
Wait(2500 * (125 / 100))
TextPrintString("Pete: Well, really? I thought that already happened?",10,2)
Wait(2500 * (125/100))
TextPrintString("Jimmy: No time to talk, I think they are here!",1,2)
Wait(1275)
PedWander(pete,true)
CameraSetWidescreen(false)
SoundEnableSpeech()
PlayerSetControl(1)
CameraReset()
CameraReturnToPlayer()
F_ConfrontThem()
end

function F_ConfrontThem()
    TextPrintString("Confront whoever is outside",3,1)
    blip1 = BlipAddXYZ(-501.8,307.2,31.4,29)
gurney = PedCreateXYZ(46,271.4088135,-111.4365768,6.214407921)
otto = PedCreateXYZ(42,273.212616,-111.2962646,6.191555023)
duncan = PedCreateXYZ(44,269.5200806,-111.2836075,6.244811535)
    if AreaGetVisible == 0 then
    BlipRemove(blip1)
end
   
   
end


I AM SO BAD :-(


Offline Altamurenza

  • Full Member
  • ***
  • Posts: 118
  • Gender: Male
  • I love cheat, unique, realistic, & expansion mod.
    • View Profile
Re: How to use AreaGetVisible()
« Reply #1 on: September 25, 2016, 07:05:29 PM »
I think GiveWeapons function doesn't exist, try GiveWeaponToPlayer(weapon,ammo) function.

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: How to use AreaGetVisible()
« Reply #2 on: September 25, 2016, 07:49:27 PM »
Altamurenza brings up a good point, but it is not the problem as your problem stems from something before MissionCleanup.

One, the GetWeapons function isn't a valid function either. I can tell this is copied from one of my older scripts, or at least parts of it, so you may want to go get the GetWeapons and GiveWeapons functions from it, rewrite your own, or just take it out.

Another issue, you check if the area is 0 one time, and if so you remove the blip. You only do it one single time though... so the player only has once chance to be outside, and it is that very frame that you check if AreaGetVisible() == 0. A solution would be to wait until the area is 0 rather than just check if he is at that time. Remember, your scripts just run once, so it won't keep checking if the player is in area 0 or not unless you tell it to behave that way. Here's how you could do it.

Code: [Select]
-- While the current area is not 0, wait:
while AreaGetVisible() ~= 0 do
  Wait(0)
end
BlipRemove(blip1)
-- other shit past here

It's okay, don't call yourself bad. You're trying and you'll learn if you keep pushing.

Offline 3gtheepic

  • Jr. Member
  • **
  • Posts: 10
  • Gender: Male
  • I'm just some kid who likes to mod.
    • View Profile
Re: How to use AreaGetVisible()
« Reply #3 on: September 26, 2016, 07:06:14 PM »
Thanks!