Need help with player (in-server) id

I used to program in AMXX, and there the player was “named” by numbers (0 - 31), I tried to use LocalPlayer, and I saw that return [Name][Number (1 for the first player, 2 for the second)][SteamID], I want to know how can I get the ID number from the function LocalPlayer

LocalPlayer():EntIndex()

I’m trying this code:


function retiraGrana()
	if checkSmg:GetChecked() then
		if(creditos[plar] - 10 >= 0) then
			player.GetByID(plar):Give("gmod_tool")
		end
	end
end

But It’s giving me:
[ERROR] STEAM_0:0:24333439/luapad/menu.txt:51: attempt to call method ‘Give’ (a nil value)

You mean you want to get the player by steamID?

[lua]
local function player_GetBySteamID(id)
for _, v in pairs(player.GetAll()) do
if v:SteamID() == id then return v end
end
end

function retiraGrana()
if checkSmg:GetChecked() then
if(creditos[plar] - 10 >= 0) then
player_GetBySteamID(plar):Give(“gmod_tool”)
end
end
end[/lua]

Make sure you’re not calling the Give() method in a shared or client file.

I’m calling in a simple lua that i’m running directly in gmod

My entire code



creditos = {}

for i = 1 , 32	do
	creditos* = 100
end

plar = LocalPlayer():EntIndex()

local Armas = vgui.Create("DFrame")
Armas:SetPos(100, 100)
Armas:SetSize(500, 400)
Armas:SetTitle("Menu de armas")
Armas:SetVisible(true)
Armas:SetDraggable(true)
Armas:ShowCloseButton(true)
Armas:MakePopup()

checkSmg = vgui.Create("DCheckBoxLabel", Armas)

checkSmg:SetText("SMG [10 Créditos]")
checkSmg:SetPos(10, 40)
checkSmg:SizeToContents()
checkSmg:SetValue(0)

local checkAr2 = vgui.Create("DCheckBoxLabel", Armas)
	
checkAr2:SetText("AR2 [10 Créditos]")
checkAr2:SetPos(10, 70)
checkAr2:SizeToContents()
checkAr2:SetValue(0)
	
local lblCredits = vgui.Create("DLabel", Armas)

lblCredits:SetText("Créditos atuais: " .. creditos[plar])
lblCredits:SetPos(10, 370)
lblCredits:SizeToContents()
	
local btConfirmar = vgui.Create("DButton", Armas)

 btConfirmar:SetText("OK")
 btConfirmar:SetPos(380, 360)
 btConfirmar:SetSize(100, 26)
 btConfirmar.DoClick = function()
 	retiraGrana()	
	lblCredits:SetText("Créditos atuais: " .. creditos[plar])
end	

function retiraGrana()
	local recebe = player.GetByID(plar)
	if checkSmg:GetChecked() then
		if(creditos[plar] - 10 >= 0) then
                         recebe:Give("weapon_smg1")
		end
	end
end	


You can’t use the Give method clientside. You’ll have to do some networking.

How Can I do that?

Using the net library.

Can You send me a tutorial site that explains the using of other gmod libraries?