• 'then' expected near 'in'
    2 replies, posted
Hello, I come to you people with a problem. [code]local function AddClassIcon(Model, description, class, command) if LocalPlayer():Team() in class then local icon = vgui.Create("SpawnIcon") icon:InvalidateLayout( true ) icon:SetModel(Model) icon:SetIconSize(64) icon:SetToolTip(description) icon.DoClick = function() LocalPlayer():ConCommand("say "..command) end WepPanel:AddItem(icon) end end AddClassIcon("models/weapons/w_mach_m249para.mdl", "Buy Para $600", TEAM_POLICE, "/buyammo pistol")[/code] Error: [code][gamemodes\darkrp\gamemode\showteamtabs.lua:653] 'then' expected near 'in' [gamemodes\darkrp\gamemode\init.lua:54] ERROR PARSING CLIENTSIDE FILE: 'DarkRP\gamemode/showteamtabs.lua'[/code] I'm wondering why its saying this when there is a then :(
You're mixing up 2 things : The if statement ( "if [true] then ... End" ) And the for loop ( "for var in pairs( table ) do ... End" )
[code]local function AddClassIcon(Model, description, class, command) if LocalPlayer():Team() == class then local icon = vgui.Create("SpawnIcon") icon:InvalidateLayout( true ) icon:SetModel(Model) icon:SetIconSize(64) icon:SetToolTip(description) icon.DoClick = function() LocalPlayer():ConCommand("say "..command) end WepPanel:AddItem(icon) end end AddClassIcon("models/weapons/w_mach_m249para.mdl", "Buy Para $600", TEAM_POLICE, "/buyammo pistol")[/code] try that.
Sorry, you need to Log In to post a reply to this thread.