Jump to content

I think this is MTA bug but I wanna check first


mtamaster97

Recommended Posts

This is the whole code but idk why I get error

2 line = expected account at argument 1 got nil

4 line = expected element at argument 1 got nil

7 line = expected ped at argument 1 got nil

  
accName = getAccountName (account) -- get his account name 
me = getRootElement() 
account = getPlayerAccount(source) 
--local admin = isObjectInACLGroup ( "user."..getAccountName ( getPlayerAccount ( source ) ), aclGetGroup ( "Admin" ) ) 
mass = 100000 
veh = getPedOccupiedVehicle (ped) 
--local oldmass = getVehicleHandlingProperty ( element, "mass" ) 
  
function show(msg) 
    outputChatBox(msg,source, 0,81,255,true) 
end 
  
function turnOn(player, cmd, option) 
if option == "yes" then 
function babaking_tankYes ( me ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) and veh then 
        bindKey ( me, "handbrake" or "space", "both", function(key,state) 
            if state == "down" then 
                setVehicleHandling ( veh, "mass", mass )  
                setVehicleHandling ( veh, "brakeDeceleration", mass )  
                show(tostring(getVehicleHandlingProperty ( element, "mass" ))) 
            elseif state == "up" then 
                setVehiceHandling (veh, "mass", true) 
                setVehicleHandling ( veh, "brakeDeceleration", true )  
                show(tostring(getVehicleHandlingProperty ( element, "mass" ))) 
            end 
        end) 
        addEventHandler ( "onResourceStart", getRootElement(), babaking_tankYes ) 
    elseif not veh then  
        return false 
    end 
end 
  
elseif option == "no" then 
    function babaking_tankNo ( me ) 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) and veh then 
            bindKey ( me, "handbrake", "both", function(key,state) 
                if state == "down" then 
                    setVehicleHandling ( veh, "mass", true )  
                    show(tostring(getVehicleHandlingProperty ( element, "mass" ))) 
                elseif state == "up" then 
                    setVehiceHandling (veh, "mass", true) 
                    show(tostring(getVehicleHandlingProperty ( element, "mass" ))) 
                end 
            end) 
            addEventHandler ( "onResourceStart", getRootElement(), babaking_tankNo ) 
        elseif not veh then  
            return false 
        end 
    end 
else 
    return false 
end 
end 
  
addCommandHandler("fpskickon", turnOn) 
  
function getVehicleHandlingProperty ( element, property ) 
    if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then  
        local handlingTable = getVehicleHandling ( element )  
        local value = handlingTable[property]   
        if value then  
            return value  
        end 
    end 
    return false  
end 
  

Link to comment

ik whats nil lol, but aren't "source","thePlayer","player","ped" already defined at MTA Source codes?

thats the whole script there

I tryed this too but doesn't work

accName = getAccountName (source) -- get his account name 
source = getAccountPlayer(theAccount) 
account = getPlayerAccount(source) 
--local admin = isObjectInACLGroup ( "user."..getAccountName ( getPlayerAccount ( source ) ), aclGetGroup ( "Admin" ) ) 
mass = 100000 
veh = getPedOccupiedVehicle (ped) 
--local oldmass = getVehicleHandlingProperty ( element, "mass" ) 

any hint? which function should I use to define source ?

Edited by Guest
Link to comment

Man but atleast explain me what is wrong there? I don't see any mistake , i replaced source in 1,3 lines with "player" element and still don''t work I don't see any forking Idea why it shouldn't work

not logic man I made few small scripts and I'm not totally noob at scripting, but idk whats wrong with this.. just tell me if u know

Link to comment
  • Moderators
I'm not totally noob at scripting, but idk whats wrong with this.. just tell me if u know

Yes you are ! as you didn't understand that predefined variable like client and source are only available into functions that are handlers for events and that the value of source is different depending on the event it is handling.

You asked again to tell you what is wrong so here is your answer:

- You are trying to use undefined variables as arguments (source, theAccount and I can see ped aswell)

You are obviously not understanding what you are doing so read and follow the tutorials from the wiki first:

https://wiki.multitheftauto.com/wiki/Scr ... troduction

Here is a working example I could make from your code:

function changeMass(thePlayer, cmd, newMass) 
    local account = getPlayerAccount(thePlayer) -- get his account 
    local accName = getAccountName(account) -- get his account name 
    local isAdmin = isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) 
    if isAdmin then 
        local veh = getPedOccupiedVehicle(thePlayer) 
        if veh then 
            local oldMass= getVehicleHandlingProperty (veh, "mass") 
            setVehicleHandling(veh, "mass", tonumber(newMass)) 
            outputChatBox("The mass of the car changed from "..oldMass.." to "..newMass..".", thePlayer, 0, 200, 0) 
        else 
            outputChatBox("You must be in a car first !", thePlayer, 200, 0, 0) 
        end 
    else 
        outputChatBox("You are not allowed to use this command !", thePlayer, 200, 0, 0) 
    end 
end 
addCommandHandler("changeMass", changeMass, false, false) 

Use /changeMass 20 to set the vehicle's mass to 20.

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