Jump to content

HELP needed lua


teronrussell

Recommended Posts

Editor      = {} 
Gate        = {} 
Gate2       = {} 
Precision   = {} 
status      = {} 
coll        = {} 
coll2        = {} 
coll3        = {} 
coll4        = {} 
  
 -- this script mod is (no longer) PRIVATE 
 -- - Deject3d 
  
function startBuilding(playerSource, commandName, objectid) 
    if not objectid then 
        outputChatBox("usage: /addgate objectid teamname", playerSource) 
    end 
         
    team = getTeamName(getPlayerTeam(playerSource)) 
    if team == false then 
        team = "" 
    end 
    for i = 1,20 do 
        if Editor[i] == playerSource then 
            destroyElement(Gate[i]) 
            Gate[i] = null 
            Editor[i] = null 
            Precision[i] = null 
        end 
        if Editor[i] == null then 
            Editor[i] = playerSource -- set Editor[i] to who made the object 
  
                --creating object -v 
            local x,y,z = getElementPosition(playerSource) 
            object = createObject ( objectid, x + 3,y + 3,z) 
            interior = getElementInterior ( playerSource ) 
            setElementInterior(object,interior) 

i need help i keep getting warning errors at lines:19,25,35,37

Link to comment

team = getTeamName(getPlayerTeam(playerSource))

getPlayerTeam() returns false if player is not in a team, so resulting getTeamName(false) can cause your warning

destroyElement(Gate)

destroyElement() can cause a warning if Gate is not an element ,use «if isElement(Gate) then destroyElement(Gate) end»

object = createObject ( objectid, x + 3,y + 3,z)

«objectid» can be undefined. there is a check whether it is specified, but it does nothing to prevent the rest of the code from running.

     if not objectid then 
         outputChatBox("usage: /addgate objectid teamname", playerSource) 
         return false  
     end 

setElementInterior(object,interior)

error here is a result of error at line 35 («object» wasnt created).

PS: «null» in Lua is «nil»

Link to comment
Editor      = {} 
Gate        = {} 
Gate2       = {} 
Precision   = {} 
status      = {} 
coll        = {} 
coll2        = {} 
coll3        = {} 
coll4        = {} 
  
 -- this script mod is (no longer) PRIVATE 
 -- - Deject3d 
  
function startBuilding(playerSource, commandName, objectid) 
    if not objectid then 
        outputChatBox("usage: /addgate objectid teamname", playerSource) 
        return false 
    end 
         
    team = getTeamName(getPlayerTeam(playerSource)) 
    if team == false then 
        team = "" 
    end 
    for i = 1,20 do 
        if Editor[i] == playerSource then 
            destroyElement(Gate[i]) 
            Gate[i] = null 
            Editor[i] = null 
            Precision[i] = null 
        end 
        if Editor[i] == null then 
            Editor[i] = playerSource -- set Editor[i] to who made the object 
  
                --creating object -v 
            local x,y,z = getElementPosition(playerSource) 
            object = createObject ( objectid, x + 3,y + 3,z) 
            interior = getElementInterior ( playerSource ) 
            setElementInterior(object,interior) 

now i have a warning for lines 20,36,38

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