Wysłany: 2014-09-13, 19:37
Zbyklon
Wiek: 50 Na forum: 4290 dni Posty: 45
Nick w MP: Zbyklon
Piwa : 7
Witam, ostatnio bawi?em si? skryptem i utworzy?em kilka pojazd?w do SAPD, lecz nst nie wiem jak zrobi? aby pojazd dost?pny by? tylko dla ACL policja lub Team SAPD
oto fragment kodu z przyk?adowym pojazdem :
function infek1 ( model , x , y , z , rx , ry , rz , numberplate , direction , variant1 , variant2 )
if model and x and y and z and rx and ry and rz then
local infek = createVehicle ( model , x , y , z , rx , ry , rz , numberplate , direction , variant1 , variant2 )
removeVehicleSirens ( infek )
addVehicleSirens ( infek , 2 , 2 , true , false , true , false )
setVehicleSirens ( infek , 1 , - 0.700 , 2.600 , - 0.500 , 255 , 0 , 0 , 255 , 255 )
setVehicleSirens ( infek , 2 , 0.700 , 2.600 , - 0.500 , 0 , 0 , 255 , 255 , 255 )
setVehicleColor ( infek , 0 , 0 , 0 , 0 )
addVehicleUpgrade ( infek , 1096 )
end
end
function infek2 ()
infek1 ( 411 , 2264 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 01" , false , 0 , 0 )
infek1 ( 411 , 2268 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 02" , false , 0 , 0 )
infek1 ( 411 , 2272.5 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 03" , false , 0 , 0 )
infek1 ( 411 , 2277 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 04" , false , 0 , 0 )
infek1 ( 411 , 2281.25 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 05" , false , 0 , 0 )
infek1 ( 411 , 2285.75 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 06" , false , 0 , 0 )
-- infek1 ( 411 , 2268 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 00" , false , 0 , 0 )
end
addEventHandler ( 'onResourceStart' , getResourceRootElement ( getThisResource ()), infek2 )
Prosz? o pomoc :>
Wysłany: 2014-09-13, 19:47
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Zbyklon , nadajesz przez setElementData jakie? dane p??niej robisz na sprawdzanie czy dany pojazd ma dan? dane przypisana funkcja getElementData je?eli ma to dales sprawdzasz czy gracz kt?ry pr?buje wej?? do pojazdu (event onVehicleStartEnter ) jest/ma odpowiednie acl i team(Polecam isPlayerInTeam i isPlayerInACL ) je?eli ma to chodzi a jezeli nie to blokujesz wej?cie( funkcj? cancelEvent )
Przydatne Linki:
Więcej informacji znajdziesz w Wikipedii MTA: cancelEvent
Wysłany: 2014-09-13, 19:50
Blur
Wiek: 28 Na forum: 4298 dni Posty: 47
Nick w MP: Blu
Piwa : 2
function infek2 ()
infek1 ( 411 , 2264 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 01" , false , 0 , 0 )
infek1 ( 411 , 2268 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 02" , false , 0 , 0 )
infek1 ( 411 , 2272.5 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 03" , false , 0 , 0 )
infek1 ( 411 , 2277 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 04" , false , 0 , 0 )
infek1 ( 411 , 2281.25 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 05" , false , 0 , 0 )
infek1 ( 411 , 2285.75 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 06" , false , 0 , 0 )
-- infek1 ( 411 , 2268 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 00" , false , 0 , 0 )
setElementData ( infek1 , "SAPD" , true )
end
addEventHandler ( 'onResourceStart' , getResourceRootElement ( getThisResource ()), infek2 )
enterSAPDCar = function ( player , seat , jacket )
if seat == 0 then
if getElementData ( source , "SAPD" ) == true then
if isPlayerInTeam ( player , "SAPD" )
else
cancelEvent ()
outputChatBox ( "Nie jeste? pracownikiem SAPD" , player , 255 , 0 , 0 )
end
end
end
end
addEventHandler ( "onVehicleStartEnter" , getRootElement (), enterSAPDCar )
Wysłany: 2014-09-13, 19:54
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Blur , my pomagamy a nie robimy gotowce bo?e nic ten kole? si? nie nauczy.
[ Dodano : 2014-09-13, 19:55 ]
Blur , naucz si? ten uzywa? funkcji.
Wysłany: 2014-09-13, 19:55
Blur
Wiek: 28 Na forum: 4298 dni Posty: 47
Nick w MP: Blu
Piwa : 2
luki123luki123 , co jest niby nie tak ?
Wysłany: 2014-09-13, 19:59
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Blur , to isPlayerInTeam takiej funkcji nie ma w mta jest stworzona przez gracza jak by? nie wiedzia? to naucz si? bradziej lua i zapraszam do lektury: https://wiki.multitheftauto.com/wiki/IsPlayerInTeam
[ Dodano : 2014-09-13, 20:01 ]
Kolejne: setElementData(infek1,"SAPD",true) to ci nie podzia?a poniewa? seElementData przypisuje si? do element?w stworzonych na serwer a to nie jest powino by? w funkcji to :
function infek1 ( model , x , y , z , rx , ry , rz , numberplate , direction , variant1 , variant2 )
if model and x and y and z and rx and ry and rz then
local infek = createVehicle ( model , x , y , z , rx , ry , rz , numberplate , direction , variant1 , variant2 )
removeVehicleSirens ( infek )
addVehicleSirens ( infek , 2 , 2 , true , false , true , false )
setVehicleSirens ( infek , 1 , - 0.700 , 2.600 , - 0.500 , 255 , 0 , 0 , 255 , 255 )
setVehicleSirens ( infek , 2 , 0.700 , 2.600 , - 0.500 , 0 , 0 , 255 , 255 , 255 )
setVehicleColor ( infek , 0 , 0 , 0 , 0 )
addVehicleUpgrade ( infek , 1096 )
end
end
Wysłany: 2014-09-13, 20:05
Zbyklon
Wiek: 50 Na forum: 4290 dni Posty: 45
Nick w MP: Zbyklon
Piwa : 7
OMG luki mo?na by ja?niej ? :>
Nie jestem jeszcze tak "zaawansowany" xD
Blur nst nie dzia?a :>
Wysłany: 2014-09-13, 20:12
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Zbyklon , haha wiem wiem
Kod: function infek1 ( model , x , y , z , rx , ry , rz , numberplate , direction , variant1 , variant2 )
if model and x and y and z and rx and ry and rz then
local infek = createVehicle ( model , x , y , z , rx , ry , rz , numberplate , direction , variant1 , variant2 )
removeVehicleSirens ( infek )
addVehicleSirens ( infek , 2 , 2 , true , false , true , false )
setVehicleSirens ( infek , 1 , - 0.700 , 2.600 , - 0.500 , 255 , 0 , 0 , 255 , 255 )
setVehicleSirens ( infek , 2 , 0.700 , 2.600 , - 0.500 , 0 , 0 , 255 , 255 , 255 )
setVehicleColor ( infek , 0 , 0 , 0 , 0 )
addVehicleUpgrade ( infek , 1096 )
setElementData ( infek , "SAPD" , "tak" )
end
end
function infek2 ()
infek1 ( 411 , 2264 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 01" , false , 0 , 0 )
infek1 ( 411 , 2268 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 02" , false , 0 , 0 )
infek1 ( 411 , 2272.5 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 03" , false , 0 , 0 )
infek1 ( 411 , 2277 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 04" , false , 0 , 0 )
infek1 ( 411 , 2281.25 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 05" , false , 0 , 0 )
infek1 ( 411 , 2285.75 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 06" , false , 0 , 0 )
-- infek1 ( 411 , 2268 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 00" , false , 0 , 0 )
end
addEventHandler ( 'onResourceStart' , getResourceRootElement ( getThisResource ()), infek2 )
function isPlayerInTeam ( player , team )
assert ( isElement ( player ) and getElementType ( player ) == "player" , "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring ( player ) .. "]" )
assert (( not team ) or type ( team ) == "string" or ( isElement ( team ) and getElementType ( team ) == "team" ), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring ( team ) .. "]" )
return getPlayerTeam ( player ) == ( type ( team ) == "string" and getTeamFromName ( team ) or ( type ( team ) == "userdata" and team or ( getPlayerTeam ( player ) or true )))
end
function wejdz ( player , seat , jacket )
if seat == 0 then
if getElementData ( source , "SAPD" ) == "tak" then
if isPlayerInTeam ( player , "SAPD" ) then
-- //Jeste? Policja
else
cancelEvent ()
outputChatBox ( "Nie jeste? pracownikiem SAPD" , player , 255 , 0 , 0 )
end
else
-- //Te Auto nie jest Policyjnym
end
else
-- //Nie chce jedz jako Kierowca
end
end
addEventHandler ( 'onVehicleStartEnter' , "vehicle" ., wejdz )
Licz? na piwko prosta z palnika ciep?utkie
Wysłany: 2014-09-13, 20:20
Zbyklon
Wiek: 50 Na forum: 4290 dni Posty: 45
Nick w MP: Zbyklon
Piwa : 7
[2014-09-13 20:19] SAPD restarted successfully
[2014-09-13 20:19] ERROR: Loading script failed: SAPD/test.lua:1: unexpected symbol near '?'
[2014-09-13 20:19] SCRIPT ERROR: SAPD/test.lua:1: unexpected symbol near '?'
[2014-09-13 20:19] WARNING: Script 'SAPD/test.lua' is not encoded in UTF-8. Loading as ANSI...
[2014-09-13 20:19] Starting SAPD
Luki :< nie dzia?a xD
Wysłany: 2014-09-13, 20:23
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Zbyklon , to co? u cb wklej jeszcze raz to:
function infek1 ( model , x , y , z , rx , ry , rz , numberplate , direction , variant1 , variant2 )
if model and x and y and z and rx and ry and rz then
local infek = createVehicle ( model , x , y , z , rx , ry , rz , numberplate , direction , variant1 , variant2 )
removeVehicleSirens ( infek )
addVehicleSirens ( infek , 2 , 2 , true , false , true , false )
setVehicleSirens ( infek , 1 , - 0.700 , 2.600 , - 0.500 , 255 , 0 , 0 , 255 , 255 )
setVehicleSirens ( infek , 2 , 0.700 , 2.600 , - 0.500 , 0 , 0 , 255 , 255 , 255 )
setVehicleColor ( infek , 0 , 0 , 0 , 0 )
addVehicleUpgrade ( infek , 1096 )
setElementData ( infek , "SAPD" , "tak" )
end
end
function infek2 ()
infek1 ( 411 , 2264 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 01" , false , 0 , 0 )
infek1 ( 411 , 2268 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 02" , false , 0 , 0 )
infek1 ( 411 , 2272.5 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 03" , false , 0 , 0 )
infek1 ( 411 , 2277 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 04" , false , 0 , 0 )
infek1 ( 411 , 2281.25 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 05" , false , 0 , 0 )
infek1 ( 411 , 2285.75 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 06" , false , 0 , 0 )
-- infek1 ( 411 , 2268 , 2473.5427246094 , 2.7917623519897 , 0 , 0 , 0 , "SAPDW 00" , false , 0 , 0 )
end
addEventHandler ( 'onResourceStart' , getResourceRootElement ( getThisResource ()), infek2 )
function isPlayerInTeam ( player , team )
assert ( isElement ( player ) and getElementType ( player ) == "player" , "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring ( player ) .. "]" )
assert (( not team ) or type ( team ) == "string" or ( isElement ( team ) and getElementType ( team ) == "team" ), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring ( team ) .. "]" )
return getPlayerTeam ( player ) == ( type ( team ) == "string" and getTeamFromName ( team ) or ( type ( team ) == "userdata" and team or ( getPlayerTeam ( player ) or true )))
end
function wejdz ( player , seat , jacket )
if seat == 0 then
if getElementData ( source , "SAPD" ) == "tak" then
if isPlayerInTeam ( player , "SAPD" ) then
-- //Jeste? Policja
else
cancelEvent ()
outputChatBox ( "Nie jeste? pracownikiem SAPD" , player , 255 , 0 , 0 )
end
else
-- //Te Auto nie jest Policyjnym
end
else
-- //Nie chce jedz jako Kierowca
end
end
addEventHandler ( 'onVehicleStartEnter' , "vehicle" ., wejdz )
Wysłany: 2014-09-13, 20:31
Zbyklon
Wiek: 50 Na forum: 4290 dni Posty: 45
Nick w MP: Zbyklon
Piwa : 7
Znalaz?em problem .. po zmianie z "jeste?" na "jestes" i usuni?ciu "." w ostatnim wersie .. pojazdy si? pojawiaj? .... lecz nie stety ka?dy poza ACL policja i team'em SAPD mo?e wej??
Wysłany: 2014-09-13, 20:38
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Zbyklon , Tylko Team SAPD mo?e wejsc.
Wysłany: 2014-09-13, 20:49
Zbyklon
Wiek: 50 Na forum: 4290 dni Posty: 45
Nick w MP: Zbyklon
Piwa : 7
no w?a?nie m?wi? jestem w team Policja i ka?dy mo?e wej?? do tego pojazdu
Wysłany: 2014-09-13, 20:52
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Zbyklon , tylko na g a ty na f
Wysłany: 2014-09-13, 21:08
Zbyklon
Wiek: 50 Na forum: 4290 dni Posty: 45
Nick w MP: Zbyklon
Piwa : 7
Ka?dy, KA?DY mo?e wej?? na F ;d
Tagi: pojazdy :: acl :: team
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: