Poka?, gdzie przy wej?ciu na serwer masz nadawan? elementdat? na prawko katB.
ElementData resetuje si? po wyj?ciu z serwera, tak wi?c po ka?dym wej?ciu musisz sprawdza? w bazie danych, czy owe prawko ma, i je?li ma to nadawa? elementdat?, albo nada? accountDat?, lecz po restarcie serwera zn?w na nowo b?dziesz musia? nadawa?. Dodaj najlepiej do bazy danych stan prawka, czy ma, czy te? nie ma. Je?li ma, to przy wsiadaniu do pojazdu nic nie r?b, je?li nie ma to cancelEvent() i outputChatBox czy co tam chcesz.
! Koniecznie zapoznaj się z regulaminem forum.
Pamiętaj, aby zawsze go przestrzegać, nie mniej ważne są również regulaminy działów, w których się wypowiadasz!
Zamiast zakładać temat po kilka razy, bo jest usuwany przez Administrację, przejrzyj regulamin i napisz poprawnie temat!
Sprawy z administracją możesz załatwiać anonimowo w tym dziale.
Najważniejsze informacje od Administracji możesz przeczytać tutaj oraz tutaj.
Emm, Ja nie jestem do?wiadczonym skrypterem i szczerze m?wi?c nie rozumiem co ty piszesz lecz moge Ci powiedziec ze to jest ogrpg i gdy zdam prawko to zapisuje sie w bazie mysql i po wyjsciu i wejsciu nadal mam to prawko xd
amama5, Prawko na elementdaty, s?aby pomys?, poniewa? po wyj?ciu z serwera i wej?ciu tego prawka ju? mia?nie bb?dziesz. Co do problemu to
function prawojazdy ( thePlayer, seat, jacked, gracz )
if seat == 0 then
if getElementData(thePlayer, "player:lic:pjB") == false then
outputChatBox("Nie posiadasz prawa jazdy",thePlayer)
cancelEvent ()
end
end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), prawojazdy )
marcin778, Nie moge wsiada? do pojazdu, ale gdy mam prawo jazdy zdane to te? nie mog? mo?e kod z prawem jazdy co? zmieni:
--[[
Resource: OURGame
Developers: Split <split.programista@gmail.com>
Copyright <split.programista@gmail.com> 2015-2016
You have no right to use this code without my permission.
]]
local startMarkers={
{'BC', 363.1123046875, 210.1064453125, 1008.3828125, 1561, 3},
{'A', 356.62890625, 209.5205078125, 1008.3828125, 1561, 3},
{'L', 355.4482421875, 203.958984375, 1008.3828125, 1561, 3},
}
local listCategory={
{'BC', 482, -1733.90, -116.35, 3.55, 90.729},
{'A', 586, -1733.90, -116.35, 3.55, 90.729},
{'L', 593, -1357.69,-242.88,14.61,314.34},
}
local pointsCategory={
{'BC',-1768.21,-115.95,3.73,'checkpoint',''},
{'BC',-1801.08,-141.68,6.43,'checkpoint',''},
{'BC',-1801.37,-238.68,18.30,'checkpoint',''},
{'BC',-1811.48,-375.01,18.30,'checkpoint',''},
{'BC',-1823.32,-447.33,15.07,'checkpoint',''},
{'BC',-1821.08,-558.61,16.31,'checkpoint',''},
{'BC',-1850.49,-573.82,21.03,'checkpoint',''},
{'BC',-1911.20,-575.75,24.56,'checkpoint',''},
{'BC',-2053.28,-569.57,29.39,'checkpoint',''},
{'BC',-2045.36,-601.45,30.38,'checkpoint',''},
{'BC',-1992.04,-662.90,32.45,'checkpoint',''},
{'BC',-1990.75,-739.47,32.14,'checkpoint',''},
{'BC',-1991.34,-813.97,32.15,'checkpoint',''},
{'BC',-1991.53,-877.59,32.15,'checkpoint',''},
{'BC',-1991.33,-952.62,32.15,'checkpoint',''},
{'BC',-1991.54,-1046.65,32.16,'checkpoint',''},
{'BC',-1990.36,-1176.46,39.62,'checkpoint',''},
{'BC',-1957.33,-1233.75,39.60,'checkpoint',''},
{'BC',-1907.70,-1300.35,39.60,'checkpoint',''},
{'BC',-1919.44,-1362.55,40.47,'checkpoint',''},
{'BC',-1962.00,-1332.47,40.17,'checkpoint',''},
{'BC',-2007.41,-1267.67,36.55,'checkpoint',''},
{'BC',-2060.76,-1175.92,32.12,'checkpoint',''},
{'BC',-2101.07,-1103.97,30.32,'checkpoint',''},
{'BC',-2157.28,-1023.37,33.18,'checkpoint',''},
{'BC',-2205.81,-982.54,37.84,'checkpoint',''},
{'BC',-2216.24,-918.15,44.63,'checkpoint',''},
{'BC',-2195.82,-832.10,58.62,'checkpoint',''},
{'BC',-2192.96,-779.14,61.78,'checkpoint',''},
{'BC',-2224.96,-741.62,64.62,'checkpoint',''},
{'BC',-2258.84,-752.43,75.21,'checkpoint',''},
{'BC',-2293.52,-767.81,86.70,'checkpoint',''},
{'BC',-2325.62,-784.50,92.26,'checkpoint',''},
{'BC',-2349.48,-778.12,95.11,'checkpoint',''},
{'BC',-2342.25,-710.34,110.37,'checkpoint',''},
{'BC',-2396.66,-631.52,131.46,'checkpoint',''},
{'BC',-2453.08,-528.99,116.21,'checkpoint',''},
{'BC',-2493.10,-478.55,96.15,'checkpoint',''},
{'BC',-2604.99,-496.21,73.24,'checkpoint',''},
{'BC',-2576.88,-469.69,68.04,'checkpoint',''},
{'BC',-2504.94,-454.32,74.50,'checkpoint',''},
{'BC',-2449.22,-426.29,84.69,'checkpoint',''},
{'BC',-2397.35,-423.39,84.06,'checkpoint',''},
{'BC',-2330.51,-462.10,80.14,'checkpoint',''},
{'BC',-2330.70,-421.74,79.61,'checkpoint',''},
{'BC',-2396.22,-370.30,74.85,'checkpoint',''},
{'BC',-2537.23,-364.29,55.72,'checkpoint',''},
{'BC',-2671.84,-410.81,32.22,'checkpoint',''},
{'BC',-2680.82,-519.64,17.42,'checkpoint',''},
{'BC',-2778.64,-489.74,7.30,'checkpoint',''},
{'BC',-2758.72,-457.52,7.19,'checkpoint',''},
{'BC',-2670.96,-386.02,9.67,'checkpoint',''},
{'BC',-2582.53,-353.08,21.75,'checkpoint',''},
{'BC',-2492.75,-343.85,30.82,'checkpoint',''},
{'BC',-2388.63,-343.71,37.85,'checkpoint',''},
{'BC',-2295.76,-349.69,39.98,'checkpoint',''},
{'BC',-2124.52,-351.94,35.12,'checkpoint',''},
{'BC',-2010.99,-350.39,36.28,'checkpoint',''},
{'BC',-1934.43,-337.65,45.57,'checkpoint',''},
{'BC',-1861.53,-257.17,49.60,'checkpoint',''},
{'BC',-1875.44,-166.43,40.27,'checkpoint',''},
{'BC',-1889.82,-65.18,38.36,'checkpoint',''},
{'BC',-1884.76,78.59,38.33,'checkpoint',''},
{'BC',-1860.97,181.33,38.43,'checkpoint',''},
{'BC',-1807.51,354.39,17.11,'checkpoint',''},
{'BC',-1762.55,318.62,7.18,'checkpoint',''},
{'BC',-1769.41,290.96,8.39,'checkpoint',''},
{'BC',-1810.51,225.85,15.08,'checkpoint',''},
{'BC',-1809.48,190.17,15.08,'checkpoint',''},
{'BC',-1779.79,181.58,8.90,'checkpoint',''},
{'BC',-1765.45,153.93,4.88,'checkpoint',''},
{'BC',-1749.29,113.14,3.67,'checkpoint',''},
{'BC',-1748.94,18.09,3.68,'checkpoint',''},
{'BC',-1731.49,-56.94,3.67,'checkpoint',''},
{'A',-1768.21,-115.95,3.73,'checkpoint',''},
{'A',-1801.08,-141.68,6.43,'checkpoint',''},
{'A',-1801.37,-238.68,18.30,'checkpoint',''},
{'A',-1811.48,-375.01,18.30,'checkpoint',''},
{'A',-1823.32,-447.33,15.07,'checkpoint',''},
{'A',-1821.08,-558.61,16.31,'checkpoint',''},
{'A',-1850.49,-573.82,21.03,'checkpoint',''},
{'A',-1911.20,-575.75,24.56,'checkpoint',''},
{'A',-2053.28,-569.57,29.39,'checkpoint',''},
{'A',-2045.36,-601.45,30.38,'checkpoint',''},
{'A',-1992.04,-662.90,32.45,'checkpoint',''},
{'A',-1990.75,-739.47,32.14,'checkpoint',''},
{'A',-1991.34,-813.97,32.15,'checkpoint',''},
{'A',-1991.53,-877.59,32.15,'checkpoint',''},
{'A',-1991.33,-952.62,32.15,'checkpoint',''},
{'A',-1991.54,-1046.65,32.16,'checkpoint',''},
{'A',-1990.36,-1176.46,39.62,'checkpoint',''},
{'A',-1957.33,-1233.75,39.60,'checkpoint',''},
{'A',-1907.70,-1300.35,39.60,'checkpoint',''},
{'A',-1919.44,-1362.55,40.47,'checkpoint',''},
{'A',-1962.00,-1332.47,40.17,'checkpoint',''},
{'A',-2007.41,-1267.67,36.55,'checkpoint',''},
{'A',-2060.76,-1175.92,32.12,'checkpoint',''},
{'A',-2101.07,-1103.97,30.32,'checkpoint',''},
{'A',-2157.28,-1023.37,33.18,'checkpoint',''},
{'A',-2205.81,-982.54,37.84,'checkpoint',''},
{'A',-2216.24,-918.15,44.63,'checkpoint',''},
{'A',-2195.82,-832.10,58.62,'checkpoint',''},
{'A',-2192.96,-779.14,61.78,'checkpoint',''},
{'A',-2224.96,-741.62,64.62,'checkpoint',''},
{'A',-2258.84,-752.43,75.21,'checkpoint',''},
{'A',-2293.52,-767.81,86.70,'checkpoint',''},
{'A',-2325.62,-784.50,92.26,'checkpoint',''},
{'A',-2349.48,-778.12,95.11,'checkpoint',''},
{'A',-2342.25,-710.34,110.37,'checkpoint',''},
{'A',-2396.66,-631.52,131.46,'checkpoint',''},
{'A',-2453.08,-528.99,116.21,'checkpoint',''},
{'A',-2493.10,-478.55,96.15,'checkpoint',''},
{'A',-2604.99,-496.21,73.24,'checkpoint',''},
{'A',-2576.88,-469.69,68.04,'checkpoint',''},
{'A',-2504.94,-454.32,74.50,'checkpoint',''},
{'A',-2449.22,-426.29,84.69,'checkpoint',''},
{'A',-2397.35,-423.39,84.06,'checkpoint',''},
{'A',-2330.51,-462.10,80.14,'checkpoint',''},
{'A',-2330.70,-421.74,79.61,'checkpoint',''},
{'A',-2396.22,-370.30,74.85,'checkpoint',''},
{'A',-2537.23,-364.29,55.72,'checkpoint',''},
{'A',-2671.84,-410.81,32.22,'checkpoint',''},
{'A',-2680.82,-519.64,17.42,'checkpoint',''},
{'A',-2778.64,-489.74,7.30,'checkpoint',''},
{'A',-2758.72,-457.52,7.19,'checkpoint',''},
{'A',-2670.96,-386.02,9.67,'checkpoint',''},
{'A',-2582.53,-353.08,21.75,'checkpoint',''},
{'A',-2492.75,-343.85,30.82,'checkpoint',''},
{'A',-2388.63,-343.71,37.85,'checkpoint',''},
{'A',-2295.76,-349.69,39.98,'checkpoint',''},
{'A',-2124.52,-351.94,35.12,'checkpoint',''},
{'A',-2010.99,-350.39,36.28,'checkpoint',''},
{'A',-1934.43,-337.65,45.57,'checkpoint',''},
{'A',-1861.53,-257.17,49.60,'checkpoint',''},
{'A',-1875.44,-166.43,40.27,'checkpoint',''},
{'A',-1889.82,-65.18,38.36,'checkpoint',''},
{'A',-1884.76,78.59,38.33,'checkpoint',''},
{'A',-1860.97,181.33,38.43,'checkpoint',''},
{'A',-1807.51,354.39,17.11,'checkpoint',''},
{'A',-1762.55,318.62,7.18,'checkpoint',''},
{'A',-1769.41,290.96,8.39,'checkpoint',''},
{'A',-1810.51,225.85,15.08,'checkpoint',''},
{'A',-1809.48,190.17,15.08,'checkpoint',''},
{'A',-1779.79,181.58,8.90,'checkpoint',''},
{'A',-1765.45,153.93,4.88,'checkpoint',''},
{'A',-1749.29,113.14,3.67,'checkpoint',''},
{'A',-1748.94,18.09,3.68,'checkpoint',''},
{'A',-1731.49,-56.94,3.67,'checkpoint',''},
{'L',-1343.51,-228.76,14.62,'checkpoint'},
{'L',-1307.31,-191.64,14.63,'checkpoint'},
{'L',-1290.97,-142.74,14.64,'checkpoint'},
{'L',-1322.52,-96.21,14.65,'checkpoint'},
{'L',-1374.84,-43.96,14.69,'checkpoint'},
{'L',-1438.93,19.78,14.62,'checkpoint'},
{'L',-1425.15,68.57,14.63,'checkpoint'},
{'L',-1334.17,159.23,17.18,'ring'},
{'L',-1300.50,195.63,20.51,'ring'},
{'L',-1105.96,388.00,45.63,'ring'},
{'L',-976.77,510.70,60.23,'ring'},
{'L',-889.06,591.31,70.05,'ring'},
{'L',-733.91,662.94,90.65,'ring'},
{'L',-633.71,703.63,103.55,'ring'},
{'L',-444.14,777.96,107.55,'ring'},
{'L',-346.54,817.26,105.34,'ring'},
{'L',-242.04,865.31,104.89,'ring'},
{'L',-171.06,894.22,107.44,'ring'},
{'L',-67.39,940.51,104.04,'ring'},
{'L',177.43,1050.64,102.55,'ring'},
{'L',314.67,1111.73,100.85,'ring'},
{'L',566.68,1216.28,93.30,'ring'},
{'L',687.29,1270.40,94.34,'ring'},
{'L',881.09,1397.39,96.47,'ring'},
{'L',984.38,1504.76,93.55,'ring'},
{'L',1062.78,1641.94,90.66,'ring'},
{'L',1129.71,1940.64,93.62,'ring'},
{'L',1130.87,2039.90,94.45,'ring'},
{'L',1133.02,2259.49,101.29,'ring'},
{'L',1071.32,2428.47,112.86,'ring'},
{'L',878.83,2477.79,93.30,'ring'},
{'L',698.46,2485.49,75.32,'ring'},
{'L',566.33,2493.59,54.62,'ring'},
{'L',457.37,2499.96,36.99,'ring'},
{'L',352.89,2506.03,21.11,'ring'},
{'L',257.98,2491.27,16.95,'checkpoint'},
{'L',276.02,2480.39,16.97,'checkpoint'},
{'L',308.69,2480.61,16.97,'checkpoint'},
{'L',330.46,2506.18,16.96,'checkpoint'},
{'L',325.78,2543.28,17.27,'checkpoint'},
}
local t=createElement('text')
t:setData('name','Zdawanie na\nprawo jazdy')
t:setPosition(366.509765625, 189.2177734375, 1008.3828125+2)
t:setDimension(1561)
t:setInterior(3)
local t=createElement('text')
t:setData('name','Kategoria B+C')
t:setPosition(363.1123046875, 210.1064453125, 1008.3828125)
t:setDimension(1561)
t:setInterior(3)
local t=createElement('text')
t:setData('name','Kategoria A')
t:setPosition(356.62890625, 209.5205078125, 1008.3828125)
t:setDimension(1561)
t:setInterior(3)
local t=createElement('text')
t:setData('name','Kategoria L')
t:setPosition(355.4482421875, 203.958984375, 1008.3828125)
t:setDimension(1561)
t:setInterior(3)
local function destroyMarkerPlayer(plr)
local markers=getElementsByType('marker', resourceRoot)
for i,v in pairs(markers) do
if v:getData('license:owner')==plr:getName() then
v:destroy()
end
end
end
local function showMarker(plr)
local number=plr:getData('license:index')
local category=plr:getData('license:category')
if not number or not category then return end
if not plr:getOccupiedVehicle() then return end
local indexNumberCheck=0
for i,v in pairs(pointsCategory) do
if v[1]==category then
indexNumberCheck=indexNumberCheck+1
if number>LoopCategoryElements(category) then
licenseFinish(plr, true)
return
end
if indexNumberCheck==number then
local marker=createMarker(v[2], v[3], v[4], v[5], 5.5, 0, 0, 255, 150, plr)
marker:setData('license:owner', plr:getName())
addEventHandler('onMarkerHit', marker, nextPointToMarker)
end
end
end
end
function LoopCategoryElements(category)
local counter=0
for i,v in pairs(pointsCategory) do
if v[1]==category then
counter=counter+1
end
end
return counter
end
function licenseFinish(plr, value)
if not plr then return end
if plr:getData('license:category') and plr:getData('license:category') then
if value then
if plr:getData('license:category')=='A' then
plr:setData('player:lic:pjA', 1)
elseif plr:getData('license:category')=='BC' then
plr:setData('player:lic:pjC', 1)
elseif plr:getData('license:category')=='L' then
plr:setData('player:lic:pjL', 1)
end
destroyMarkerPlayer(plr)
plr:removeData('license:start')
plr:removeData('license:index')
local pojazd=plr:getOccupiedVehicle()
if pojazd then
pojazd:destroy()
end
plr:outputChat('* Zda?e?(a?) egzamin z wynikiem pozytywnym!')
fadeCamera(plr, false)
Timer(function()
plr:setPosition(362.99, 207.16, 1008.38)
setPedRotation(plr, 271.552)
plr:setInterior(3)
plr:setDimension(1561)
fadeCamera(plr, true)
end, 1500, 1)
else
destroyMarkerPlayer(plr)
plr:removeData('license:start')
plr:removeData('license:index')
local pojazd=plr:getOccupiedVehicle()
if pojazd then
pojazd:destroy()
end
plr:outputChat('* Nie zda?e?(a?) egzaminu, spr?buj ponownie! Mo?e nast?pnym razem si? uda...')
fadeCamera(plr, false)
Timer(function()
plr:setPosition(362.99, 207.16, 1008.38)
setPedRotation(plr, 271.552)
plr:setInterior(3)
plr:setDimension(1561)
fadeCamera(plr, true)
end, 1500, 1)
end
if value=='wyjscie' then
local pojazd=plr:getOccupiedVehicle()
if pojazd then
pojazd:destroy()
end
end
end
end
function nextPointToMarker(plr)
if not plr then return end
if plr:getData('license:category') and plr:getData('license:category') and source:getData('license:owner')==plr:getName() then
local idx=plr:getData('license:index')
plr:setData('license:index', idx+1)
source:destroy()
showMarker(plr)
end
end
function createExample(plr)
if not plr:getData('player:logged') then return end
--if plr:getName()~='dpj09' then return end
local category=source:getData('marker:category')
if source:getData('marker:category') == 'BC' then
if plr:getData('player:lic:pjC') == 1 then
plr:outputChat('* Posiadasz prawo jazdy kategorii B i C')
return
end
elseif source:getData('marker:category') == 'A' then
if plr:getData('player:lic:pjA') == 1 then
plr:outputChat('* Posiadasz prawo jazdy kategorii A')
return
end
elseif source:getData('marker:category') == 'L' then
if plr:getData('player:lic:pjL') == 1 then
plr:outputChat('* Posiadasz prawo jazdy kategorii L')
return
end
end
for i,v in pairs(listCategory) do
if v[1] == category then
-- pos starting driving license
-- -1733.90, -116.35, 3.55, 90.729
fadeCamera(plr, false)
local vehicle=Vehicle(v[2], v[3], v[4], v[5], 0, 0, v[6])
if vehicle:getVehicleType()=='Automobile' or vehicle:getVehicleType()=='Bike' then
vehicle:setHandling('maxVelocity', 90.0)
vehicle:addUpgrade(1025)
end
vehicle:setData('vehicle:desc', 'Egzamin prawa jazdy')
vehicle:setData('vehicle:mileage', math.random(500, 1000))
vehicle:setData('vehicle:fuel', math.random(50, 60))
plr:setData('license:index', 1)
plr:setData('license:category', category)
Timer(function()
fadeCamera(plr, true)
plr:warpIntoVehicle(vehicle)
plr:setInterior(0)
plr:setDimension(0)
vehicle:setEngineState(true)
showMarker(plr)
end, 2000, 1)
return
end
end
end
local function createMarkers()
for i,v in pairs(startMarkers) do
local marker=createMarker(v[2], v[3], v[4]-0.9, 'cylinder', 1, 255, 0, 0)
marker:setData('marker:category', v[1])
marker:setDimension(v[5] or 0)
marker:setInterior(v[6] or 0)
addEventHandler('onMarkerHit', marker, createExample)
end
end
createMarkers()
addEventHandler('onPlayerWasted', root, function()
if source:getData('license:category') and source:getData('license:category') then
licenseFinish(source, false)
end
end)
addEventHandler('onVehicleDamage', resourceRoot, function(loss)
if not loss then return end
local plr=getVehicleOccupant(source)
if not plr then return end
if plr:getData('license:category') and plr:getData('license:category') then
licenseFinish(plr, false)
source:destroy()
end
end)
addEventHandler('onVehicleStartExit', resourceRoot, function(plr, seat, jacked)
if seat==0 then
if plr:getData('license:category') and plr:getData('license:category') then
cancelEvent()
end
end
end)
addEventHandler('onPlayerQuit', root, function()
if source:getData('license:category') and source:getData('license:category') then
licenseFinish(source, 'wyjscie')
end
end)
-- cmds
addCommandHandler('lotgp1', function(plr,cmd)
local veh=getPedOccupiedVehicle(plr)
if not veh then return end
local x,y,z=getElementPosition(veh)
local p=string.format("{'BC',%.2f,%.2f,%.2f,'checkpoint',''},", x,y,z)
outputChatBox(p)
end)
addCommandHandler('lotgp2', function(plr,cmd)
local veh=getPedOccupiedVehicle(plr)
if not veh then return end
local x,y,z=getElementPosition(veh)
local p=string.format("{'A',%.2f,%.2f,%.2f,'checkpoint',''},", x,y,z)
outputChatBox(p)
end)
! Koniecznie zapoznaj się z regulaminem forum.
Pamiętaj, aby zawsze go przestrzegać, nie mniej ważne są również regulaminy działów, w których się wypowiadasz!
Zamiast zakładać temat po kilka razy, bo jest usuwany przez Administrację, przejrzyj regulamin i napisz poprawnie temat!
Sprawy z administracją możesz załatwiać anonimowo w tym dziale.
Najważniejsze informacje od Administracji możesz przeczytać tutaj oraz tutaj.
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