Forum

> > CS2D > Scripts > How do i change the character with custom one?
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch How do i change the character with custom one?

19 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Re: How do i change the character with custom one?

Mami Tomoe
User Off Offline

Zitieren
There are many approaches to doing this, each with their own downside.

You can use mods to hide the player sprites so everyone is invisible, and then use cs2d lua cmd image on a spreadsheet mode to display a custom skin, but that won't overlay very well because you can't place an image above the feet but below the held weapons.
This would also be affected by lag, as you'd need to change the sprite using the cs2d lua hook switch hook, which is ping dependent and won't look good visually.

Instead, a better approach would be to use mods to simply change the skin, though then you're still limited to 4 characters per team.
Also, you can't set a skin through Lua, not yet at least, so it would be fairly messy to force a skin, if you wish.

This is assuming that your definition of a character is the skin, if not, do elaborate on what it is.

alt Re: How do i change the character with custom one?

Komo the Cat
User Off Offline

Zitieren
Zitat
Instead, a better approach would be to use mods to simply change the skin, though then you're still limited to 4 characters per team.
I think this one is a good idea, but the problem is that the texture only affects on clientside, not server one. Is there any ways to make the mod downloaded on the other players' device?

alt Re: How do i change the character with custom one?

Masea
Super User Off Offline

Zitieren
user Komo the Cat hat geschrieben
Zitat
Instead, a better approach would be to use mods to simply change the skin, though then you're still limited to 4 characters per team.
I think this one is a good idea, but the problem is that the texture only affects on clientside, not server one. Is there any ways to make the mod downloaded on the other players' device?
Note that you can't force a player to use a specific skin, so this is relatively useless if you plan to change a player's character skin via code. Custom skins you do via the mods folder are just there for the sake of appearance if anyone cares.

One of the mods that come to my mind with custom skins is a classes mod where every class will possess different characteristics and a custom sprite. You can't do this with that.

alt Re: How do i change the character with custom one?

Mami Tomoe
User Off Offline

Zitieren
@user Masea, you can force a skin but it's very...

You'd have to use cs2d cmd maket/cs2d cmd makect depending on the player's team to set the team until the randomiser sets the skin on the skin that you want.

An example code:
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
local setTeam = { [0] = 'makespec', [1] = 'maket', [2] = 'makect' }

setTeam[3] = setTeam[2] -- V.I.P. support.


function setSkin(p, skin)
	if skin < 0 or skin > 3 then
		-- No such skin id.

		return
	end

	local team = player(p, 'team')

	if team == 0 then
		-- Player is a spectator

		return
	end

	-- Optimise this as much as possible
	local exec	= parse
	local get	= player
	local cmd	= setTeam[team]

	while get(p, 'look') ~= skin do
		-- Keep setting the team
		-- for as long as the randomiser
		-- didn't choose the skin that we want.
		exec(cmd .. ' ' .. p)
	end
end
1× editiert, zuletzt 29.01.22 23:44:43

alt Re: How do i change the character with custom one?

Cebra
User Off Offline

Zitieren
I don't think there will be a force download, if only because of security reasons.
A more practical solution maybe would be if the server can check which mods are available and can set one of them.
If sb joins who has not the right mod you can kick him

alt Re: How do i change the character with custom one?

Gaios
Reviewer Off Offline

Zitieren
user Mami Tomoe hat geschrieben
@user Gaios: Read the documentation.
Executed every time a player switches their held item.
In this context used to change the player sprite accordingly.

Zitat
The Lua hook "switch" has not been found. It either does not exist or it is not documented here.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht