What to do with the nill in a table?

Recommended Posts

• Moderators

Hello guys,

I have a very large table, but the problem is that 70% is "0"

WeaponRecoil = {=0,=0,=0,=0,=0,=0..................ETC

How can I make sure the table will be small.

The numbers that will be something in the table is 0 t/m 47. (btw in some of my tables does have a "0", for sample you have explosion = 0 or unarmed = 0)

A guy told me once, that I have to use "var" (remi-x)

What is the best way to make a good table?

I don't understand you.

You want to make the table small?

just something looks like this instead of 1=0, 2=0, 3=1, 4=0 etc.:

0 to 10 = 0

10 to 20 = 1

11 to 15 = 0

etc. etc.

I hope that you will understand me to ;p

• MTA Team

Perhaps don't make a table for all weapons if you don't want to change them from zero to anything. Only make a table for the weapons you want to change.

You can use 'nil', unless I'm wrong

• Moderators

How do you set a table like that?

denny199

0 to 10 = 0

10 to 20 = 1

11 to 15 = 0

etc. etc.

I get errors if I call a weapon/number, that does not exist in the table it self.

Sample: I ask for 3, but the table is: omfg = {1=,2=} -- 3 isn't inside.

myonlake

Perhaps don't make a table for all weapons if you don't want to change them from zero to anything. Only make a table for the weapons you want to change.

How can I check with nil if the number isn't inside?

Renkon

You can use 'nil', unless I'm wrong

if (table) == nil then

IIYAMA said:
How do you set a table like that?

denny199

0 to 10 = 0

10 to 20 = 1

11 to 15 = 0

etc. etc.

I get errors if I call a weapon/number, that does not exist in the table it self.

Sample: I ask for 3, but the table is: omfg = {1=,2=} -- 3 isn't inside.

myonlake

Perhaps don't make a table for all weapons if you don't want to change them from zero to anything. Only make a table for the weapons you want to change.

How can I check with nil if the number isn't inside?

Renkon

You can use 'nil', unless I'm wrong

It's {  = 1,  = 2 } not { 1 = , 2 =  }.

• Moderators

ops sorry , just a sample :3

Create an account

Register a new account