Jump to content

Is Ped In vehicle problem SB pls help me


nerfioner

Recommended Posts

Posted

Hi, i wanted to make a script. when i sit in Savanna vehicle i press O and the script add a roof to my car and when i press it again it is delete it

but my debugscript says that: tetoad.lua:2: bad argument @ 'isPedInVehicle'

Thank you for help, i am a begginer :D

function tetoad() 
    if (isPedInVehicle(targetPlayer)) then 
        if not(succes == nil) then 
            setTimer(tetoveg, 5000, 1) 
        else 
            destroyElement(succes) 
        end 
    else  
        outputChatBox("Rossz") 
    end 
end 
function gomb() 
    bindKey("p", "down", tetoad) 
end 
addEventHandler("onClientResourceStart", getRootElement(), gomb) 
function tetoveg() 
    theVehicle = getPedOccupiedVehicle(targetPlayer) 
    success = addVehicleUpgrade(theVehicle, 1131) 
end 

Posted

savana dont have allow to add roof so use this function

attachElements 

and try ti use it (Condition)

function addroof(thePlayer) 
    if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then 
    local veh = getElementModel ( source ) == 576  
        if veh then 

Posted

i can't do it can you send me the full correct file i can not paste your version, i pasted it to somewhere and now

tetoad.lua:2: bad argument @ 'getElementType' :S

  • MTA Team
Posted

Programming isn't just copy and paste. Please read Debugging. We will not fix your code for you unless you take the effort to understand the code you're modifying.

tetoad.lua:2: bad argument @ 'isPedInVehicle' 

This means that in line 2, there is an error in the function isPedInVehicle.

    if (isPedInVehicle(targetPlayer)) then 

If you look carefully, there is no "targetPlayer" variable defined anywhere in your code, and this is confirmed because the debug output says that there is a bad argument.

Since this is client side, you just need to rename all targetPlayer's to localPlayer.

Posted

If the script on the client-side; Change targetPlayer to localPlayer or getLocalPlayer()

If not; get first arguement(targetPlayer) on the function

e.g:

function tetoad(targetPlayer) 
-- Blablabla 

If you make this, i think it will work.

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...