Wysłany: 2012-05-04, 18:13
Marcin^^
Lajk a nie skrypter
Wiek: 29 Na forum: 5170 dni Posty: 59
Nick w MP: Marcin^^
Piwa : 2
Skorzysta?em z tego co poda? Ziomek11, ot?? kodzik mi nie zadzia?a?.
Cytat: policeVehicles = { [598]=true,[596]=true,[597]=true,[599]=true [523]=true [522]=true [490]=true [528]=true [497]=true }
policeSkins = { [280]=true,[281]=true,[282]=true,[283]=true,[284]=true,[285]=true,[286]=true }
function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle
if ( policeVehicles[getElementModel(source)] ) and ( not policeSkins[getElementModel(player)] ) then --if the vehicle is one of 4 police cars, and the skin is not a police skin
cancelEvent()
outputChatBox ( "Only policeman can enter police cars!", player ) --and tell the player why
end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) --add an event handler for onVehicleStartEnter
Wysłany: 2012-05-04, 19:07
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Kod:
policeVehicles = { [598]=true,[596]=true,[597]=true,[599]=true [523]=true [522]=true [490]=true [528]=true [497]=true }
policeSkins = { [280]=true,[281]=true,[282]=true,[283]=true,[284]=true,[285]=true,[286]=true }
function enterVehicle ( player, seat, jacked )
if ( pdVehicles[getElementModel(source)] ) and ( not pdSkins[getElementModel(player)] ) then
cancelEvent()
outputChatBox ( "Nie jeste?› pracownikiem Policji!!!", player )
end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle )
Wysłany: 2012-05-04, 19:27
Jacob
Głupiomądry
Wiek: 28 Na forum: 5502 dni Posty: 967
Nick w MP: Jacob
Piwa : 786
Kod: policeVehicles = { [598]=true,[596]=true,[597]=true,[599]=true [523]=true [522]=true [490]=true [528]=true [497]=true }
policeSkins = { [280]=true,[281]=true,[282]=true,[283]=true,[284]=true,[285]=true,[286]=true }
function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle
if ( policeVehicles[getElementModel(source)] ) and ( not policeSkins[getElementModel(player)] ) then --if the vehicle is one of 4 police cars, and the skin is not a police skin
cancelEvent()
outputChatBox ( Only policeman can enter police cars!, player ) --and tell the player why
else
outputChatBox("Jeste? policjantem, wi?c mo?esz wchodzi?", player)
end
end
addEventHandler ( onVehicleStartEnter, getRootElement(), enterVehicle )
Wysłany: 2012-05-04, 19:40
Piorun
Wiek: 32 Na forum: 6712 dni Posty: 1837
Nick w MP: Piorun
Piwa : 516
Kod: policeVehicles = { [598]=true,[596]=true,[597]=true,[599]=true [523]=true [522]=true [490]=true [528]=true [497]=true }
policeSkins = { [280]=true,[281]=true,[282]=true,[283]=true,[284]=true,[285]=true,[286]=true }
function enterVehicle ( player, seat, jacked )
if ( policeVehicles[getElementModel(source)] ) and ( not policeSkins[getElementModel(player)] ) then
cancelEvent()
outputChatBox ( "Tylko policjant mo?e wsiada? do tego pojazdu!", player )
else
outputChatBox("Jeste? policjantem, wi?c mo?esz wchodzi?", player)
end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle )
Jacob , drobne b??dy zauwa?y?em i poprawi?em. Ten kod na 100% dzia?a.
Wysłany: 2012-05-05, 09:11
Marcin^^
Lajk a nie skrypter
Wiek: 29 Na forum: 5170 dni Posty: 59
Nick w MP: Marcin^^
Piwa : 2
Sp?jrzcie, je?eli chcia?bym mie? przypis do jednego wozu na mapie, ale nie do jednego modelu tak jak 490... Jak to przerobi? b?d? co doda? aby by? przypis tylko do jednego WOZU, nie MODELU auta. + Kod: zamiast policeSkins = { [280]=true,[281]=true,[282]=true,[283]=true,[284]=true,[285]=true,[286]=true }
wpisa? login player= treletre
?
[ Dodano : 2012-05-05, 09:30 ]
Piorun, wgra?em to jako client, jako serwer, podjecha?em do miejsca ustawionych aut na mapie i co, mog? sobie do nich wsi???.... Jest z dobr? met? ale nie dzia?a ;/ HELP!
Wysłany: 2012-05-05, 15:06
Piorun
Wiek: 32 Na forum: 6712 dni Posty: 1837
Nick w MP: Piorun
Piwa : 516
M?j kod wklejasz po stronie serwera (tylko!).
Co do twojego problemu ja bym zrobi? tak:
Tworzysz tabel? po stronie serwera np. pojazdy.
Tworzysz pojazd (createVehicle, wiadomo).
Zapisujesz element do tablicy (musisz nada? index, a nie jest to trudne je?li si? wie jak odczyta? wielko??, czyli ilo?? element?w w tabeli). Przyk?adowy kod:
Kod: pojazdy [ #pojazdy + 1 ] = createVehicle ( ... )
Potem przy pomocy p?tli for sprawdzasz (oczywi?cie musisz funkcj? podpi?? pod zdarzenie onVehicleEnter ) czy dany pojazd znajduje si? w tabeli
Je?li tak - Wyrzucasz komunikat + co? z graczem robisz.
Je?li nie - Wpuszczasz gracza do pojazdu.
Przyk?adowy kod:
Kod:
pojazdy = {}
addCommandHandler("stworz",
function()
pojazdy [ #pojazdy + 1 ] = createVehicle ( ... )
end)
addEventHandler("onVehicleStartEnter", getRootElement(),
function(player)
for _,vehElement in ipairs ( pojazdy ) do
if source = vehElement then
cancelEvent()
end
end
end)
Wysłany: 2012-05-05, 17:17
Marcin^^
Lajk a nie skrypter
Wiek: 29 Na forum: 5170 dni Posty: 59
Nick w MP: Marcin^^
Piwa : 2
Po wpisaniu /stworz wy?wieli?oby mi si?.... Jakie? okno gui i mia?bym co? jak give nazwa wozu??? Na twoim przyk?adowym kodzie jest to do ogarni?cia
Wysłany: 2012-05-05, 17:18
Jacob
Głupiomądry
Wiek: 28 Na forum: 5502 dni Posty: 967
Nick w MP: Jacob
Piwa : 786
Marcin^^ , masz podane na tacy, wystarczy doda? par? rzeczy, i przerobi? troszeczk?.
Wysłany: 2012-05-05, 17:22
Piorun
Wiek: 32 Na forum: 6712 dni Posty: 1837
Nick w MP: Piorun
Piwa : 516
Cytat: Po wpisaniu /stworz wy?wieli?oby mi si?.... Jakie? okno gui i mia?bym co? jak give nazwa wozu???
Musia?e? ju? gdzie? stworzy? komend? /stworz, wi?c sprawd? sw?j kod ca?y!
Wysłany: 2012-05-05, 17:31
Marcin^^
Lajk a nie skrypter
Wiek: 29 Na forum: 5170 dni Posty: 59
Nick w MP: Marcin^^
Piwa : 2
Tak :E Cytat: pojazdy = {}
addCommandHandler("stworz",
function()
pojazdy [ #pojazdy + 1 ] = createVehicle ( ... )
end)
addEventHandler("onVehicleStartEnter", getRootElement(),
function(player)
for _,vehElement in ipairs ( pojazdy ) do
if source = vehElement then
cancelEvent()
end
end
end)
onvehiclecenter
createvehicle=player
Wysłany: 2012-05-05, 17:35
Jacob
Głupiomądry
Wiek: 28 Na forum: 5502 dni Posty: 967
Nick w MP: Jacob
Piwa : 786
Kod:
onvehiclecenter
createvehicle=player
Co to jest?
To jest dla Ciebie za trudne, nie wyrywaj si? na g??bokie wody jak nie umiesz p?ywa? - taka lekcja od wujka Jacoba
Zacznij od czego? prostszego.
Wysłany: 2012-05-05, 18:39
Marcin^^
Lajk a nie skrypter
Wiek: 29 Na forum: 5170 dni Posty: 59
Nick w MP: Marcin^^
Piwa : 2
Dzi?kuje wujku... Lecz ja chce si? tego nauczy? ! Chc? zrobi? ten skrypt i? jest on mi potrzebny
Wysłany: 2012-05-05, 18:41
Piorun
Wiek: 32 Na forum: 6712 dni Posty: 1837
Nick w MP: Piorun
Piwa : 516
Najlepiej od kompletnych podstaw Lua, czyli tworzenie funkcji, podpi?cie funkcji pod zdarzenia, co to s? parametry i jak je wykorzystywa? itp.
Tagi: przypis :: pojazdów
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: