• My code doesn"t work help me x)
    9 replies, posted
Hello, my code doen"t work : [CODE]hook.Add( "PlayerInitialSpawn", "moderator", function() if ply:IsUserGroup("operatorpoufsouffle") or ply:IsUserGroup("operatorserdaigle") or ply:IsUserGroup("operatorgryffondor") or ply:IsUserGroup("operatorserpentard") then ply:Give("weapon_physgun"); end end)[/CODE] It creates a lua error and I do not understand why ? Help me ! error : [ERROR] lua/autorun/server/moderator.lua:4: attempt to index global 'ply' (a nil value) 1. fn - lua/autorun/server/moderator.lua:4 2. unknown - addons/ulib/lua/ulib/shared/hook.lua:179
[QUOTE=Douille2113;48573840]Hello, my code doen"t work : [CODE]hook.Add( "PlayerInitialSpawn", "moderator", function() if ply:IsUserGroup("operatorpoufsouffle") or ply:IsUserGroup("operatorserdaigle") or ply:IsUserGroup("operatorgryffondor") or ply:IsUserGroup("operatorserpentard") then ply:Give("weapon_physgun"); end end)[/CODE][/QUOTE] On the first line, you need [B]function( ply )[/B], not just function().
[CODE]hook.Add( "PlayerInitialSpawn", "moderator", function(ply)[/CODE]
You can also simplify it a bit: [code] local lookup = { operatorpoufsouffle = true, operatorserdaigle = true, operatorgryffondor = true, operatorserpentard = true } hook.Add( "PlayerInitialSpawn", "moderator", function( ply ) if ( lookup[ ply:GetUserGroup() ] ) then ply:Give("weapon_physgun"); end end)[/code] My automerge :(
It's doesn"t work. Help me pleas
Need more information to be able to help you.
I would give physic to moderator gun from my server without using the trick of setting the darkrp . Thank you
Works for me... are you getting any errors? How are you running this on a server? Do you know the addon is executing? Put print("Addon has loaded") at the top and see if it comes out in console. [CODE] local lookup = { superadmin = true } hook.Add( "PlayerInitialSpawn", "moderator", function( ply ) if ( lookup[ ply:GetUserGroup() ] ) then ply:Give("weapon_crossbow"); end end) [/CODE] [CODE] Semajnad has spawned. ServerLog: Semajnad (STEAM_0:1:22686651) Spawned ServerLog: Semajnad (STEAM_0:1:22686651) Attempted to pick up a weapon_crossbow [/CODE]
i test.
also why initial spawn? when they die, they will spawn with default weapons.
Sorry, you need to Log In to post a reply to this thread.