Script dosent working maybe conflict?

Hey,

Based on the http://wiki.garrysmod.com/page/GM/PlayerSay i created a teleport script:

local comodo_spawn_pos = Vector(-944.464111, -196.986008, -15775.968750)

function skybox( ply, text, public )
if (string.sub(text, 1, 6) == “/skybox”) then
player:SetPos(comodo_spawn_pos)
return “”
end
end
hook.Add( “PlayerSay”, “skybox”, skybox );

When i try to loading it on the server: lua_openscript autorun/teleport.lua
I get:

[ERROR] lua/includes/util.lua:184: attempt to index local ‘object’ (a number value)
1. IsValid - lua/includes/util.lua:184
2. sortHooks - addons/ulib/lua/ulib/shared/hook.lua:47
3. Add - addons/ulib/lua/ulib/shared/hook.lua:105
4. unknown - lua/autorun/teleport.lua:9

Any ideas? maybe conflict?

Thanks

On line 5, you are setting the position for “player” when it needs to be “ply” because that is what you specified at the beginning of the function:
[lua]
local comodo_spawn_pos = Vector(-944.464111, -196.986008, -15775.968750)

local function skybox( ply, text, public )
if (string.sub(text, 1, 6) == “/skybox”) then
ply:SetPos(comodo_spawn_pos)
return “”
end
end
hook.Add( “PlayerSay”, “skybox”, skybox );
[/lua]

You should also localize your functions unless you have a reason to not localize them.

Not a conflict, you just try to access variable “player” which doesn’t exist because your function passes “ply”, not “player”. ( Technically “player” exists as a library, but not the player that executed the command )

[editline]22nd February 2014[/editline]

Darn, I got ninjad 2nd time today.

Thanks but it says now: 4. unknown - lua/autorun/teleport.lua:9

Ahhmm wiki says its correct?

That doesn’t look like the full error, could you post the rest?

21:40:13 lua_openscript autorun/teleport.lua
21:40:13 Running script autorun/teleport.lua…
Loading Teleport script
TEST [lua/autorun/lordi_anti_propkill.lua][lua/autorun/teleport.lua]
TEST [lua/autorun/m9k_assault_rifles.lua][lua/autorun/teleport.lua]
TEST [lua/autorun/m9k_heavy_weaps.lua][lua/autorun/teleport.lua]
TEST [lua/autorun/m9k_small_arm_weapons.lua][lua/autorun/teleport.lua]
TEST [lua/autorun/m9k_specialties.lua][lua/autorun/teleport.lua]
TEST [lua/autorun/pdmg_client.lua][lua/autorun/teleport.lua]
TEST [lua/autorun/pdmg_convars.lua][lua/autorun/teleport.lua]
TEST [lua/autorun/pdmg_exclusions.lua][lua/autorun/teleport.lua]
TEST [lua/autorun/pdmg_server.lua][lua/autorun/teleport.lua]

     [ERROR] lua/includes/util.lua:184: attempt to index local 'object' (a number value)
       1. IsValid - lua/includes/util.lua:184
        2. sortHooks - addons/ulib/lua/ulib/shared/hook.lua:47
         3. Add - addons/ulib/lua/ulib/shared/hook.lua:105
          4. unknown - lua/autorun/teleport.lua:9

It looks like you ( or something else ) is trying to use IsValid on a number… Try uninstalling ULX, since it’s shit anyways.

Line 47:
if not isstring( name ) and not IsValid( name ) then <<<<<< THERE
Remove( event_name, name )
end

Line: 105 sortHooks( event_name )

So its removing my hook or what?