Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2011-07-09, 14:33


Shaun

Młodszy Programer






Wiek: 32
Na forum: 6893 dni
Posty: 463
Nick w MP: Shaun

Piwa: 1786

Respekt: 96

Witajcie :P

Mam problem z rozgryzieniem pewnego "problemu" w LUA(poniewa? dopiero zaczynam ;) ).

Z tego co mi wiadomo, niekt?re funkcje mo?na wykona? tylko po stronie serwera, a niekt?re po stronie klienta - ?eby to wszystko poprawnie dzia?a?o.

No ale co zrobi?, gdy po stronie klienta, chc? wykona? funkcj? ze strony serwera(kt?ra jest oczywi?cie w innym pliku) ?? Np. po wej?ciu w marker(kt?ry jest utworzony po stronie serwera), otworzy GUI(po stronie klienta).

Podpis
,
pomogłem ci ?? Wystarczy jak podziękujesz ;)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2011-07-09, 16:02


Piorun







Wiek: 32
Na forum: 6712 dni
Posty: 1837
Nick w MP: Piorun

Piwa: 516

Respekt: 480,7
Respekt: 480,7

Kod:

triggerClientEvent

Kod:

triggerServerEvent

Kod:

addEvent


Zapraszam do wiki MTA - tam wszystko jest opisane.

Podpis
Możesz mnie znaleźć na: Facebook
Postaw piwo autorowi tego posta
 

 
Wysłany: 2011-07-09, 16:29


Shaun

Młodszy Programer






Wiek: 32
Na forum: 6893 dni
Posty: 463
Nick w MP: Shaun

Piwa: 1786

Respekt: 96

No dobra :P Rozwi?zane, poka?? jakby kto? nie wiedzia? xD
Po stronie klienta:
Kod:

--Setup some tables

shotguns = {
"chrome",
"sawn-off",
"combat"
}

machineGun = {
"m4",
"ak-47"
}

function setupWeaponSelection ( theResource )
-- getResourceRootElement(getThisResource()) at the bottom means it will only create the gui on this resource start
-- Create a window for our spawnscreen, with the title "Select your weapons".
spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "Select your weapons", true )
-- create an OK button to allow the user to confirm their selections, and attach it to the confirmSelection function
spawnScreenOKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, spawnScreenMenu )
-- ensure the user can't move or resize our spawnscreen.
guiWindowSetMovable ( spawnScreenMenu, false )
guiWindowSetSizable ( spawnScreenMenu, false )
-- create our gridlist, which fills up most of the window.
spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu )
guiGridListSetSelectionMode ( spawnScreenGridList, 2 ) -- ensure the selection mode is one per column
-- Since we have 2 sets of weapons, create a column for shotguns and one for machine guns
guiGridListAddColumn ( spawnScreenGridList, "Shotguns", 0.3 )
guiGridListAddColumn ( spawnScreenGridList, "Machine guns", 0.3 )
-- next, we loop through our handguns table to add handgun items to the gridlist
for key,weaponName in pairs(shotguns) do
-- add a new row to our gridlist each time
local row = guiGridListAddRow ( spawnScreenGridList )
-- next, we set that row's text to the weapon name. Column is 1 since the "Shotguns" column was created first.
guiGridListSetItemText ( spawnScreenGridList, row, 1, weaponName, false, false )
end
-- we repeat the process for other weapon list, changing the column number
row = 0
for key,weaponName in pairs(machineGun) do
-- we don't need to create new rows as that was done in the previous loop
-- we just set the row's text to the weapon name. Column is 2 since the "Machine guns" column was created second.
guiGridListSetItemText ( spawnScreenGridList, row, 2, weaponName, false, false )
row = row + 1 -- increase the row number
end
end
addEvent( "onGreeting", true )
addEventHandler( "onGreeting", getRootElement(), setupWeaponSelection)

Po stronie serwera:
Kod:

theMarker = createMarker ( -713.363, 957.305, 11, "cylinder", 1.5, 255, 255, 0, 170 )

function duty(hitElement, matchingDimension)
triggerClientEvent ( "onGreeting", getRootElement())
outputChatBox("Good! Duty 1.", thePlayer, 255, 0, 0)

end
addEventHandler( "onMarkerHit", theMarker, duty )


Prosta funkcja, kt?ra po wej?ciu w marker wy?wietli GIU, kt?re pobra?em z wikiMTA ;)

Podpis
,
pomogłem ci ?? Wystarczy jak podziękujesz ;)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2011-07-09, 16:32


Piorun







Wiek: 32
Na forum: 6712 dni
Posty: 1837
Nick w MP: Piorun

Piwa: 516

Respekt: 480,7
Respekt: 480,7

Masz zdefiniowane "thePlayer" ?? ?

Podpis
Możesz mnie znaleźć na: Facebook
Postaw piwo autorowi tego posta
 

 
Wysłany: 2011-07-09, 18:18


Shaun

Młodszy Programer






Wiek: 32
Na forum: 6893 dni
Posty: 463
Nick w MP: Shaun

Piwa: 1786

Respekt: 96

tonymontana, po stronie serwera chyba nie trzeba definiowa? thePlayer ?? Ale dzia?a ;)

Podpis
,
pomogłem ci ?? Wystarczy jak podziękujesz ;)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2011-07-09, 19:44


KukiX







Wiek: 34
Na forum: 6718 dni
Posty: 567

Piwa: 17560

Respekt: 160
Respekt: 160Respekt: 160

Nic nie musisz definiowa? po prostu zamiast thePlayer powinno by? hitElement czyli element(gracz) kt?ry wszed? w marker.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2011-07-09, 22:05


Piorun







Wiek: 32
Na forum: 6712 dni
Posty: 1837
Nick w MP: Piorun

Piwa: 516

Respekt: 480,7
Respekt: 480,7

"KukiX" napisał/a:

Nic nie musisz definiowa? po prostu zamiast thePlayer powinno by? hitElement czyli element(gracz) kt?ry wszed? w marker.

plus jeszcze
Kod:

if (getElementType(hitElement) == "player") then

Pozdrawiam :)

Podpis
Możesz mnie znaleźć na: Facebook
Postaw piwo autorowi tego posta
 

 
Tagi: server :: client
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku