Forum

> > CS2D > Scripts > Own[id]['itemid'] for images / owned stuff
Forums overviewCS2D overview Scripts overviewLog in to reply

English Own[id]['itemid'] for images / owned stuff

4 replies
To the start Previous 1 Next To the start

old Own[id]['itemid'] for images / owned stuff

Alistaire
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Img = {}
Own = {}

addhook('startround','Items_startround_hook')
function Items_startround_hook()
	for j = 1,32 do
		Img[j] = 0
		for k = 1,100 do
			Own[j]['k'] = 0
		end
	end
end

function I_c_eD_clth(id)
	menu(id, 'eDock Clothes,Poncho|$100,Shirt|$20,Jacket|$70,Vest|$65,Anorak|$80,,,,,Close')
end

addhook('menu','Items_computer_hook')
function Items_computer_hook(id, menu, sel)
	if (menu == 'eDock Clothes') then
		if sel == 1 then
			if player(id, 'money') >= 100 then
				parse('setmoney '..id..' '..player(id, 'money')-100)
				Own[id]['1'] = 1
			else
				msg2(id, '©255000000-Not enough money-')
			end
		end
	end
end

addhook('say','Clothes')
function Clothes(id, txt)
	if txt == '!wear' then
		freeimage(Img[id])
		if Own[id]['1'] == 1 then
			Img[id] = image(stpth..'eDock/Poncho.png',1,0,200+id)
		elseif Own[id]['2'] == 1 then
			Img[id] = image(stpth..'eDock/Shirt.png',1,0,200+id)
		end
		return 1
	end
end

I want the Own[id]['itemid'] to be different for every player. At the moment the items are the same for everybody but the images differ.

How do I make the Own table have 2 of those fancy brackets; 1 for the player(id) and 1 for the 'itemid'?
edited 3×, last 23.01.12 01:24:44 pm

old Re: Own[id]['itemid'] for images / owned stuff

TimeQuesT
User Off Offline

Quote
You have to define an array in the already existing array...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
--copied from resources

function aNewArray(iSize,bIsMulti,iMultiSize)
dummyArray = {};
for i=0,iSize do
if (bIsMulti) then
dummyArray[i] = {};
for i2=0,iMultiSize do
dummyArray[i][i2] = 0;
end
else
dummyArray[i] = 0; -- overwrites the default value NULL
end
end

return dummyArray;
end


------------------------------
Own =  aNewArray(32,true,100);

old Re: Own[id]['itemid'] for images / owned stuff

EngiN33R
Moderator Off Offline

Quote
@user Alistaire: Well, from what I can see in your original script, you already did it right. It will be different for each player. Although, I recommend to have the second table index (own ID or item ID) a number and not a string - it'll be more convenient that way.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview