Jump to content

Function Not Working Like must be [many conditions + 2 FORs]


DarkLink

Recommended Posts

Okay so, I have a problem here in my function. I am trying to fix this from about 2 hours ago and cant find the issue..

It was working before, not anymore.

function prenderTipoNoCarro(keyPresser) 
  
 local x,y,z = getElementPosition(keyPresser) 
 local vehicles = getVehiclesOfType(599) 
     
    for i, k in ipairs (getPlayersInTeam(team_immigrantsSP)) do 
         
         
        local x1,y1,z1 = getElementPosition(k) 
        if (getDistanceBetweenPoints3D ( x, y, z, x1, y1, z1 ) < 3 ) then 
         
         
            if(isPedOnGround(keyPresser)) then 
             
                if (getElementData ( k, "handsup", false) == true ) then 
                    for carValue, carro in ipairs(vehicles) do 
                        local q,w,e = getElementPosition(carro) 
                         
                        if(getDistanceBetweenPoints3D ( x, y, z, q, w, e ) < 6) then 
                             
                         
                         
                            local x = 1 
                            while(x ~= 4) do 
                                if(getVehicleOccupant(carro,x) == false) then 
                                    warpPedIntoVehicle ( k, carro, x) 
                                    toggleControl ( k, "enter_exit", false) 
                                    outputChatBox("You are arrested!", k, 30,144,255) 
                                    return 
                                end 
                                 
                                x = x + 1 
                                if (x == 4) then 
                                    outputChatBox("The car is full, you cant put more Emigrants here, arrest this ones at prison", keyPresser, 30,144,255) 
                                     
                                end 
                            end 
                             
                        end 
                    end 
                     
                     
                    --outputChatBox("Maybe you are too far from prisoner's truck..?", keyPresser, 30, 144, 255) 
                else 
                    outputChatBox("He is not hands up yet!", keyPresser, 30,144,255) 
                end 
            else 
                outputChatBox("You need to be out of the vehicle and in the ground!", keyPresser, 30,144,255) 
            end 
        else 
            outputChatBox("You are to far from any Emigrant!", keyPresser, 30,144,255) 
        end 
         
    end 
  
end 
  

This function is binded to a key.

Its working at any car, and its suppose to work only to the cars on table vehicles (that are near the police), because its the table with all police rangers on server.

Can anyone give me a hand here?

Thanks alot guys.

Link to comment
What's the problem? Where the func doesn't work? Type /debugscript 3 and see the errors...

The problem is that, the table is getting other vehicles that are near the player, but if this vehicles are not of model 599 it shouldn't warp the ped!

And is warping with car models 599 all others..

kinda weird

Link to comment

Worked with one more verification, this one:

if getElementModel(carro) == 599 then

..

but the table should give only the vehicles of that model (599) but doesnt.. so the function getVehiclesOfType is bugged?

I would like some answer from MTA Team, or from someone that really knows what is the exactly problem of this function.

Thanks guys.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...