Forum

> > CS2D > Scripts > command thats adding image to someones screen
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch command thats adding image to someones screen

11 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt command thats adding image to someones screen

Mami Tomoe
User Off Offline

Zitieren
i want a script that will show someone a image on his screen (only for him) until he clicks it and it will be activated when i say
@fake <id>
the image is in gfx/fake.png
thanks to anyone who will help
(i also want it to play a sound on sfx/fake.wav)

alt Re: command thats adding image to someones screen

The Gajos
BANNED Off Offline

Zitieren
I don't get your request. Here you start with this code (this isn't all you want, because your English is fu*ked up):
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
fakePatch = 'gfx/fake.png'

function toTable(txt,match)
	local cmd = {}
	if not match then match = '[^%s]+' end
	for word in string.gmatch(txt,match) do
		table.insert(cmd,word)
	end
	return cmd
end

function server(id,txt)
	msg2(id,'©000255000[SERVER]: ©255255255'..txt..'.')
end

function _say(id,txt)
	local p = toTable(txt)
	local cmd = string.lower(p[1]):sub(2)
	if (txt:sub(1,1) == '@' or txt:sub(1,1) == '!') and txt ~= 'rank' then
		if cmd == 'fake' then
			local pl = p[2]
			if pl then
				if player(pl,'exists') then
					-- I fuck your English
					server(id,'What the fuck are you talking about?!')
					server(pl,'What the fuck are you talking about?!')
				else
					server('Player with id '..pl..' does not exsit')
				end
			end
		else
			server('Unknown command: '..cmd)
		end
		return 1
	end
end
addhook('say','_say',-11)

alt Re: command thats adding image to someones screen

GeoB99
Moderator Off Offline

Zitieren
1. You must use cs2d lua cmd image for images. To show to a specific player ONLY then you might want to use the [pl] parameter and that must be the id of the player.
Ex:
1
image("path",x,y,mode,id)
For the mode just check the description of that command and read the modes (duh, I think the mode to show to the player's screen is 2 but I am wrong...)
2.You must use cs2d cmd sv_sound2 to play a sound to a specific player.

I only gave the little basic things. The rest is up to you by learning to script yourself .
1× editiert, zuletzt 22.07.15 11:04:53

alt Re: command thats adding image to someones screen

Dousea
User Off Offline

Zitieren
I'm just being nice here. Just test code below and see if it fulfills your need.
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
fakeplayer = {}

for id = 1, 32 do
	fakeplayer[id] = {
		image = 0,
		shown = false
	}
end

addhook("say", "sayhook")
addhook("attack", "attackhook")

function sayhook(id, message)
	if (message:sub(1, 5) == "@fake") then
		local toid = tonumber(message:sub(7, #message))
		
		if (type(toid) == "number") then
			fakeplayer[toid].image = image("gfx/fake.png", 320, 240, 2, toid)
			
			parse("sv_sound2 " .. toid .. " \"fake.wav\"")
			
			fakeplayer[toid].shown = true
		end
	end
end

function attackhook(id)
	if (fakeplayer[id].shown) then
		freeimage(fakeplayer[id].image)
		
		fakeplayer[id].image = 0
		fakeplayer[id].shown = false
	end
end

alt Re: command thats adding image to someones screen

Mami Tomoe
User Off Offline

Zitieren
@user Dousea: thanks! But will it work for other peoples? I dont want it to work for other peoples cause it can get abused...

For other peoples who want me to make it myself, I do not know how to script, I know how to edit a existing script but not how to create one myself.
1× editiert, zuletzt 23.07.15 13:59:20

alt Re: command thats adding image to someones screen

Rainoth
Moderator Off Offline

Zitieren
Making yourself is one step from editing. You'd never guess how I started scripting - I edited sample classes script and was totally amazed at what awesome things I did, even though they weren't. You could at least TRY to make a script. Trust me, it's not the easiest of tasks but the most rewarding.

For your problem, just put this line somewhere in say hook for the command. The closer it is to top of function definition, the less computation
1
if player(id,"usgn") == 123456 then

alt Re: command thats adding image to someones screen

Mami Tomoe
User Off Offline

Zitieren
@user Rainoth: I tried to place it in many places but all I get is errors saying the server expected END near IF
IMG:https://i.imgur.com/YmdTjr5.png


Yes I did created some nice stuff using the samples (like a script thats auto kick whoever ask for admin (or any other rank) and a script that will clear the chat etc...
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht