So I’ve been trying to change and make the code apply to each player separately, but I cant find a way to do it.
Here is the code, It’s located in “init.lua”.
AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") resource.AddFile("sound/allahu2.wav") local ply=FindMetaTable("Player") local expt=0 function GM:KeyPress(ply,key) if key==IN_USE and ply:Alive() then if expt==0 then expt=1 local exp=ents.Create("env_explosion") exp:Spawn() exp:SetKeyValue("iMagnitude",200) sound.Play("allahu2.wav",ply:GetPos(),70,100,1) timer.Simple(1,function() if ply:Alive() then exp:SetPos(ply:GetPos()) exp:Fire("Explode",0,0) expt=0 else expt=0 end end) else sound.Play("weapons/slam/buttonclick.wav",Vector(ply:GetPos())) -- Sends players to this part of the code If someone is already using the function. end end end
So here is the problem, If one player presses the use button (Default E) and starts the function on himself, then others would not be able to enable the function and execute it on themselves. What It would do is just send them to this part of the code,
... .. . else sound.Play("weapons/slam/buttonclick.wav",Vector(ply:GetPos())) end . .. ...
I don’t know what I’m doing wrong, maybe I need to setup a database for each player or something?