Jump to content

Is Ped In vehicle problem SB pls help me


nerfioner

Recommended Posts

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 

Link to comment

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.

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