• Attempt to concante a userdata value
    6 replies, posted
First one Hook 'Adds a zombiespawner at the caller's location' Failed: [gamemodes\zombies\gamemode\chatcommands.lua:35] attempt to concatenate local 'POS' (a userdata value) S [CODE] hook.Add( "PlayerSay", "Adds a zombiespawner at the caller's location", function( ply, text, team ) if (text == "/addzombiespawner") then if !ply:IsAdmin() then return "" else local POS = sql.Query("INSERT INTO spawners (map, vector, propspawner, zombiespawner ) VALUES ('"..game.GetMap().."','"..POS.."', 'false', 'true'") end end end) [/CODE] 2. This one is meant to update a value stored on a database but when i do it the value doesnt have appeared to change ( I have a chat command that prints it in chat) [CODE] hook.Add( "PlayerSay", "Adds a specific amount of credits to a player if they are an admin", function ( ply, text, team ) if not ply:IsAdmin() then return "" else if string.sub(text, 8) == "/addcred" then local amtc = tonumber(string.sub(text,9)) local ocredits = tonumber(sql.QueryValue("SELECT credits FROM player_points WHERE unique_id = '"..ply:SteamID().."'")) local ncredits = ocredits + amtc sql.Query("UPDATE player_points(credits) VALUES ('"..ncredits.."') WHERE unique_id = '"..ply:SteamID().."'") else return text end end end) [/CODE]
Thanks Also i'm trying to get a table of stored data using SQLite but it doesn't work ( i get a "expected table, got nil" error) [CODE] amts = sql.QueryRow("SELECT vector FROM spawners WHERE map = '"..game.GetMap().."' AND zombiespawner = 'true'") function Spawn_zombies() for k,v in pairs(amts) do timer.Create("ZombieSpawn", 4, 20, function() local ent1 = ents.Create("npc_zombie") ent1:SetPos( v ) ent1:Spawn() end) end process = 0 end [/CODE]
And what lines are you getting these errors? It helps a bit for me to know so that i may be able to take a closer look without having to search every character :P Its 2 am and im lazyyyy
In the code snippet it is line 3 (for k,v in pairs...)
[QUOTE=selekton99;32161598]In the code snippet it is line 3 (for k,v in pairs...)[/QUOTE] Ill check it out tomorrow but first a couple questions. Nil is basically meaning that its not getting anything from the table (If im not mistaking someone correct me) So make sure that you actually have something in the table (Im sure you do) Q1:What modual are you using for mysql? Q2:Are your tables named correctly? (This happened to me a couple of times when i stared a bit ago) Double check those things. :] ill respond later today with a answer hopefully unless someone responds first
Q1: It's not mysql it's the built in sql library Just realised it is now returning boolean (when something was in it) and yes there is things in it. Thanks in advance
Sorry, you need to Log In to post a reply to this thread.