Jump to content

Script bad argument ?


tim260

Recommended Posts

Posted

I have an error when im using the gatemaker tried to use some other functions and stuff i have red the wiki but i dont understand the errors it says bad argument @ getTeamName and its on rule 24 see it below

local name = getTeamName(getPlayerTeam(hitElement)) 

Posted
function checkClass(hitElement, matchingDimension) 
  
    if ( getElementType(hitElement) == "vehicle" ) then 
        hitElement = getVehicleController(hitElement) 
    end 
  
    for i=0,#gateList do  
        local name = getTeamName(getPlayerTeam(hitElement)) 
        if(name == false) then 
            name = "false" 
        end 
        if ( name == team[i] or name == "false") then  
            detection = isElementWithinColShape ( hitElement, shapes[i] ) 
            if detection == true then  
                move(i, false) 
            end 
        end 
    end 
end 

thats the script but it really says that the getteamname is wrong in the server :D

Bad argument @ `getTeamName` 

Posted
function checkClass(hitElement, matchingDimension)  
    if ( getElementType(hitElement) == "vehicle" ) then 
        hitElement = getVehicleController(hitElement) 
    end 
  
    for i=0,#gateList do 
        if not getPlayerTeam(hitElement) then return end 
        local name = getTeamName(getPlayerTeam(hitElement)) 
        if(name == false) then 
            name = "false" 
        end 
        if ( name == team[i] or name == "false") then 
            detection = isElementWithinColShape ( hitElement, shapes[i] ) 
            if detection == true then 
                move(i, false) 
            end 
        end 
    end 
end 

Try that.

  • MTA Team
Posted
function checkClass(hitElement, matchingDimension)  
    if ( getElementType(hitElement) == "vehicle" ) then 
        hitElement = getVehicleController(hitElement) 
    end 
    if not isElement(hitElement) then return end  
  
    for i=0,#gateList do 
        if not getPlayerTeam(hitElement) then return end 
        local name = getTeamName(getPlayerTeam(hitElement)) 
        if(name == false) then 
            name = "false" 
        end 
        if ( name == team[i] or name == "false") then 
            detection = isElementWithinColShape ( hitElement, shapes[i] ) 
            if detection == true then 
                move(i, false) 
            end 
        end 
    end 
end 

Try that.

Posted

Try with these functions:

setPlayerTeam -- Sets the player team 
createTeam --Creates a team 
isObjectInACLGroup --Check is user in Admin group. 
  
onPlayerLogin --You must use this event to move a player in a team. 
  

Posted
setPlayerTeam -- Sets the player team 
createTeam --Creates a team 
onPlayerLogin --You must use this to move a player in a team. 
isObjectInACLGroup --Check is user in Admin group. 

Posted

Thanks TAPL :D

This is the code ? :D so i see there is written teamAdmmin with 2 "m" is that correct

function createTeamsOnStart () 
    teamAdmmin = createTeam ( "Admin", 0, 255, 0 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart  ) 
  
local root = getRootElement() 
  
addEventHandler("onPlayerLogin", root 
if isObjectInACLGroup ( "user." .. playerName, aclGetGroup ( "Admin" ) ) then 
local theTeam = getPlayerTeam ( source ) 
  if theTeam then                       
    setPlayerTeam ( source, Admin ) 
  end 
end 

  • Discord Moderators
Posted

Really buggy. Look at line 8 and on, does this look correct to you?

Also if you define teamAdmmin, but you tell the script to get Admin, how is it supposed to work?

function createTeamsOnStart () 
    teamAdmmin = createTeam ( "Admin", 0, 255, 0 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart  ) 
  
local root = getRootElement() 
  
addEventHandler("onPlayerLogin", root, 
    function (_, account) 
        if isObjectInACLGroup ("user." .. getAccountName(account), aclGetGroup("Admin" )) then                   
            setPlayerTeam (source, teamAdmmin) 
        end 
    end 
) 

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