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


Author Topic: Where is the error in these scripts!!  (Read 1758 times)

0 Members and 1 Guest are viewing this topic.

Offline Poters

  • Jr. Member
  • **
  • Posts: 32
  • Gender: Male
    • View Profile
Where is the error in these scripts!!
« on: September 01, 2021, 07:17:36 AM »
hii guys, I'm making a mod where players can steal Ped's car, but here I have a problem, maybe this is a serious problem for me..

so can you see where is the error in this Script?, I am 100% sure there is nothing wrong with this Script but why is the code "if not PedIsInVehicle(NPC, VEH) then" not working?

but if I remove the word no, and it becomes "if PedIsInVehicle(NPC, VEH) then", it's safe, works fine..

can someone know where is the error in this Script?, I will be very happy if any of you can find where the error is, because I myself can't solve this mod despite using many ways.

Code: [Select]
function Car()
    while true do
        Wait(0)
        local FIND = VehicleFindInAreaXYZ(0, 0, 0, 999999)
        if type(FIND) == "table" then
            for V, VEH in ipairs(FIND) do
                if VehicleIsValid(VEH) then
                    if not VehicleIsModel(VEH, 272) and not VehicleIsModel(VEH, 273) and not VehicleIsModel(VEH, 274) and not VehicleIsModel(VEH, 275) and not VehicleIsModel(VEH, 276) and not VehicleIsModel(VEH, 277) and not VehicleIsModel(VEH, 278) and not VehicleIsModel(VEH, 279) and not VehicleIsModel(VEH, 280) and not VehicleIsModel(VEH, 281) and not VehicleIsModel(VEH, 282) and not VehicleIsModel(VEH, 283) and not VehicleIsModel(VEH, 284) and not VehicleIsModel(VEH, 289) then
                        for N, NPC in {PedFindInAreaXYZ(0, 0, 0, 999999)} do
                            if not PedIsInVehicle(NPC, VEH) then
                                VX, VY, VZ = VehicleGetPosXYZ(VEH)
                                X, Y, Z = PlayerGetPosXYZ()
                                if math.abs(VX - X) + math.abs(VY - Y) + math.abs(VZ - Z) <= 4.2 and not PlayerIsInAnyVehicle() and not PedHasWeapon(gPlayer, 437) and IsButtonBeingPressed(15,0) then
                                    repeat
                                        Wait(0)
                                        PedWarpIntoCar(gPlayer, VEH)
                                    until PedIsInVehicle(gPlayer, VEH)
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end
             

Offline mhdt

  • Jr. Member
  • **
  • Posts: 93
  • 中国!中国!中国!
    • View Profile
Re: Where is the error in these scripts!!
« Reply #1 on: September 01, 2021, 08:50:51 AM »
Because this is an iterator, if Ped is not in a vehicle in the table, it will return another Vehicle ID, so it should be
Code: [Select]
if not PedIsInAnyVehicle(NPC)
« Last Edit: September 01, 2021, 08:52:33 AM by mhdt »

Offline Poters

  • Jr. Member
  • **
  • Posts: 32
  • Gender: Male
    • View Profile
Re: Where is the error in these scripts!!
« Reply #2 on: September 01, 2021, 11:02:20 AM »
Hii, mhdt..
I've tried this method before, but because I was still unsure so I tried to do it again, but after I tried it it was true, it still didn't work..

is there no other way to solve this?, because this is really a serious problem, I want you to try the scripts yourself, work or not. because I tried it in Bully AE game not SE

Offline Poters

  • Jr. Member
  • **
  • Posts: 32
  • Gender: Male
    • View Profile
Re: Where is the error in these scripts!!
« Reply #3 on: September 02, 2021, 03:45:59 AM »
are you also unable to find the Solution?

Offline mhdt

  • Jr. Member
  • **
  • Posts: 93
  • 中国!中国!中国!
    • View Profile
Re: Where is the error in these scripts!!
« Reply #4 on: September 02, 2021, 05:02:57 AM »
You meaning you wanna Kick out the driver?
« Last Edit: September 02, 2021, 05:12:39 AM by mhdt »

Offline Poters

  • Jr. Member
  • **
  • Posts: 32
  • Gender: Male
    • View Profile
Re: Where is the error in these scripts!!
« Reply #5 on: September 02, 2021, 09:29:28 AM »
I want to make a mod, when Ped is in the car, the Player will not be able to enter the car, and if Ped is no longer in the car, we can already enter the car.

Offline mhdt

  • Jr. Member
  • **
  • Posts: 93
  • 中国!中国!中国!
    • View Profile
Re: Where is the error in these scripts!!
« Reply #6 on: September 03, 2021, 09:20:55 PM »
It seems that Untitled has the source code of this function

Offline Ming

  • Full Member
  • ***
  • Posts: 154
  • Gender: Male
  • 抽刀斷水水更流,舉杯消愁愁更愁
    • View Profile
Re: Where is the error in these scripts!!
« Reply #7 on: September 06, 2021, 12:31:26 AM »
I want to do this mod , too
I think you can make a function that allows the player to pull the ped out of the car