Jump to content

Server error codes


Recommended Posts

Hello everybody,

I'm making a server but sometimes i get a error from the debugscript.

For example:

WARNING: [gameplay]\(SARS)Mechanic\server.lua:63: Bad argument @ 'getTeamName' [Expected team at argument 1, got boolean]

or

WARNING: [gameplay]\(SARS)Police\JobVehicle\s_vehicles.lua:3: Bad argument @ 'getPlayerTeam' [Expected player at argument 1, got nil]

What does the [Expected team at argument 1, got boolean] and [Expected player at argument 1, got nil] mean?

I don't understand it but i want to understand it :P

Is there a list with the information what does error means?

Sorry for bad English :P

Hope somebody could help me :)

Link to comment

What? The team name is the same name in server.lua.

Server:

  
Teame1= createTeam("Mechanic",0,255,160) 
  
miqTeams = { [Teame1] = true } 
miqVehs = { [525] = true } 
  
local vehicleTable = {} 
function teamSet ( ) 
    local team = getTeamFromName ( "Mechanic" ) 
    if team then 
        local TT = vehicleTable[source] -- load 
        if TT then -- check 
            if isElement( TT ) then 
                destroyElement( TT ) 
            end 
            vehicleTable[source]= nil -- clean 
        end 
        setPlayerTeam ( source, team ) 
        setPlayerNametagColor ( source, 0, 255, 0 ) 
        setElementModel(source, 50) 
            TT = createVehicle(525,1063.32, -1030.27, 32.29, 0, 0, 180) 
            warpPedIntoVehicle ( source, TT ) 
            vehicleTable[source]= TT 
            outputChatBox("You are now employed as a Mechanic!", thePlayer) 
        else 
            local teamw = getTeamFromName ( "Mechanic" ) 
            if teamw then 
            cancelEvent() 
            outputChatBox("You are already a Mechanic!", source) 
        end 
    end 
end 
addEvent ( "sTeame5", true) 
addEventHandler ( "sTeame5", root, teamSet ) 
  
function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle 
    if getElementType ( thePlayer ) == "player" then 
    if ( miqVehs[getElementModel ( source )] ) and ( not miqTeams[getPlayerTeam( thePlayer )] ) then -- if the vehicle is one of 4 police cars, and the skin is not a police skin 
            removePedFromVehicle( thePlayer )-- force the player out of the vehicle 
            outputChatBox("Only Mechanics can drive this vehicle!", thePlayer) 
        end 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 
  
addEventHandler("onPlayerQuit",root, 
function () 
    local TT = vehicleTable[source] 
    if TT then 
        if isElement( TT ) then 
            destroyElement( TT ) 
        end 
        vehicleTable[source]= nil 
    end 
end) 
  
local allowedTeams = {  
["Mechanics"] = true, 
["Mechanic"] = true, 
} 
  
function fix () 
car = getPedOccupiedVehicle(source) 
if allowedTeams[getTeamName(getPlayerTeam(source))] and getElementHealth(car) < 999 then 
price = 1001 - getElementHealth(car)  
givePlayerMoney(source, price*2) 
fixVehicle(car) 
outputChatBox("You have repair Brooken Stuff of this car", source, 0, 255, 0) 
end 
end 
addEventHandler("onPlayerVehicleEnter", getRootElement(), fix) 
  

Link to comment

That's 'cause the player doesn't have a team.

To fix this just add this before every getTeamName() check:

local team = getPlayerTeam(player); --Return a Team or nil if the player doesn't have a team; 
if team then --If the team ~= nil; 
    teamName = getTeamName(team); -- Get team name; 
end 

You most likely did it like this:

local team = getPlayerTeam(player); --This was returning nil; 
local teamName = getTeamName(team); --And then you tried to get the them name of a nil (NOTHING); 

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