Jump to content

Wierd error @ Bad Argument 'blowVehicle'


'LinKin

Recommended Posts

Hello,

I've been working on an AFK Killer / Kicker.

I've modified the following function:

function afkKill() 
        local car = getPedOccupiedVehicle(source) 
        blowVehicle (car) 
                --setElementHealth( source, 0) 
end 
addEvent( "afkSlap", true ) 
addEventHandler( "afkSlap", getRootElement(), afkKill) 

*Note: The original funtion did not include the code-lines 2,3. (original function works 100%)

When I test the modified function in my local server, it works perfectly. '/debugscript 3' doesn't show any @Bad Argument.

But, when I upload it in a hosted server oppened for public, the script doesn't work.

While having enabled 'debugscript 3'; the console shows an error by the following statement "@ Bad Argument 'blowVehicle' ". Which causes the script run prematurely (when the player is killed by the first time by the AFK, the 'bug' makes it to keep counting the number of times the played was killed by AFK up to 3 (which is the limit and when the player gets kicked)) as a result, the player gets kicked if he's killed just once by the AFK.

Any ideas / solutions related to this problem are welcome.

Thanks,

LinKin.

Link to comment
  • Moderators
function afkKill() 
    local car = getPedOccupiedVehicle(source) 
    if car then 
        blowVehicle (car) 
    end 
end 
addEvent( "afkSlap", true ) 
addEventHandler( "afkSlap", getRootElement(), afkKill) 

Make sure he has a car before you try to blow it.

You can't blow a boolean(false). :D

Link to comment
local player = getLocalPlayer() 
        if(AFKtime >= MaxAFKtime) then 
            if (afkCounter <= 4) then 
                triggerServerEvent ( "afkWarn", player, 1, afkCounter) 
                afkCounter = afkCounter+1 
                triggerServerEvent ( "afkSlap", player) 
                stopWarn() 

Link to comment
local player = getLocalPlayer() 
        if(AFKtime >= MaxAFKtime) then 
            if (afkCounter <= 4) then 
                triggerServerEvent ( "afkWarn", player, 1, afkCounter) 
                afkCounter = afkCounter+1 
                triggerServerEvent ( "afkSlap", player) 
                stopWarn() 

local player = getLocalPlayer() 
        if(AFKtime >= MaxAFKtime) then 
            if (afkCounter <= 4) then 
                triggerServerEvent ( "afkWarn", player, 1, afkCounter) 
                afkCounter = afkCounter+1 
                triggerServerEvent ( "afkSlap", root, player) 
                stopWarn() 

Try now.

Link to comment
local player = getLocalPlayer() 
        if(AFKtime >= MaxAFKtime) then 
            if (afkCounter <= 4) then 
                triggerServerEvent ( "afkWarn", player, 1, afkCounter) 
                afkCounter = afkCounter+1 
                triggerServerEvent ( "afkSlap", player) 
                stopWarn() 

local player = getLocalPlayer() 
        if(AFKtime >= MaxAFKtime) then 
            if (afkCounter <= 4) then 
                triggerServerEvent ( "afkWarn", player, 1, afkCounter) 
                afkCounter = afkCounter+1 
                triggerServerEvent ( "afkSlap", root, player) 
                stopWarn() 

Try now.

You cannot get the vehicle of "root."

Link to comment
local player = getLocalPlayer() 
        if(AFKtime >= MaxAFKtime) then 
            if (afkCounter <= 4) then 
                triggerServerEvent ( "afkWarn", player, 1, afkCounter) 
                afkCounter = afkCounter+1 
                triggerServerEvent ( "afkSlap", player) 
                stopWarn() 

local player = getLocalPlayer() 
        if(AFKtime >= MaxAFKtime) then 
            if (afkCounter <= 4) then 
                triggerServerEvent ( "afkWarn", player, 1, afkCounter) 
                afkCounter = afkCounter+1 
                triggerServerEvent ( "afkSlap", root, player) 
                stopWarn() 

Try now.

You cannot get the vehicle of "root."

root = rootElement, the function is being triggered across file types, I think root is moreover recommended. We aren't stating the vehicle in this side of the function, that all comes on the other file.

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