[EVOLVE][SANDBOX] How to give Ranked Players Weapons when Spawning

Hello, I’m not very educated in the field of lua scripting, only besides its use and specific variable inputs. Here’s my problem:

I’m attempting to create a lua script to give different ranked players different assortments of weapons when they spawn. The Server I manage uses the admin mod EVolve, and the weapons i’m trying to set are m9k.

Here’s the idea:
Rank (gets) weapons
Client (=) colt1911, tec9, m3

The weapon names are:

m9k_colt1911
m9k_tec9
m9k_m3

From what I know with EVolve, when using “usergroups”, it’s EV_GetRank.
http://evolvemod.googlecode.com/svn-history/r149/trunk/beta/lua/ev_framework.lua

How would one go about setting up a simple script that would give a client joining the server the above weapons?

Any constructive input would be greatly appreciated, I’ve looked all over for a script that would barely resemble this function, yet I have not come across one, I bet i’m not the only one who wishes to have access to such a script…

You serious?

I made you a script already and it works.


//lua/autorun/server
local SBOX_WB = {
	["servermanager"] = {"m9k_colt1911"},
	["specialguest"] = {"weapon_zm_revolver", "weapon_ttt_m16"}
}

hook.Add("PlayerSpawn", "SBOX_WB.PlayerSpawn", function(ply)
	local benefits = ply:GetNWString("usergroup")
	if (ply.EV_GetRank) then 
		benefits = ply:EV_GetRank()
	end
	print(benefits)
	benefits = SBOX_WB[benefits]
	PrintTable(benefits)
	if !benefits then return end
	for k,v in ipairs(benefits) do
		ply:Give(v)
	end
end)

This one works? I’m running the code now.

If you don’t know how to check the console to see what prints, I can’t help you any further.

Switch lines 14 and 15 with eachother.

[ERROR] lua/includes/util.lua:54: bad arguement #1 to ‘pairs’ <table expected, got nil>

  1. pairs - [c]:-2
  2. PrintTable - lua/includes/util.lua:54
  3. v - lua/autorun/server/weapons.lua:13
  4. unknown - lua/includes/modules/hook.lua:82

What does it print before that? It should print “nil” or “servermanager”.

rewent over the error, and that’s what I got again. There is nothing before that. It’s just <table expected, got nil>

heheh.

can you take a screenshot of your console.

I did, how do I upload? It asks for a URL to post image

oh my…

Imgur

Here is the exact script (correct me if i’m wrong) that I was provided, that gives the error

and Here is the Error Code (Bottom in Blue)

I am the Server Manager, Chris. When I join, this is the error that shows, and I spawn striped, with no player model, and ranks are completely non-existent. Very very weird, any ideas on why this is?

Welp, here you are!

Just remove the PrintTable line and it will work fine. The error is only caused because it’s printing a nil table.

Make sure you set the table ranks accordingly, yours’ is destroyer, which is not in the table so you will get nothing.

I’m not so sure what the print table line is in this:


//lua/autorun/server
local SBOX_WB = {
	["servermanager"] = {"m9k_colt1911"},
	["specialguest"] = {"weapon_zm_revolver", "weapon_ttt_m16"}
}

hook.Add("PlayerSpawn", "SBOX_WB.PlayerSpawn", function(ply)
	local benefits = ply:GetNWString("usergroup")
	if (ply.EV_GetRank) then 
		benefits = ply:EV_GetRank()
	end
	print(benefits)
	benefits = SBOX_WB[benefits]
	PrintTable(benefits)
	if !benefits then return end
	for k,v in ipairs(benefits) do
		ply:Give(v)
	end
end)

This is what he’s talking about… PrintTable(benefits)


//lua/autorun/server
local SBOX_WB = {
	["servermanager"] = {"m9k_colt1911"},
	["specialguest"] = {"weapon_zm_revolver", "weapon_ttt_m16"}
}

hook.Add("PlayerSpawn", "SBOX_WB.PlayerSpawn", function(ply)
	local benefits = ply:GetNWString("usergroup")
	if (ply.EV_GetRank) then 
		benefits = ply:EV_GetRank()
	end
	print(benefits)
	benefits = SBOX_WB[benefits]
	if !benefits then return end
	for k,v in ipairs(benefits) do
		ply:Give(v)
	end
end)

Testing this code now.

[editline]8th October 2013[/editline]

Not getting errors, that’s a good sign, though as a Server Manager, upon joining the server, no colt 1911, nor does console mention the script