• Gmod 13 Possiable Script Read ERROR
    6 replies, posted
over the last view days i have been scripting a gamemode for Garry's Mod 13 and im Nearly 300% that the error the console is pointing to is Correct and there is a gmod Script Read Error Instead i will post the error and the script below [CODE] AMMO! [ERROR] gamemodes/team ruca deathmatch/gamemode/shared.lua:41: attempt to call method 'GiveAmmo' (a nil value) 1. unknown - gamemodes/team ruca deathmatch/gamemode/shared.lua:41 Timer Failed! [Reward][@gamemodes/team ruca deathmatch/gamemode/shared.lua (line 47)] [/CODE] Script **NOTE** that the first line is realy the 34th* [CODE] function AmmoGive ( ply ) local ply = Entity(1) MsgN("AMMO!") if ply:Team() == 1 then ply:GiveAmmo(36,"pistol") ply:GiveAmmo(30,"AR2") elseif ply:Team() == 2 then ply:GiveAmmo(12,"357") ply:GiveAmmo(45,"SMG1") end MsgN("DONE!") end timer.Create("Reward", 30, 0, AmmoGive)] [/CODE] if anyone knows why the script is wrong then please help out and reply!
Well The Problem Is Obvious You Need To Replace GiveAmmo With Spawn
Why Did You Rate My Post Dumb Without Posting Why You Did It Bitch Scared Of The Intellectual Ass Whooping I Would Bring On You
Well replacing the GiveAmmo hook with Spawn will not work this because the Spawn hook acculy used to spawn/respawn entity's such as props and npc's in this case in adding ammo (witch isn't a entity) in to the players inventory because this way it won't spawn the ammo entity at the players feet and the pick I up it will just add ammo directly.
[QUOTE='[Ruca]Hunna;38593824']over the last view days i have been scripting a gamemode for Garry's Mod 13 and im Nearly 300% that the error the console is pointing to is Correct and there is a gmod Script Read Error Instead i will post the error and the script below [CODE] AMMO! [ERROR] gamemodes/team ruca deathmatch/gamemode/shared.lua:41: attempt to call method 'GiveAmmo' (a nil value) 1. unknown - gamemodes/team ruca deathmatch/gamemode/shared.lua:41 Timer Failed! [Reward][@gamemodes/team ruca deathmatch/gamemode/shared.lua (line 47)] [/CODE] Script **NOTE** that the first line is realy the 34th* [CODE] function AmmoGive ( ply ) local ply = Entity(1) MsgN("AMMO!") if ply:Team() == 1 then ply:GiveAmmo(36,"pistol") ply:GiveAmmo(30,"AR2") elseif ply:Team() == 2 then ply:GiveAmmo(12,"357") ply:GiveAmmo(45,"SMG1") end MsgN("DONE!") end timer.Create("Reward", 30, 0, AmmoGive)] [/CODE] if anyone knows why the script is wrong then please help out and reply![/QUOTE] Entity(1) isn't always the player. Just remove the local ply = Entity(1), that should fix it.
Bear in mind he's calling the function from a timer and ply is going to be nil anyway.
Just to update: we got this working. Solution: [CODE]function AmmoGive ( ply ) local Players = player.GetAll() for i = 1, table.Count(Players) do local ply = Players[i] if ply:Team() == 1 then ply:GiveAmmo(30,"AR2") ply:GiveAmmo(36,"pistol") elseif ply:Team() == 2 then ply:GiveAmmo(45,"SMG1") ply:GiveAmmo(12,"357") end end end timer.Create("Reward", 30, 0, AmmoGive)[/CODE] Works perfectly. Thanks for the input, guys. I'll get the OP to mark as Solved.
Sorry, you need to Log In to post a reply to this thread.