Element tree: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Undo revision 49993 by Marcin778 (talk))
Line 1: Line 1:
[[File:Tre.png|frame|Element tree]]
MTA uses a so-called ''element tree'' to store all the elements that exist on the server and the client. This is directly related to the set of running [[resources]] and their map files' XML layout, although it can be changed at run-time by scripts.


= Strzeżcie się tych pseudo skrypterów, którzy tworzą swoje pseudo serwery! =
If you are familiar with the concept of ''trees'' in computer-science, this should be easy to understand. If you are not, think of it like a family tree - except everyone only has a single parent. Every [[element]] has a ''parent'' element.


== '''Emm - krul i władca wszystkich skrypterów''' ==
All elements that are created within scripts or from .map files are child elements of the resource they belong to. Thus, most elements (except for [[client]]s) exist only within resources and are also destroyed as soon as their resource is stopped.


== '''marcin778 - optymalizacja to podstawa''' ==
==Tree elements==
* '''root''': This is at the very base of the tree - all elements are children (or descendants) of this element.
<syntaxhighlight lang="lua">
getRootElement()
</syntaxhighlight>
* '''resource''': These are direct children of the root element - with one for each ''running'' resource. This element is called the ''resource root''. Its ID holds the name of the resource.
<syntaxhighlight lang="lua">
getResourceRootElement()
</syntaxhighlight>
* '''map''': Each resource element contains at least one map element, representing either a ".map" file in the resource or the one containing the elements created by scripts (this is called the ''dynamic'' map). Their IDs contain the maps' filenames, or ''dynamic'' for the dynamic map.
** Map files can contain a number of other [[element]]s as well as an unlimited number of custom elements.


Witam, od około miesiąca pracuje wraz z jedną osobą nad projektem RPG, który będzie nosił nazwę creativeGame. Mamy duże inspiracje oraz wiele ciekawych pomysłów, zadbaliśmy o to aby były to nie powtarzalne pomysły, czyli gdzie indziej takich rzeczy nie znajdziecie. Cały czas pracujemy nad serwerem. Modelarz ukończył już jeden z kilku wozów dla PSP. Dla policji(SAPD) są już pierwsze skrypty tj. wyposażenie dość rozbudowane, i trwają prace nad bazą danych SAPD. Gotowe także są już sygnały dźwiękowe oraz barierki/pachołki z oświetleniem zarówno jak i bez. Dzięki sporej kreatywności i wyobraźni sądzimy, że uda nam się wybić na scenie MTA. Nie uważamy się za najlepszych, jednakże dzięki pomysłom możemy osiągnąć sukcesy. W zanadrzu i przygotowaniu mamy już bardzo wiele unikalnych rzeczy, wiele nowych prac dorywczych i aspektów zmieniających rozgrywkę, powodując, że nie będzie ona polegała na znanym schemacie z innych serwerów czyli
==Example==
-Zarabiaj
This in an example of a serverside tree dumped to XML from a running server.
-Kup auto
''Please note that it is shortened on some places for the sake of overview.''
-Kup Dom
<syntaxhighlight lang="xml">
-Dostań się do frakcji
<root>
Przez ów plan gry wiele serwerów zostaje po prostu zamkniętych z powodu małej ilości graczy. Dlatego wprowadzimy wiele nowych atrakcji i niespodzianek, których gdzie indziej nie znajdziecie. Poprzez 'nowe' prace dorywcze mam na myśli takie, których jeszcze nie widzieliście. Większość z nich nie polega tylko na jeżdżeniu po checkpointach. Mamy również wiele niespodzianek odnośnie pojazdów. Między innymi:
<console/>
-Pasek rozrządu się zrywa
<player dontRespawn="false"/>
-Przestają działać przewody zapłonowe
<player dontRespawn="false" lastSpawnarea=""/>
-Przepalają się żarówki od reflektorów
<resource id="resourcebrowser"/>
I wiele więcej takich smaczków.
<resource id="ajax"/>
Planowaliśmy również dodać dźwięki silnika dla pojazdów, aczkolwiek zrezygnowaliśmy ponieważ przy dużej ilości pojazdów w jednym miejscu z włączonym silnikiem nastąpiły by ogromne spadki FPS oraz zlewające się dźwięki były by nie do zniesienia. Niestety ten element odpada. Nie martwcie się i tak was zaskoczymy.
<resource id="resourcemanager"/>
<resource id="spawnmanager"/>
<resource id="mapmanager"/>
<resource id="runcode"/>
<resource id="fr">
<map id="dynamic">
<vehicle/>
</map>
</resource>
<resource id="elementbrowser"/>
<resource id="assault">
<map id="dynamic">
<team/>
<team/>
<blip/>
<marker/>
<colshape/>
<blip/>
<blip/>
</map>
</resource>
<resource id="as-farm">
<map id="dynamic"/>
<map id="as-farm.map">
<spawngroup req="" type="attacker">
<spawnarea posY="-8.3976354598999" posX="20.182683944702" skins="9" ... />
</spawngroup>
<spawngroup req="" type="attacker">
<spawnarea posY="32.166355133057" posX="-46.90763092041" skins="9" ... />
</spawngroup>
<spawngroup req="" type="attacker">
<spawnarea posY="35.214984893799" posX="-33.486911773682" skins="9" ... />
</spawngroup>
<spawngroup req="" type="attacker">
<spawnarea posY="35.214984893799" posX="-33.486911773682" skins="9" ... />
</spawngroup>
<objective id="first" type="checkpoint" description="Breach into the farm" ... />
<pickup type="weapon" ... />
</map>
</resource>
</root>
</syntaxhighlight>
===Explanation===
This tree consists of a number of resource root elements, the [[Element/Console|server console]] and two [[player]] elements, that are direct children of the '''root''' element. All these resources have a ''dynamic map'' as child element (it is just not shown for most of them). These contain the elements that are created dynamically by this resource using scripts, for example a [[vehicle]]. If the resource has a map file, it is also a child element, itself containing all the elements in the .map file.


Nie chcę tutaj przedstawiać zbyt wiele by nasze pomysły nie zostały skradzione.  
Let's have a closer look at the '''assault''' resource: This contains just one ''dynamic'' map that has 2 teams, 3 blips, 1 marker and 1 colshape as child elements. These are the elements that are created by the script, for example the marker, the colshape and one of the blips are probably used for the objective.


Na chwilę obecną stan prac określa się na ok 25%
The '''as-farm''' resource's function on the contrary is to be a map for the '''assault''' gamemode. The dynamic map is empty (it could contain elements if there was a script in it though), while there is a map called 'as-farm.map', that contains a number of elements. These are mostly custom elements (like spawngroup, spawnarea, objective) but also a few elements that MTA creates automactically after loading the map (like pickup). In the brackets after the element type, you can see the element data it contains. These are identical with the attributes the .map file contains within these elements, while you can also set and get element data for any other elements (e.g. players) with [[setElementData]] and [[getElementData]].


Planowana data startu serwera jest szacowana na lipiec 2017, oczywiście data ta na pewno ulegnie zmianie, aczkolwiek muszę tutaj ją uwzględnić.
==Pratical application==
Elements can have as many children as they like. This does not directly affect the map in any way, but it comes in to its own when combined with the scripting system.


Screenów nie daję z obawy przed kradzieżą pomysłów oraz z powodu iż jak na razie nie ma zbyt wiele do pokazania. Wszystko jeszcze powstaje.
===Setting data for elements===
If you call a set... function on a node of the element tree, the function will affect every element within it (that it can work on).


== '''luki123luki123 - zwyciężca konkursu na najgorszego programiste GTAO''' ==
So, the following code would set the size of every marker (the only type of element the setMarkerSize function can work on) that is below the root element to ''2.5''.
Witam ciebie drogi użytkowniku forum.  
<syntaxhighlight lang="lua">
Chciałbym ciebie prosić o pomoc o tym jak według ciebie zrobić serwer.
setMarkerSize ( getRootElement(), 2.5 )
Możesz opisać jedynie jeden aspekt ( np. Policje, Mechanika etc. ) aby pomóc mi nad stworzeniem serwera który będzie według was przyjemny do grania.
</syntaxhighlight>
Nie chce stworzyć kolejnego serwera "pseudola" których jest pełno na polskiej scenie MTA:SA ale coś co będzie nowym innowacyjny projektem na scenie MTA:SA. Ale nie zapominajmy że to ma być serwer RPG więc pomysłu podsyłacie na to jaki ma być serwer RPG a nie RP czy też Zombie itp.


Wszelkie propozycje będę rozpatrywał bardzo uważnie.
The same can be done on any element, it is not restricted to the root element.
Zacznę pisać projekt kiedy wizja serwera będzie w pełni utworzona.
Więc czym szybciej zostanie ukończona wizja tym szybciej serwer wystartuje.
Mam już kilka innowacyjny pomysłów na serwer ale czekam na wasze zdanie, ponieważ chce zrobić serwer dla graczy a nie na swoja własną wizje.  


Zapraszam do pisania propozycji
===Map manager===
The [[#Example|example above]] shows the way the [[map manager]] uses different resources. The 'assault' resource is the gamemode, that manages what happens on the server using scripts and thus by creating elements in the tree dynamically. When a map resource is started, the gamemode receives a [[resource|resource pointer]] referring to the started resource - in this case ''as-farm'' - from which you can retrieve and store the resource root element. Using this element in conjunction with functions like [[getElementsByType]], [[getElementData]] and various others, you can access any of the information that was loaded into the tree from the 'as-farm.map'-file through scripts in the gamemode resource.


== '''AlteX - co miesiac tworzy nowy serwer taki on szybki''' ==
Another thing that has to be considered related to the tree of elements is the fact that when you change the map, you don't have to remove any elements you created within the map resource, while you '''do''' have to remove elements that are created within the gamemode resource, '''if''' they are specific to the map (which will be probably the case for those items you create based on information read from the map resource's .map files).
Witajcie .


Po długich zastanowieniach oraz rozmowach , nasza ekipa doszła do wniosku aby stworzyć w pełni autorski serwer pod nazwą " Your common dream " .
==Element browser==
 
You can start the resource ''elementbrowser'' to see a live view of the element tree on your server. Just start the resource and browser to your server's web page and choose the ''Element browser'' option in the sidebar (firefox only currently).
Ten projekt powstaje dzięki użytkownikom tego forum gdyż to wy daliscie nam do zrozumienia aby stworzyć coś swojego a nie tworzyć serwer na skryptach z neta .
[[Category:Scripting Concepts]]
 
[[es:Árbol de elementos]]
Administracja :
[[ru:Element tree]]
AlteX - skrypty/mapy/dodatki
Barcioo - Skrypty/Forum/Grafiki .
 
Nasz projekt ma powstawać dzięki waszym propozycją abyście dodali też coś od siebie i mieli się czym pochwalić przy oficjalnym starcie serwera .
Oczywiście osoby które będą dawały nam ciekawe propozycje z automatu będą betatesterami serwera abyście sami mogli przetestować swój pomysł .
Pracę nad serwerem ruszają od jutra , więc już niedługo powinny ukazać się pierwsze ss'y z naszej pracy wszystkie aktualizację będą dodawane na bieżąco .
 
Chcesz stworzyć coś swojego albo dołączyć się do naszej ekipy ? Nie ma problemu wystarczy że znasz się na lua lub potrafisz stworzyć mapę jedyną w swoim rodzaju . Wystarczy że napiszesz do mnie na pw forum i opiszesz tam co potrafisz a nawet możesz podeslać ss'a swojej pracy , a my zaprosimy cię do wspólnego ustalenia jak to dalej będzie .  
Przewidywany start serwera : 01.02.2017 .
Twoje Wspólne Marzenie
Dlaczego akurat wybrałem taką nazwę ?
To chyba jest oczywiste ,
chce aby nasz serwer spełnił twoje marzenia .
 
Zapraszam do dawania nam propozycji co ma się znaleść na serwerze a my nad tym pomyślimy i może właśnie twój pomysł zostanie stworzony w naszym projekcie .
Dziękuje za poświęcenie czasu na przeczytanie tej zapowiedzi i życzę ci wspaniałych pomysłów .
 
== '''NankY. - chuj wie kto to ale pseudole robi dobre''' ==
settingMTA - Serwer RPG(Role Play Gaming) czyli odgrywanie realnego życia oraz czysta rozgrywka, na serwerze znajdziemy: Doświadczoną administrację, autorskie zasoby/mapy/grafiki oraz brak jakichkolwiek błędów/luk w Game-Modzie.
Prace nad zasobami serwera nie idą zbyt szybko żeby nie robić niczego na "odwal się", serwer będzie posiadał m.in. autorskie modele postaci/budynków wykonane przez R3n0, serwer ma na celu pokazać że jednak RPG nie upadło że potrafią powstać serwery z autorskimi zasobami bo dotychczas powstają serwery na znanych Game-Modach typu: Our-Game, SquareRPG, TPR, YWG itp. serwer nie ma zamiaru korzystać z żadnych zasobów wymienionych GM. Serwer powstał z inicjatywy 2 skrypterów oraz 1 modelera: .nankY, NankjU., R3n0. sMTA jest 4 reaktywacją projektu Setting-Life tym razem na 100% udaną.
 
Forum serwera: sMTA.PL ( NIEAKTYWNE )  
Nazwa serwera: settingMTA
Przewidywana ilość slotów na start: 250
Team-Speak 3 serwera: sMTA.GCLAN.PL
Założyciele serwera: .nankY, .nankjU
Hosting: OVH.PL ( DEDYK )
Przewidywany start serwera: 2016-01-20
 
Z poważaniem .nankY
Zakaz kopiowania grafiki/treści reklamy w celu użytku własnego
 
[ Dodano: 2016-12-29, 16:22 ]  
Dotychczasowe informacje dot. aktualizacji na serwerze będą umieszczane tutaj!
 
== '''Podhal - przydupas Aspera''' ==
Witaj, zapewne odwiedziłeś naszą zapowiedź na tym portalu gdyż poszukujesz:
- Innowacyjnego serwera RPG.
- Miejsca gdzie rozegrasz ciekawe akcje role play.
- Miejsca gdzie administracja zrozumie graczy.
- Serwera który nie jest tworzony dla pieniędzy.
- Serwera na autorskich zasobach.
- Serwera gdzie nie ma faworyzacji graczy.
 
Jak sądzisz czy jest jeszcze takie miejsce?
 
Oczywiście, że jest. Takie miejsce znajduje się właśnie przed waszymi
oczami, HanceRPG, serwer tworzony dla graczy nie dla pieniędzy.
 
Dlaczego to właśnie u nas masz rozpocząć rozgrywkę?
 
Cóż jest to bardzo ciężkie pytanie, zapewne nie wybierzesz nas przez zasób jednak
przez atmosferę, dobrą administracji znającą od podstaw skrypt rozgrywki gdyż
to właśnie z nimi rozpoczęliśmy pierwsze prace, pierwsze testy.
 
Nasz plan.
Nasz plan jest dosyć prosty, chcemy stworzyć nowe innowacyjne miejsce dla graczy
na którym każdy znajdzie coś dla siebie.
Jak wiemy większość projektów RPG jest wzorowanych na różnych life
jednak bez obaw. Naszego projektu to nie dotyczy, staramy się stworzyć miejsce
gdzie każda osoba znajdzie coś dla siebie, od funkcjonariuszy role play po gangsterów dm.
Tutaj każdy znajdzie coś dla siebie…
Postanowiliśmy rozwinąć to wszystko w kierunku nowego miasta jednak o tym za chwilę...
 
Miasto, miejsce rozgrywki.
Tak jak wyżej wspomniałem jesteśmy innowacyjnym projektem dlatego też pracujemy nad własnym miastem a dokładniej nad Las Mountenos. Miasto to nie będzie wzorować się na żadnej prawdziwej miejscowości, staramy się stworzyć własne miasto z własną historią którą zaraz zaprezentujemy.
 
Historia miasta
Miasto zostało założone w 1999r. Przez nie jakiego Marca Diemado. Miasto do 2004r. działało głównie jako schronienie lub miejsce schronienia na jakiś czas dla rybaków, mafi, szajek, firm transportowych drogą morską. Jednak w 2009r. do miasta przeprowadził się znany biznesmann, John Smith razem z jego żoną Abellą Smith (Bogata para biznesmenów). Rozpoczęli normalnie, wybudowali jeden hotel w 2009 roku, rok później założyli spółkę mieszkalną ,,Sunny Smile” (Słoneczny Uśmiech). Kilka dni po utworzeniu spółki bogata para rozpoczęła budowę wielu domów. W 2010r. do miasta przeprowadziło się około 20.000 tysięcy mieszkańców dzięki owej spółce. Dnia 20.11.2014 rok w mieście mieszkało około 210.000 tys. mieszkańców i wszyscy żyją i żyli "prawdopodobnie" szczęśliwie.
 
Zasady, kary, regulaminy itp.
Zasady, kary będziemy robić razem z graczami dzięki forum które nie długo wystartuje.
Kary, kary na serwerze będą dosyć proste, oczywiście mówimy o karach za utrudnianie rozgrywki itp.
Tak więc kary będą dosyć znane, ban, kick, mute, adminjail.
 
Informacje ogólne
IP: Wkrótce.
Forum: W trakcie prac.
Planowany start: 26.02.2017r data najprawdopodobniej ulegnie zmianie.
 
Coś ode mnie :)
 
Cześć i czołem, dzisiaj prezentuje wam mój projekt nad którym obecnie pracuję, nie wiem czy przeczytaliście wszystko dlatego powiem Ci to wszystko tutaj na szybko. Tak więc pracuję razem z moją ekipą nad stworzeniem nowego miasta Las Mountenos. Planujemy razem stworzyć innowacyjne miejsce rozgrywki dla każdego gracza, więcej dowiecie się na forum które za jakiś czas zostanie udostępnione dla Was, miłego dnia ew. wieczoru. :)
 
PS. Zapraszam do zadawania pytań/komentowania pod tematem.
 
== '''Inni świetni programiści''' ==
 
'''Barcioo'''
 
'''ExtreM'''
 
'''gg55'''
 
'''VatraSs123'''
 
'''OskarYT'''
 
'''Rookspack'''
 
'''mixLoLmix'''
 
= i oczywiście ukochany przez nas wszystkich '''TRIN''' =

Revision as of 17:55, 1 January 2017

Element tree

MTA uses a so-called element tree to store all the elements that exist on the server and the client. This is directly related to the set of running resources and their map files' XML layout, although it can be changed at run-time by scripts.

If you are familiar with the concept of trees in computer-science, this should be easy to understand. If you are not, think of it like a family tree - except everyone only has a single parent. Every element has a parent element.

All elements that are created within scripts or from .map files are child elements of the resource they belong to. Thus, most elements (except for clients) exist only within resources and are also destroyed as soon as their resource is stopped.

Tree elements

  • root: This is at the very base of the tree - all elements are children (or descendants) of this element.
getRootElement()
  • resource: These are direct children of the root element - with one for each running resource. This element is called the resource root. Its ID holds the name of the resource.
getResourceRootElement()
  • map: Each resource element contains at least one map element, representing either a ".map" file in the resource or the one containing the elements created by scripts (this is called the dynamic map). Their IDs contain the maps' filenames, or dynamic for the dynamic map.
    • Map files can contain a number of other elements as well as an unlimited number of custom elements.

Example

This in an example of a serverside tree dumped to XML from a running server. Please note that it is shortened on some places for the sake of overview.

<root>
	<console/>
	<player dontRespawn="false"/>
	<player dontRespawn="false" lastSpawnarea=""/>
	<resource id="resourcebrowser"/>
	<resource id="ajax"/>
	<resource id="resourcemanager"/>
	<resource id="spawnmanager"/>
	<resource id="mapmanager"/>
	<resource id="runcode"/>
	<resource id="fr">
		<map id="dynamic">
			<vehicle/>
		</map>
	</resource>
	<resource id="elementbrowser"/>
	<resource id="assault">
		<map id="dynamic">
			<team/>
			<team/>
			<blip/>
			<marker/>
			<colshape/>
			<blip/>
			<blip/>
		</map>
	</resource>
	<resource id="as-farm">
		<map id="dynamic"/>
		<map id="as-farm.map">
			<spawngroup req="" type="attacker">
				<spawnarea posY="-8.3976354598999" posX="20.182683944702" skins="9" ... />
			</spawngroup>
			<spawngroup req="" type="attacker">
				<spawnarea posY="32.166355133057" posX="-46.90763092041" skins="9" ... />
			</spawngroup>
			<spawngroup req="" type="attacker">
				<spawnarea posY="35.214984893799" posX="-33.486911773682" skins="9" ... />
			</spawngroup>
			<spawngroup req="" type="attacker">
				<spawnarea posY="35.214984893799" posX="-33.486911773682" skins="9" ... />
			</spawngroup>
			<objective id="first" type="checkpoint" description="Breach into the farm" ... />
			<pickup type="weapon" ... />
		</map>
	</resource>
</root>

Explanation

This tree consists of a number of resource root elements, the server console and two player elements, that are direct children of the root element. All these resources have a dynamic map as child element (it is just not shown for most of them). These contain the elements that are created dynamically by this resource using scripts, for example a vehicle. If the resource has a map file, it is also a child element, itself containing all the elements in the .map file.

Let's have a closer look at the assault resource: This contains just one dynamic map that has 2 teams, 3 blips, 1 marker and 1 colshape as child elements. These are the elements that are created by the script, for example the marker, the colshape and one of the blips are probably used for the objective.

The as-farm resource's function on the contrary is to be a map for the assault gamemode. The dynamic map is empty (it could contain elements if there was a script in it though), while there is a map called 'as-farm.map', that contains a number of elements. These are mostly custom elements (like spawngroup, spawnarea, objective) but also a few elements that MTA creates automactically after loading the map (like pickup). In the brackets after the element type, you can see the element data it contains. These are identical with the attributes the .map file contains within these elements, while you can also set and get element data for any other elements (e.g. players) with setElementData and getElementData.

Pratical application

Elements can have as many children as they like. This does not directly affect the map in any way, but it comes in to its own when combined with the scripting system.

Setting data for elements

If you call a set... function on a node of the element tree, the function will affect every element within it (that it can work on).

So, the following code would set the size of every marker (the only type of element the setMarkerSize function can work on) that is below the root element to 2.5.

setMarkerSize ( getRootElement(), 2.5 )

The same can be done on any element, it is not restricted to the root element.

Map manager

The example above shows the way the map manager uses different resources. The 'assault' resource is the gamemode, that manages what happens on the server using scripts and thus by creating elements in the tree dynamically. When a map resource is started, the gamemode receives a resource pointer referring to the started resource - in this case as-farm - from which you can retrieve and store the resource root element. Using this element in conjunction with functions like getElementsByType, getElementData and various others, you can access any of the information that was loaded into the tree from the 'as-farm.map'-file through scripts in the gamemode resource.

Another thing that has to be considered related to the tree of elements is the fact that when you change the map, you don't have to remove any elements you created within the map resource, while you do have to remove elements that are created within the gamemode resource, if they are specific to the map (which will be probably the case for those items you create based on information read from the map resource's .map files).

Element browser

You can start the resource elementbrowser to see a live view of the element tree on your server. Just start the resource and browser to your server's web page and choose the Element browser option in the sidebar (firefox only currently).