SetPos setting player to vector 0 0 0 no matter what :/

this makes players goes to vector 0 0 0 but why … ?
and how to fix it … ? :stuck_out_tongue:

[lua]
function meta:Arrest()
if not self:IsPlayer() then return end

local ArrestPosition = {}
ArrestPosition[1] = "-2205.760254, 165.064667, -131.968750"
ArrestPosition[2] = "-2094.647461, 157.306168, -131.968750"
ArrestPosition[3] = "-2004.702393, 160.443497, -131.968750" 
ArrestPosition[4] = "-1892.039063, 180.676239, -131.968750"

self:SetPos(Vector(table.Random(ArrestPosition)))
Msg( table.Random(ArrestPosition) .. "

" )
end
[/lua]

cause its not a vector its a string in the table…

function meta:Arrest()
    if not self:IsPlayer() then return end
    
    local ArrestPosition = {}
    ArrestPosition[1] = {-2205.760254, 165.064667, -131.968750}
    ArrestPosition[2] = {-2094.647461, 157.306168, -131.968750}
    ArrestPosition[3] = {-2004.702393, 160.443497, -131.968750} 
    ArrestPosition[4] = {-1892.039063, 180.676239, -131.968750}
    RandomPos = table.Random(ArrestPosition)
    
    self:SetPos(Vector(RandomPos[1],RandomPos[2],RandomPos[3]))
    Msg( table.Random(ArrestPosition) .. "
" )
end

this should work, im not totaly sure its untested.

got this

gamemodes\undergroundrp\gamemode\meta.lua:11: attempt to concatenate a table value
it is the Msg… :stuck_out_tongue: but the msg no matter, just for some debug stuff :slight_smile:

[editline]10:57AM[/editline]

Thank you!

[lua]

function meta:Arrest()
if not self:IsPlayer() then return end

local ArrestPosition = {}
ArrestPosition[1] = Vector(-2205.760254, 165.064667, -131.968750)
ArrestPosition[2] = Vector(-2094.647461, 157.306168, -131.968750)
ArrestPosition[3] = Vector(-2004.702393, 160.443497, -131.968750) 
ArrestPosition[4] = Vector(-1892.039063, 180.676239, -131.968750)

self:SetPos(table.Random(ArrestPosition))
Msg( table.Random(ArrestPosition) .. "

" )
end
[/lua]

Something wrong with using a table of vectors?

Works for me.
Also its better to use print() than msg(). Atleast i think so

i know this is a bit out of topic, but i don’t wanna create a new topic soo…

the Arrest Method returns nil

[lua]
function SWEP:PrimaryAttack()
if CurTime() < self.NextStrike then return end

self.Owner:SetAnimation(PLAYER_ATTACK1)
self.Weapon:EmitSound(self.Sound)
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)

self.NextStrike = CurTime() + .4

if CLIENT then return end

	local trace = self.Owner:GetEyeTrace()
	trace.Entity:Arrest()

end
[/lua]

[lua]
local ArrestPosition = {
Vector(-2205.760254, 165.064667, -131.968750),
Vector(-2094.647461, 157.306168, -131.968750),
Vector(-2004.702393, 160.443497, -131.968750),
Vector(-1892.039063, 180.676239, -131.968750)
}[/lua]
I still haven’t understood what’s the problem, it isn’t printing or what?
It shouldn’t return nil.
What’s “meta”, are you sure you specified that? If not then put this
local meta = FindMetaTable(“Player”)
In shared.lua