Forum

> > CS2D > Scripts > Image for all?-why happened?
Forums overviewCS2D overview Scripts overviewLog in to reply

English Image for all?-why happened?

2 replies
To the start Previous 1 Next To the start

old Image for all?-why happened?

Mora
User Off Offline

Quote
Hello all, i wanna ask for this:
When i use the button in the menu i have, this image do spawn for all players they joined in server, but!, the shake(when do i drink beer) only for player did used this button, here is a image with it happened:
IMG:https://i.pixs.ru/storage/6/0/3/Bezimyanni_9846161_12956603.jpg

as you see this s**t bugged, the script is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
cd = {}

here is just a part of menu:

 if button==1 then
beer(id)
 end

function beer(id)
   if not cd[id] then
		parse("shake "..id.." 100")
               cd[id]=true
               timer(5000,'bc', tostring(id))
id=image("gfx/beer.png",320,240,2)
               return 1
          else msg2(id,"©255000000You have drink beer, you can't do it more[after 10 sec only]")
          return 1
          end
end

function bc(id)
     cd[tonumber(id)]=nil
end
do someone have ideas why this happened?

old Re: Image for all?-why happened?

EngiN33R
Moderator Off Offline

Quote
Your image is visible to all players. If you want it to only be visible to the player of your choice, you need to provide the player ID as another argument to cs2d lua cmd image, making the function call this:
1
image("gfx/beer.png",320,240,2,id)

I also strongly advise not to use id as a variable to hold your image ID; it is highly unreliable.

old Solved!

Mora
User Off Offline

Quote
@user EngiN33R: that's why when player join in server and all get again image to all?
example:
i'm join first, my image is 0.5 hiden, someone coming, image hasn't hiden, more!-when someone join image making more no hiden...ee, i mean
that every new player join with new image for all.
Thank you so much Engi. gonna test

Edit: this is work! you help me a lot @user EngiN33R: .!
and [/close]
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview