Forum

> > CS2D > Scripts > Class script for both teams.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Class script for both teams.

7 replies
To the start Previous 1 Next To the start

old Class script for both teams.

parhana
User Off Offline

Quote
Hi us
i'm currently still really new to learning lua and i have been messing around with the sample class script and trying to get a working script that allows both teams to have separate classes. The problem is i can't get the script to work at all. If anyone can maybe help at all it would be appreciated. Current code is written bellow.
edited 1×, last 25.02.17 06:30:43 pm

old Re: Class script for both teams.

parhana
User Off Offline

Quote
Hi masea thanks for the reply. Do you mind if you could help me with what menu names you mean exactly i'm a little confused

Also do you mean adding it like this?

1
2
3
4
5
6
7
-- SNIPER
     if (sample.classes.class[id]==5) then
          parse ("setmaxhealth "..id.." 75")
          parse ("setarmor "..id.." 25")
          return "35,3,53";
    end
    end

old Re: Class script for both teams.

GeoB99
Moderator Off Offline

Quote
The 72 line is incorrectly tabbed and the
end
block you've added in the 7 line in the second post is also incorrect because the
if
statement in the 2 line has already the
end
block.
Click me! >

Since you claim that you're novice at Lua, a proper indent style is highly recommended, you can't ignore this. Here's a tutorial wiki which provides a detailed information on how to, Lua Style Guide.

As for the menu names, what user Masea tries to mean is you're attempting to check if the menu titles in 55 and 59 line are Select your Class - CT or Select your Class - T while the menu templates (17 and 21 line) have different menu titles. That's the problem.
1
2
3
4
5
6
7
function sample.classes.classmenu.ct(id)
     menu(id,"Select your Class,Grenadier, Officer, Assault, Machine Gunner, Sniper ")     
end

function sample.classes.classmenu.t(id)
     menu(id,"Select your Class,Rifleman, Officer, Assault, Machine Gunner, Sniper ")     
end
They should be...
1
2
3
4
5
6
7
function sample.classes.classmenu.ct(id)
     menu(id,"Select your Class - CT,Grenadier, Officer, Assault, Machine Gunner, Sniper ")     
end

function sample.classes.classmenu.t(id)
     menu(id,"Select your Class - T,Rifleman, Officer, Assault, Machine Gunner, Sniper ")     
end

old Re: Class script for both teams.

parhana
User Off Offline

Quote
Hi Fraizeraust thanks so much for taking the time to help and explaining stuff, really helps a tone with learning. I have a bit of a problem now though. I managed to correct some nil value errors and got the script working but it now only works for one team and one team only.

To give an example if i pick the Terrorist team the menu for classes shows but if i pick the counter terrorist team the menu for classes does not. I'll link the current updated code i made bellow.
Spoiler >

old Re: Class script for both teams.

GeoB99
Moderator Off Offline

Quote
In the 32 line:
1
if (team>2) then
You're comparing the
team
variable parameter if it's greater than 2. Within team check conditions you use the
==
relational operator for equality test, just like you did in the 34 line.
1
if ( team == 2 ) then
This is how it should be. Hopefully I was understood.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview