help needed

Im trying to make the classes unlock able in accordance to the players rank on onslaught.
so far i have:
[lua]if Classes[3] then
if ply:GetRank() < 3 then
ply:ChatPrint(“You must be a corporal or above to use this class!”)
return
end[/lua]

I believe its the ‘if Classes[3] then’ part. Im trying to get the class number from the Classes table but im not quite sure how. Any help is appreciated and sorry for being such a noob :3


(User was banned for this post ("Wrong section" - mahalis))

To get any help, you’re probably going to have to post the structure of the Classes table and what the ‘class number’ is.

okay

here is the class table

[lua]Classes = {}
Classes[1] = {NAME = “Scout”, SPEED = 650, JUMP = 260, WEAPON_SET = 1, HEALTH = 100, AMMO = {2,11}, MODEL = “models/player/Group03/Female_02.mdl”, DSCR = “A fast and agile class the scout is perfect for those who like to be in the action.”}
Classes[2] = {NAME = “Soldier”, SPEED = 250, JUMP = 200, ARMOR = 50, WEAPON_SET = 2, HEALTH = 200,AMMO = {1,2,8,6}, MODEL = “models/player/Group03/male_08.mdl”, DSCR = “A perfect for those defensive players featuring a wide range of weapons the soldier is a perfect well balanced class.” }
Classes[3] = {NAME = “Engineer”, SPEED = 300, JUMP = 160, WEAPON_SET = 3, HEALTH = 120, AMMO = {2,4}, MODEL = “models/player/Group03/male_03.mdl”, DSCR = “With the ability to make turrets and dispensers the engineer is truly an invaluable class.” }
Classes[4] = {NAME = “Sniper”, SPEED = 270, JUMP = 160, WEAPON_SET = 4, HEALTH = 80,AMMO = {7,5}, MODEL = “models/player/Group03/male_06.mdl”, DSCR = “The Sniper is the useful for taking out incoming enemies but its lack of health and speed requires you to keep cover!”}
Classes[5] = {NAME = “Pyro”, SPEED = 450, JUMP = 210, WEAPON_SET = 5, HEALTH = 150, AMMO = {2,10,12,8}, MODEL = “models/player/Group03/male_07.mdl”, DSCR = “The pyro has the ability to set enemies alight and place mines to send those enemies fliying!” }
Classes[6] = {NAME = “Medic”, SPEED = 500, JUMP = 210, WEAPON_SET = 6, HEALTH = 100, AMMO = {13}, MODEL = “models/player/Group03/Female_04.mdl”, DSCR = “Acting as the team medic, the support helps keep the team alive and the base standing.” }
Classes[7] = {NAME = “Berserker”, SPEED = 250, JUMP = 200, WEAPON_SET = 7, HEALTH = 400, AMMO = {8}, MODEL = “models/player/Group03/male_03.mdl”, DSCR = “The Berserker has a very high amount of health and hits… HARD!” }[/lua]

And what are you trying to do exactly? What is ‘get the class number’ mean, if you already have Classes[3]?

[lua]
if Classes[3] and ply:GetRank() <= 3 then
ply:ChatPrint(“You must be a corporal or above to use this class!”)
return
end
[/lua]

or if you still wanted to do it your way, you forget one END on the end :slight_smile:

im trying to do in words.
If classes [3] is selected and your rank is below 3 then you cant use that class but i couldnt do the if classes [3] is selected.

How is classes[3] selected

I tried it antid2 but i could still change class. I could change to any class and it said “You must be a corporal or above to use this class!” for every class. here is all of my class function if it helps
[lua]function Class(ply,com,args)
local newclass = tonumber(args[1])
if !Classes[newclass] then return end
ply:SetNetworkedInt(“class”, newclass )
for k,v in pairs( ents.GetAll( ) ) do
if v:IsNPC() || v:GetClass() == “ose_mines” then
v:CheckValidOwnership()
end
end
if PHASE == “BATTLE” && ply:Alive() then
ply.NextSpawn = CurTime() + SPAWN_TIME + (#player.GetAll() * ADD_SPAWN_TIME)
ply:Kill()
else
ply:ChatPrint(“You will spawn as “…Classes[newclass].NAME…” in the battle phase”)
end
if Classes[3] and ply:GetRank() <= 3 then
ply:ChatPrint(“You must be a corporal or above to use this class!”)
return
end
end
[/lua]

[editline]06:07PM[/editline]

by either the command join_class 3 or on the qmenu and clicking on the class

You should use newclass == 3 instead of Classes[3]

thanks esalaka. It works now except the class is still changes. I need to code it now so it doesnt change class or changes to another if it is selected.

Put the if newclass == 3… thing right below if !Classes[newclass] then return end. You’re checking if they can do it after you’ve already done it.

facepalm Of course. Thanks for all your help guys.