• ATM Banker v3 - Question
    6 replies, posted
I have an error, maybe you can help me. This is the error: [lua] [ERROR] addons/darkrp_atm/lua/autorun/server/atmspawn.lua:17: bad argument #1 to 'pairs' (table expected, got nil) 1. pairs - [C]:-1 2. LoadATMs - addons/darkrp_atm/lua/autorun/server/atmspawn.lua:17 3. fn - addons/darkrp_atm/lua/autorun/server/atmspawn.lua:52 4. unknown - addons/ulib/lua/ulib/shared/hook.lua:183 [/lua] And this is the code: [QUOTE][CODE] hook.Add( "PlayerInitialSpawn", "PSNoteBank", function( ply ) ply:ChatPrint( "This server uses DarkRP ATM Banker!" ) end ) local function CreateATMMachine( pos, ang ) local ATM = ents.Create( "ATM_Machine" ) ATM:SetPos( pos ) ATM:SetAngles( ang ) ATM:Spawn() ATM:Activate() end local function LoadATMs() if ( file.Exists( "ATM/"..string.lower( game.GetMap() )..".txt", "DATA" ) ) then local ATMs = util.JSONToTable( file.Read( "ATM/" .. string.lower( game.GetMap() ) .. ".txt" ) ) for id, tab in pairs( ATMs ) do CreateATMMachine( tab.pos, tab.ang ) end else MsgN("ATM Spawn file is missing for map " .. string.lower( game.GetMap() ) ) end end concommand.Add( "rp_atm_removespawns", function( ply ) if ( IsValid( ply ) && !ply:IsUserGroup("superadmin") ) then return end file.Delete( "ATM/"..string.lower( game.GetMap() )..".txt" ) end ) concommand.Add( "rp_atm_savespawns", function( ply ) if ( IsValid( ply ) && !ply:IsUserGroup("superadmin") ) then return end local tableOfATMs = {} for k, v in pairs( ents.FindByClass( "ATM_Machine" ) ) do table.insert( tableOfATMs, { ang = v:GetAngles(), pos = v:GetPos() } ) end if ( !file.IsDir( "ATM", "DATA" ) ) then file.CreateDir( "ATM" ) end file.Write( "ATM/"..string.lower( game.GetMap() ) .. ".txt", util.TableToJSON( tableOfATMs ) ) end ) concommand.Add( "rp_atm_respawnall", function( ply ) if ( IsValid( ply ) && !ply:IsUserGroup("superadmin") ) then return end for k, v in pairs( ents.FindByClass( "ATM_Machine" ) ) do v:Remove() end LoadATMs() end ) concommand.Add( "rp_atm_removeall", function( ply ) if ( IsValid( ply ) && !ply:IsUserGroup("superadmin") ) then return end for k, v in pairs( ents.FindByClass( "ATM_Machine" ) ) do v:Remove() end end ) hook.Add( "InitPostEntity","atm", function() LoadATMs() end )[/CODE][/QUOTE]
Delete garrysmod/data/ATM folder on your server
Why delete?
Because files in it are corrupted.
Okay, I have delete it and now is created the folder garrysmod/data/atm/ - when I am save a atm on the server, there aren't creating the spawn file - why?
Map name? Are you super admin on your server?
Yes I am superadmin and the map is rp_bangclaw
Sorry, you need to Log In to post a reply to this thread.