• Self error code is not executed by custom function in metatable
    3 replies, posted
Hello, i just saw the tutorial by Omni Ed with the topic of setting teams and adding lua files (4). i did exactly what he did and it works.. halfway.. The Code only executes when i call a method that is nil (does not exist). i relly hope you have an idea init.lua: AddCSLuaFile("shared.lua") AddCSLuaFile("cl_init.lua") AddCSLuaFile("controller/cl_controller.lua") --AddCSLuaFile("money/cl_init.lua") include( "shared.lua" ) include("controller/sv_controller.lua") AddCSLuaFile("teamsetup.lua") include("teamsetup.lua") --include("money/sv_init.lua") DeriveGamemode("sandbox") --include("tests/test.lua") --function GM:PlayerSpawn(player) --MsgN(player:Nick() .. " has spawned!") --player:SetModel("models/player/odessa.mdl") --end function GM:ShowHelp (player) player:SetHealth(100) --increaseMoney(100) --MsgN(MyGam.Hello) end function Spawn(player) player:ChatPrint("You have spawned") player:SetPos(Vector(0,0,0)) player:SetupTeam(math.random(0,1)) end teamsetup.lua: (does NOT work) local ply = FindMetaTable("Player") local teams = {} teams[0] = { name = "Red", color = Vector(1.0,0,0), weapons= {}} teams[1] = { name = "Blue", color = Vector(0,0,1.0), weapons= {}} function ply:SetupTeam(n) print("ROFFFFFFFFFFFLLLLLL") if (not teams[n]) then return end print("ROFFFFFFFFFFFLLLLLL") self:SetTeam( n ) self:SetPlayerColor(teams[n].color) self:SetHealth( 150 ) self:SetMaxHealth( 290 ) self:SetWalkSpeed(100) self:SetRunSpeed(1000) --self:SetModel("models/player/Group03m/Male_0" .. math.random(1,9) .. ".mdl") self:SendHint("Hallo", 10) print("Spawn endemd") end teamsetup.lua (does work) local ply = FindMetaTable("Player") local teams = {} teams[0] = { name = "Red", color = Vector(1.0,0,0), weapons= {}} teams[1] = { name = "Blue", color = Vector(0,0,1.0), weapons= {}} function ply:SetupTeam(n) print("ROFFFFFFFFFFFLLLLLL") if (not teams[n]) then return end print("ROFFFFFFFFFFFLLLLLL") self:SetTeam( n ) self:SetPlayerColor(teams[n].color) self:SetHealth( 150 ) self:SetMaxHealth( 290 ) self:SetWalkSpeed(100) self:SetRunSpeed(1000) --self:SetModel("models/player/Group03m/Male_0" .. math.random(1,9) .. ".mdl") self:SendHint("Hallo", 10) self:randomfunctiondoesnotexistlol123() print("Spawn endemd") end
Don't make several threads for the same thing.
to be fair, one was in gmod general and this one is in lua developer. So i GUESS he noticed its in the wrong thread so he did it in the "right" one now. But i see alot people doing that so..
yeah sorry im pretty new here ^^'
Sorry, you need to Log In to post a reply to this thread.