• No matterwhat i cant set global GAMEOBJECT var's!
    8 replies, posted
I need help! :( Its been a while but im pretty sure im doing everthing right. It wont let me set the GAMEMODE variables. Can you help me? :( ty in advance! :) [CODE] --Includes AddCSLuaFile("../client/cl_armorsystem.lua") AddCSLuaFile("../share/sh_armorsystem.lua") --Configuration-- GAMEMODE.armorSets={ --Format : [NAME]={NAME,resoucecost,armour percent} ["Leather"]={"Leather",1,10}, ["Mail"]={"Leather",1,10}, ["Plate"]={"Leather",1,10} } --Pickup Type ( 0 = Overide previous armor, 1 = Add new armor total to old armor total.) GAMEMODE.pickupTypes=1; --Class restricted (set as false if you dont want it to be, but if true set it to the team of the class) GAMEMODE.classRestricted=false; --Class Starter Armors ( ) GAMEMODE.classStarterArmor={ -- Format is { Class Team, Armor Name} {"Gun Dealer","Leather"} } --End Of Configuration hook.Add( "PlayerSpawn", "giveStarterArmor", function(ply) for i,v in ipairs(GAMEMODE.classStarterArmor)do if(team.GetName(ply:Team())==v[1])then ply:giveArmor(v[2]) print("Gave "..ply:Nick().." Armor ( TYPE : "..v[2]..")!") end end end) local plymeta = FindMetaTable("Player") function plymeta:giveArmor( armorType) if(GAMEMODE.pickupTypes==0)then local newarmor = GAMEMODE.armorSets[armorType][3] self:SetArmor(newarmor) elseif(GAMEMODE.pickupTypes==1)then local oldarmor = self:Armor() local newarmor = oldarmor+GAMEMODE.armorSets[armorType][3] self:SetArmor(newarmor) end end [/CODE] Its all in the auto runs if you couldnt tell! :P
[QUOTE=DamienTehDemo;48899003]I need help! :( Its been a while but im pretty sure im doing everthing right. It wont let me set the GAMEMODE variables. Can you help me? :( ty in advance! :) [CODE] --Includes AddCSLuaFile("../client/cl_armorsystem.lua") AddCSLuaFile("../share/sh_armorsystem.lua") --Configuration-- GAMEMODE.armorSets={ --Format : [NAME]={NAME,resoucecost,armour percent} ["Leather"]={"Leather",1,10}, ["Mail"]={"Leather",1,10}, ["Plate"]={"Leather",1,10} } --Pickup Type ( 0 = Overide previous armor, 1 = Add new armor total to old armor total.) GAMEMODE.pickupTypes=1; --Class restricted (set as false if you dont want it to be, but if true set it to the team of the class) GAMEMODE.classRestricted=false; --Class Starter Armors ( ) GAMEMODE.classStarterArmor={ -- Format is { Class Team, Armor Name} {"Gun Dealer","Leather"} } --End Of Configuration hook.Add( "PlayerSpawn", "giveStarterArmor", function(ply) for i,v in ipairs(GAMEMODE.classStarterArmor)do if(team.GetName(ply:Team())==v[1])then ply:giveArmor(v[2]) print("Gave "..ply:Nick().." Armor ( TYPE : "..v[2]..")!") end end end) local plymeta = FindMetaTable("Player") function plymeta:giveArmor( armorType) if(GAMEMODE.pickupTypes==0)then local newarmor = GAMEMODE.armorSets[armorType][3] self:SetArmor(newarmor) elseif(GAMEMODE.pickupTypes==1)then local oldarmor = self:Armor() local newarmor = oldarmor+GAMEMODE.armorSets[armorType][3] self:SetArmor(newarmor) end end [/CODE] Its all in the auto runs if you couldnt tell! :P[/QUOTE] why are you storing it inside the gamemode table? Config = {} Config.ArmorSets = { stuff, stuff2, } would work perfectly fine
[QUOTE=legendofrobbo;48899424]why are you storing it inside the gamemode table? Config = {} Config.ArmorSets = { stuff, stuff2, } would work perfectly fine[/QUOTE] Gotta access it from a entity. :s
then you can make your table global and you can still acess it
[QUOTE=Tomelyr;48899509]then you can make your table global and you can still acess it[/QUOTE] What..? What you mean? O-o Theres a way to make global varaibles?? I thought the global variables were only the gamemode variables
[QUOTE=DamienTehDemo;48899532]What..? What you mean? O-o Theres a way to make global varaibles?? I thought the global variables were only the gamemode variables[/QUOTE] Any newly defined variable not preceded by the keyword "local" is considered global (there are certain circumstances where this will not be true, notably when messing around with the environment, but you shouldn't run into that problem yet).
[QUOTE=DamienTehDemo;48899532]What..? What you mean? O-o Theres a way to make global varaibles?? I thought the global variables were only the gamemode variables[/QUOTE] nah nah lua doesn't work like that local function func1() <-- local and can only be accessed from inside the file its located in function func1() <-- global and can be accessed from anywhere as long as its in the same environment(can't access a clientside global directly from a serverside file, you'd need to network it)
[QUOTE=legendofrobbo;48899603]nah nah lua doesn't work like that local function func1() <-- local and can only be accessed from inside the file its located in function func1() <-- global and can be accessed from anywhere as long as its in the same environment(can't access a clientside global directly from a serverside file, you'd need to network it)[/QUOTE] HAX HAX HAX , but ty :3
[QUOTE=legendofrobbo;48899603]nah nah lua doesn't work like that local function func1() <-- local and can only be accessed from inside the file its located in function func1() <-- global and can be accessed from anywhere as long as its in the same environment(can't access a clientside global directly from a serverside file, you'd need to network it)[/QUOTE] You say no and then in words agree with what I said. Also, when I said environment I meant environment (see setenv), not realm.
Sorry, you need to Log In to post a reply to this thread.