• LocalPlayer() = ply
    13 replies, posted
Do you still need to declare LocalPlayer() ? cuz it says ply is global something. hook.Add ("PostCleanupMap" , "GiveWeapon" , function (ply)  if  ply:Team() == breacher then ply:StripWeapons() ply:Give ("weapon_lordi_sledgehammer")  ply:Give ("cwc_icarus37") ply:Give ("cw_flash_grenade") end  if ply:Team() == hacker then  ply:StripWeapons() ply:Give ("cw_mp5") ply:Give ("weapon_hack_phone") ply:Give ("cw_flash_grenade") end  if ply:Team() == assault then  ply:StripWeapons() ply:Give ("cw_g3a3") ply:Give ("cw_smoke_grenade") ply:Give ( "cw_flash_grenade") end if ply:Team() == medic then  ply:StripWeapons() ply:Give ("cw_mp5") ply:Give ("med_kit_nn") ply:Give ("cw_flash_grenade") end end)
Why ure using this hook? This hook dont get a player variable defined ... anyway you should use for k,v in pairs(player.GetAll()) do things... otherwise it wont work.. or just w8 for better devs in this forum to answer.. but i think the hook dont support a ply variable by default and its a serverside hook... or is it shared idk
Oh i see thanks for the reply
and if u want to check if the player whos starting the cleanup just use netmessages
it runs automatically after few seconds
Before you continue with anything else, LocalPlayer() = ply is backwards. You'd want to do ply = LocalPlayer() instead, but again, don't even do that in this hook.
Since this is a shared hook, it depends on where you are calling it from, regardless ply is not defined in your code. What is the file containing this code called?
It's from init.lua
anyone correct me if I'm wrong but would ply inside the custom function brackets work?
Since it is being used serverside, no player objects are being passed to the function. Add this around your current code. for k, v in pairs(player.GetAll()) do --code here end Instead of ply: use v: Or keep your code the same and define local ply = v
No, because the PostCleanupMap function does not support players as an argument. In fact, the function has no arguments at all. @Unknown Strafes solution is one of the few ways to be able call players from within that function.
ohhhh that's how that works. Thanks
for k, v in pairs(player.GetAll()) do local ply = v end Why define anything, why won't you let the loop do it for you? Unnecessary pointers and memory waste, it might be a micro-Optimization, but if you're going to use a pairs loop for it, do it the correct way. That's a bad practice. Why instead not do; for _, ply in pairs( player.GetAll() ) do --Do stuff end
You're right Rako, that's the best way to do it.
Sorry, you need to Log In to post a reply to this thread.