• Checking to see what a players team is when they talk to an NPC
    2 replies, posted
So i'm new to Lua and I came across this error when trying to do a simple check on a players team when they speak with an NPC. Essentially what happens is that when a non police officer talks to the NPC i'm trying to make it alert the SWAT & Police that someone is in the PD. This is probably a really dumb error I have made but I would appreciate any feedback. Here is the code... [CODE]function NPC.OnTalk ( ) if (LocalPlayer():GetNWInt("hand_cuffs") == true) then LEAVE_DIALOG() end if (LocalPlayer():IsGovernmentOfficial()) then GAMEMODE.DialogPanel:SetDialog("Hello what can I do for you?") GAMEMODE.DialogPanel:AddDialog("Can you help me with this criminal?", NPC.GetPlayers) GAMEMODE.DialogPanel:AddDialog("Could you please help me release a prisoner?", NPC.Release) GAMEMODE.DialogPanel:AddDialog("Could you please open the gate(s) for me?", NPC.DoDoors_OPEN) GAMEMODE.DialogPanel:AddDialog("Could you please close the gate(s) for me?", NPC.DoDoors_CLOSE) GAMEMODE.DialogPanel:AddDialog("Nevermind...", LEAVE_DIALOG) else GAMEMODE.DialogPanel:SetDialog("I don't think you should be here! I'm calling for backup!") GAMEMODE.DialogPanel:AddDialog("Err, Err, FUCK YOU!!!", LEAVE_DIALOG) for k, v in pairs( player.GetAll() ) do if v:Team == TEAM_POLICE || TEAM_SWAT then v:Notify("Someone is trespassing in the PD!") end end end[/CODE] The error i'm getting... [CODE][ERROR] gamemodes/secret/gamemode/npcs/police_jail.lua:37: function arguments expected near '==' 1. unknown - gamemodes/secret/gamemode/npcs/police_jail.lua:0[/CODE]
(I think) the error you're getting is at [code] if v:Team == TEAM_POLICE || TEAM_SWAT then [/code] v:Team is a function, so you need to call it as v:Team() Also, you want to check each condition, so you need to do [code] if v:Team() == TEAM_POLICE || v:Team() == TEAM_SWAT then [/code]
snip
Sorry, you need to Log In to post a reply to this thread.