· 5 years ago · Apr 15, 2020, 05:16 PM
1
2local bazy = 17;
3
4--local db = dbConnect("sqlite","uzytkowanie")
5--dbExec ( db, "CREATE TABLE IF NOT EXISTS Bazy (lider,owner,)")
6
7local bazy_marker = {}
8
9
10local blipy = {}
11
12local baza_auto = {}
13
14local col_to_marker = {}
15
16local col_shapy = createElement("col_shapy_baz","col_shapy_baz")
17
18
19
20
21function getVehicle(typ,cuboid)
22 local cars = {}
23 for i,v in pairs(getElementsWithinColShape(cuboid,'vehicle')) do
24 if typ==1 then
25 if getVehicleType(v) =="Automobile" or getVehicleType(v)=="Quad" or getVehicleType(v)=="Bike" then
26 table.insert(cars,v)
27 end
28 else
29 if getVehicleType(v)=="Helicopter" or getVehicleType(v)=="Plane" then
30 table.insert(cars,v)
31 end
32 end
33 end
34 return cars
35end
36
37local blocked_bases = {
38 [42] = true,
39 [46] = true,
40 [43] = true,
41 [64] = true,
42 [34] = true,
43
44}
45
46local ilosc_zarobku = 0
47local ilosc_zarobku_max = 0
48
49local sprawdz = {
50 ".Mlody",
51 "GuupekMalyy",
52 "Blueee",
53 "Tabu",
54 "hammerr",
55 "Klaudiuszek2001",
56 "Linux",
57 "DjEpitet",
58 "Szwagier0",
59 "neffo",
60}
61
62addEventHandler("onResourceStart",resourceRoot,function()
63 local i = 0
64 while (i<9999) do
65 i = i + 1
66
67 if not fileExists("bazy/baza_"..i..".xml") then break end
68 local file = xmlLoadFile("bazy/baza_"..i..".xml")
69 if file then
70 local atrybut = xmlFindChild(file,"informacje",0)
71 if atrybut and not blocked_bases[i] then
72 local pozycje = {}
73 local lider = xmlNodeGetAttribute(atrybut,"lider")
74 local grupa = xmlNodeGetAttribute(atrybut,"grupa")
75 local id = xmlNodeGetAttribute(atrybut,"id_bazy")
76 local gracze = xmlNodeGetAttribute(atrybut,"gracze")
77 local dni = xmlNodeGetAttribute(atrybut,"dni")
78 local kupione = xmlNodeGetAttribute(atrybut,"kupione")
79 local cena = xmlNodeGetAttribute(atrybut,"cena")
80 local typ = xmlNodeGetAttribute(atrybut,"typ")
81 local limity_naziemne = xmlNodeGetAttribute(atrybut,"limit_naziemnych")
82 local limity_lotne = xmlNodeGetAttribute(atrybut,"limit_lotne")
83 local bramy = {xmlNodeGetAttribute(atrybut,"brama_1"),xmlNodeGetAttribute(atrybut,"brama_2"),xmlNodeGetAttribute(atrybut,"brama_3")}
84 pozycje["marker"] = split(xmlNodeGetAttribute(atrybut,"marker_dane"),",")
85
86 local alpha
87 if kupione == "Tak" then
88 alpha = {255,0,0,0}
89 else
90 alpha = {0,255,0,0}
91 end
92 local marker = createMarker(pozycje["marker"][1],pozycje["marker"][2],pozycje["marker"][3],'cylinder',1.5,alpha[1],alpha[2],alpha[3],alpha[4])
93 setElementID(marker,"baza_marker_"..id)
94 local col_dane = split(xmlNodeGetAttribute(atrybut,"col_dane"),",")
95 if (xmlNodeGetAttribute(atrybut,"platnosc") == "PP" and tonumber(cena) >= 100) or (xmlNodeGetAttribute(atrybut,"platnosc") == "GP" and tonumber(cena) >= 30000) then
96 local objekt = createObject(2226,col_dane[1],col_dane[2],col_dane[3])
97 setElementAlpha(objekt,0)
98 setElementCollisionsEnabled(objekt,false)
99 end
100 local col = createColCuboid(col_dane[1],col_dane[2],col_dane[3],col_dane[4],col_dane[5],col_dane[6])
101 for i,v in pairs(getElementsWithinColShape(col,"ped")) do
102 killPed(v)
103 end
104 setElementParent(col,col_shapy)
105 setElementData(col,'pojazdy_naziemne',#getVehicle(1,col))
106 for i,v in pairs(getElementsWithinColShape(col,"vehicle")) do
107 baza_auto[v] = col
108 end
109 setElementData(col,'pojazdy_lotne',#getVehicle(2,col))
110 setElementData(col,'back_pos',split(xmlNodeGetAttribute(atrybut,"back_pos"),","))
111 col_to_marker[col] = marker
112 if kupione == "Tak" then
113 setElementData(marker,"Blip_id",32)
114 if xmlNodeGetAttribute(atrybut,"platnosc") == "PP" then
115 ilosc_zarobku = ilosc_zarobku + tonumber(cena)
116 end
117 else
118 setElementData(marker,"Blip_id",31)
119 end
120 if xmlNodeGetAttribute(atrybut,"platnosc") == "PP" then
121 ilosc_zarobku_max = ilosc_zarobku_max + tonumber(cena)
122 end
123
124 setElementData(marker,"Marker-Opis",cena.." "..xmlNodeGetAttribute(atrybut,"platnosc"))
125 bazy_marker[marker] = {}
126 bazy_marker[marker]["lider"] = lider
127 bazy_marker[marker]['col'] = col
128 bazy_marker[marker]['platnosc'] = xmlNodeGetAttribute(atrybut,"platnosc")
129 bazy_marker[marker]['limity'] = {tonumber(limity_naziemne),tonumber(limity_lotne)}
130 if alpha[1] == 255 then
131 bazy_marker[marker]['Pickup'] = createPickup(pozycje["marker"][1],pozycje["marker"][2],pozycje["marker"][3] + 0.7,3,1272,5000,0)
132 else
133 bazy_marker[marker]['Pickup'] = createPickup(pozycje["marker"][1],pozycje["marker"][2],pozycje["marker"][3] + 0.7,3,1273,5000,0)
134 end
135 local get_id_base
136 if tonumber(id) < 10 then
137 get_id_base = "0"..id
138 else
139 get_id_base = id
140 end
141 for i=1,3 do
142 if bramy[i] == "1" then
143 pozycje["brama"] = split(xmlNodeGetAttribute(atrybut,"brama_"..i.."_dane"),",")
144 local brama = createObject(pozycje['brama'][1],pozycje['brama'][2],pozycje['brama'][3],pozycje['brama'][4],pozycje['brama'][5],pozycje['brama'][6],pozycje['brama'][7])
145 setElementID(brama,"brama_"..get_id_base.."_0"..tostring(i))
146 setElementData(brama,'Status',"Zamknięta")
147 setElementData(brama,'Default-pos',{pozycje['brama'][2],pozycje['brama'][3],pozycje['brama'][4]},false)
148 bazy_marker[marker]["brama_"..i] = true
149 end
150 end
151 bazy_marker[marker]["id"] = id
152 bazy_marker[marker]["grupa"] = grupa
153 bazy_marker[marker]['gracze'] = gracze
154 bazy_marker[marker]["dni"] = dni
155 bazy_marker[marker]["kupione"] = kupione
156 bazy_marker[marker]["cena"] = cena
157 bazy_marker[marker]["typ"] = typ
158 end
159 xmlUnloadFile(file);
160 end
161 end
162 print("* Zarobione pieniÄ…zki z baz: "..ilosc_zarobku.."/"..ilosc_zarobku_max)
163end)
164
165local isMessage = {}
166local timer = {}
167
168--[[
169setTimer(function()
170 for i,v in pairs(sprawdz) do
171 for _,marker in pairs(getElementsByType("marker",resourceRoot)) do
172 local lider = bazy_marker[marker]["lider"]
173 local dni = tonumber(bazy_marker[marker]["dni"])
174 if lider == v and dni > 0 then
175 outputChatBox(bazy_marker[marker]["id"].." : "..dni)
176 end
177 end
178 end
179end,50,1)
180]]
181function zajebSkurwysyna(player)
182 setElementData(player,'blood',-49)
183 if isTimer(timer[player]) then
184 killTimer(timer[player])
185 end
186end
187
188local players_in_col = {}
189
190addEvent("UsunWynikFromBaza",true)
191addEventHandler("UsunWynikFromBaza",resourceRoot,function(plr,dane,typ)
192 local id = dane[1]
193 local xml = xmlLoadFile("bazy/baza_"..id..".xml")
194 local marker = getElementByID("baza_marker_"..id)
195 if xml then
196 if typ == 0 then
197 local atrybut = xmlFindChild(xml,"informacje",0)
198 if atrybut then
199 local gracze = fromJSON(xmlNodeGetAttribute(atrybut,'gracze'))
200 gracze[dane[2]] = nil
201 local konto = getAccount(dane[2])
202 local ides = fromJSON((getAccountData(konto,"Global_Base_Id") or toJSON({})))
203 ides[id] = nil
204 setAccountData(konto,"Global_Base_Id",toJSON(ides))
205 if getAccountPlayer(konto) then
206 setElementData(getAccountPlayer(konto),"Global_Base_Id",toJSON(ides))
207 end
208 xmlNodeSetAttribute(atrybut,"gracze",toJSON(gracze))
209 bazy_marker[marker]['gracze'] = toJSON(gracze)
210 end
211 elseif typ == 1 then
212 local atrybut = xmlFindChild(xml,"informacje",0)
213 if atrybut then
214 local grupa = fromJSON(xmlNodeGetAttribute(atrybut,'grupa'))
215 grupa[dane[2]] = nil
216 xmlNodeSetAttribute(atrybut,"grupa",toJSON(grupa))
217 bazy_marker[marker]['grupa'] = toJSON(grupa)
218 end
219 end
220 xmlSaveFile(xml)
221 xmlUnloadFile(xml)
222 triggerClientEvent(plr,"chujcyckichujcycki",resourceRoot)
223 end
224end)
225
226
227
228
229
230function isVehicleInBase(player,veh)
231 if baza_auto[veh] then
232 local id_marker = col_to_marker[baza_auto[veh]]
233 if not id_marker then return false end
234 local gracze = fromJSON(bazy_marker[id_marker]["gracze"])
235 local grupa = fromJSON(bazy_marker[id_marker]['grupa'])
236 if gracze and not gracze[getElementData(player,'logedin')] or not gracze then
237 return true
238 elseif getElementData(player,'Grupa') and grupa and grupa[getElementData(player,"Grupa").nazwa] or not grupa then
239 return true
240 else
241 return false
242 end
243 end
244 return false
245end
246
247addEventHandler('onColShapeHit',col_shapy,function(hit)
248 local id_marker = col_to_marker[source]
249 if not id_marker then return end
250 local naziemne = getElementData(source,'pojazdy_naziemne') or 0
251 local limit_naziemnych = bazy_marker[id_marker]['limity'][1]
252 local lotne = getElementData(source,'pojazdy_lotne') or 0
253 local limit_lotne = bazy_marker[id_marker]['limity'][2]
254 setElementData(source,"pojazdy_lotne",#getVehicle(2,source))
255 setElementData(source,"pojazdy_naziemne",#getVehicle(1,source))
256 local gracze = fromJSON(bazy_marker[id_marker]["gracze"])
257 local grupa = fromJSON(bazy_marker[id_marker]['grupa'])
258 if hit and getElementType(hit) == "player" then
259 players_in_col[hit] = source
260 end
261 if hit and getElementType(hit)=='player' then
262 if getElementData(hit,"Administrator-Open") then return end
263
264 --[[if getPedOccupiedVehicle(hit) and getVehicleOccupant(getPedOccupiedVehicle(hit),0) then
265 if isTimer(chwilowe_pojazdy[getPedOccupiedVehicle(hit)]) then return end
266 if getVehicleType(getPedOccupiedVehicle(hit))=="Automobile" or getVehicleType(getPedOccupiedVehicle(hit))=="Quad" or getVehicleType(getPedOccupiedVehicle(hit))=="Bike" then
267 if naziemne+1>limit_naziemnych then
268 outputChatBox("Przekroczyłeś limit pojazdów naziemnych!",hit,255,0,0)
269 setElementFrozen(getPedOccupiedVehicle(hit),false)
270 local back_pos = getElementData(source,'back_pos')
271 setElementPosition(getPedOccupiedVehicle(hit),unpack(back_pos))
272 setElementVelocity(getPedOccupiedVehicle(hit),0,0,0)
273 setElementRotation(getPedOccupiedVehicle(hit),0,0,0)
274 --pojazdy.naziemne[1] = #getVehicle(1) + 1
275 setElementData(source,"pojazdy_naziemne",#getVehicle(1,source))
276 setVehicleDamageProof(getPedOccupiedVehicle(hit),false)
277 return
278 else
279 --pojazdy.naziemne[1] = #getVehicle(1) + 1
280 setElementData(source,"pojazdy_naziemne",#getVehicle(1,source) + 1)
281 setVehicleDamageProof(getPedOccupiedVehicle(hit),true)
282 end
283
284 elseif getVehicleType(getPedOccupiedVehicle(hit))=="Helicopter" or getVehicleType(getPedOccupiedVehicle(hit))=="Plane" then
285 if lotne+1>limit_lotne then
286 outputChatBox("Przekroczyłeś limit pojazdów latających!",hit,255,0,0)
287 setElementFrozen(getPedOccupiedVehicle(hit),false)
288 local back_pos = getElementData(source,'back_pos')
289 setElementPosition(getPedOccupiedVehicle(hit),unpack(back_pos))
290 --pojazdy.lotne[1] = #getVehicle(2) + 1
291 setElementVelocity(getPedOccupiedVehicle(hit),0,0,0)
292 setElementData(source,"pojazdy_lotne",#getVehicle(2,source))
293 setElementRotation(getPedOccupiedVehicle(hit),0,0,0)
294 setVehicleDamageProof(getPedOccupiedVehicle(hit),false)
295 return
296 else
297 setElementData(source,"pojazdy_lotne",#getVehicle(2,source) + 1)
298 setVehicleDamageProof(getPedOccupiedVehicle(hit),true)
299 end
300 end
301 end]]
302
303 if gracze and gracze[getElementData(hit,'logedin')] then
304 outputChatBox("* Witamy w bazie! Posiadasz pojazdĂłw latajÄ…cych: "..getElementData(source,'pojazdy_lotne').."/"..limit_lotne..", pojazdĂłw naziemnych: "..getElementData(source,'pojazdy_naziemne').."/"..limit_naziemnych,hit,200,200,0)
305 if gracze[getElementData(hit,"logedin")]['tenty'] == "TAK" then
306 setElementData(hit,'Moze-Otwierac',{source,bazy_marker[id_marker]["id"]})
307 else
308 if not isMessage[hit] then
309 isMessage[hit] = true
310 outputChatBox("* Nie masz uprawnień do otwierania namiotów, gdy rozłożysz namiot każdy będzie go mógł otwierać",hit,255,255,255)
311 end
312 end
313 return
314 elseif getElementData(hit,'Grupa') and grupa and grupa[getElementData(hit,"Grupa").nazwa] then
315 outputChatBox("* Witamy w bazie! Posiadasz pojazdĂłw latajÄ…cych: "..getElementData(source,'pojazdy_lotne').."/"..limit_lotne..", pojazdĂłw naziemnych: "..getElementData(source,'pojazdy_naziemne').."/"..limit_naziemnych,hit,200,200,0) return
316 else
317 outputChatBox("#ddddddMasz 3 sekundy, aby opuścić tą strefę!",hit,255,0,0,true)
318 if isTimer(timer[hit]) then return end
319 timer[hit] = setTimer(zajebSkurwysyna,3000,0,hit)
320 end
321
322 elseif hit and getElementType(hit)=='vehicle' then
323 --if getVehicleOccupant(hit,0) then return end
324 local kierowca = getVehicleOccupant(hit,0)
325 if getVehicleType(hit)=="Automobile" or getVehicleType(hit)=="Quad" or getVehicleType(hit)=="Bike" then
326 if naziemne+1>limit_naziemnych then
327 if kierowca then
328 outputChatBox("Przekroczyłeś limit pojazdów naziemnych!",kierowca,255,0,0)
329 end
330 setElementFrozen(hit,false)
331 setVehicleDamageProof(hit,false)
332 local back_pos = getElementData(source,'back_pos')
333 local rx,ry,rz = getElementRotation(hit)
334 setElementRotation(hit,0,0,rz)
335 setElementPosition(hit,unpack(back_pos))
336 setElementData(source,"pojazdy_naziemne",#getVehicle(1,source))
337 return
338 else
339 setElementData(source,"pojazdy_naziemne",#getVehicle(1,source))
340 baza_auto[hit] = source
341 setVehicleDamageProof(hit,true)
342 end
343 elseif getVehicleType(hit)=="Helicopter" or getVehicleType(hit)=="Plane" then
344 if lotne+1>limit_lotne then
345 if kierowca then
346 outputChatBox("Przekroczyłeś limit pojazdów lotnych!",kierowca,255,0,0)
347 end
348 setVehicleDamageProof(hit,false)
349 setElementFrozen(hit,false)
350 local back_pos = getElementData(source,'back_pos')
351 setElementPosition(hit,unpack(back_pos))
352 local rx,ry,rz = getElementRotation(hit)
353 setElementRotation(hit,0,0,rz)
354 setElementData(source,"pojazdy_lotne",#getVehicle(2,source))
355 return
356 else
357 setElementData(source,"pojazdy_lotne",#getVehicle(2,source) + 1)
358 setVehicleDamageProof(hit,true)
359 baza_auto[hit] = source
360 end
361 end
362 elseif hit and getElementType(hit) == "ped" then
363 killPed(hit)
364 end
365end)
366
367addEventHandler('onPlayerVehicleExit',root,function(veh,seat)
368 if players_in_col[source] then
369 if checkIsCanDo(source,players_in_col[source]) then
370 if seat == 0 then
371 setElementFrozen(veh,true)
372 fixVehicle(veh)
373 end
374 else
375 zajebSkurwysyna(source)
376 end
377 end
378end)
379
380function checkIsCanDo(player,col)
381 local id_marker = col_to_marker[col]
382 if not id_marker then return end
383 local gracze = fromJSON(bazy_marker[id_marker]["gracze"])
384 local grupa = fromJSON(bazy_marker[id_marker]['grupa'])
385 if getElementData(player,"Administrator-Open") then return true end
386 if getElementData(player,'Grupa') and grupa and grupa[getElementData(player,"Grupa").nazwa] then
387 return true
388 elseif gracze and gracze[getElementData(player,'logedin')] then
389 return true
390 end
391 return false
392end
393
394addEventHandler('onPlayerVehicleEnter',root,function(veh,seat)
395 setTimer(function(source)
396 if players_in_col[source] then
397 if checkIsCanDo(source,players_in_col[source]) then
398 if seat == 0 then
399 setElementFrozen(veh,false)
400 end
401 else
402 zajebSkurwysyna(source)
403 end
404 end
405 end,50,1,source)
406end)
407
408addEventHandler('onColShapeLeave',col_shapy,function(hit)
409 if hit and getElementType(hit)=='player' then
410 if getElementData(hit,"Administrator-Open") then return end
411 players_in_col[hit] = nil
412 if getPedOccupiedVehicle(hit) and getPedOccupiedVehicleSeat(hit)==0 then
413 if getVehicleType(getPedOccupiedVehicle(hit))=="Automobile" or getVehicleType(getPedOccupiedVehicle(hit))=="Quad" or getVehicleType(getPedOccupiedVehicle(hit))=="Bike" then
414 setElementData(source,"pojazdy_naziemne",#getVehicle(1,source))
415 elseif getVehicleType(getPedOccupiedVehicle(hit))=="Helicopter" or getVehicleType(getPedOccupiedVehicle(hit))=="Plane" then
416 setElementData(source,"pojazdy_lotne",#getVehicle(2,source))
417 end
418 setVehicleDamageProof(getPedOccupiedVehicle(hit),false)
419 baza_auto[getPedOccupiedVehicle(hit)] = nil
420 end
421 setElementData(hit,'Moze-Otwierac',nil)
422 if isTimer(timer[hit]) then
423 killTimer(timer[hit])
424 end
425 elseif hit and getElementType(hit)=='vehicle' then
426 if getVehicleOccupant(hit,0) then return end
427 for i,player in pairs(getVehicleOccupants(hit)) do
428 players_in_col[player] = nil
429 if not isTimer(timer[player]) then return end
430 killTimer(timer[player])
431 end
432 if getVehicleType(hit)=="Automobile" or getVehicleType(hit)=="Quad" or getVehicleType(hit)=="Bike" then
433 setElementData(source,"pojazdy_naziemne",#getVehicle(1,source) - 1)
434 elseif getVehicleType(hit)=="Helicopter" or getVehicleType(hit)=="Plane" then
435 setElementData(source,"pojazdy_lotne",#getVehicle(2,source) - 1)
436 end
437 setVehicleDamageProof(hit,false)
438 baza_auto[hit] = nil
439 end
440end)
441
442
443addEvent("Base_SetDostep",true)
444addEventHandler("Base_SetDostep",resourceRoot,function(player,konto,typ,tabela,id_bazy)
445 local file = xmlLoadFile("bazy/baza_"..id_bazy..".xml")
446 local marker = getElementByID("baza_marker_"..id_bazy)
447 if file then
448 local atrybut = xmlFindChild(file,'informacje',0)
449 if atrybut then
450 local gracze = fromJSON(xmlNodeGetAttribute(atrybut,'gracze'))
451 if not gracze[konto] then
452 xmlUnloadFile(file)
453 outputChatBox("* Wystąpił problem skontaktuj się z administracją!",player,255,255,255)
454 return
455 end
456 gracze[konto][tabela] = typ
457 xmlNodeSetAttribute(atrybut,"gracze",toJSON(gracze))
458 bazy_marker[marker]["gracze"] = toJSON(gracze)
459 end
460 triggerClientEvent(player,"chujcyckichujcycki",resourceRoot)
461 outputChatBox("* Pomyślnie zmieniłeś ustawienia!",player,255,255,255)
462 xmlSaveFile(file)
463 xmlUnloadFile(file)
464 end
465end)
466
467addEvent("KupBaze",true)
468addEventHandler("KupBaze",resourceRoot,function(plr)
469 if not getElementData(plr,'Dane_bazy') then outputChatBox("* Wystąpił problem spróbuj ponownie za 1 minute!",plr,255,255,255) return end
470 if not getPlayerAccount(plr) then outputChatBox("* Wystąpił problem spróbuj ponownie za 1 minute!",plr,255,255,255) return end
471
472 local tablica = getElementData(plr,'Dane_bazy')
473 if (getElementData(plr,tablica['platnosc']) or 0)<tonumber(tablica['cena']) then
474 outputChatBox("* Nie posiadasz wystarczajÄ…co "..tablica['platnosc'],plr,255,255,255)
475 return
476 end
477 local file = xmlLoadFile("bazy/baza_"..tablica["id"]..".xml")
478 if file then
479 local atrybut = xmlFindChild(file,"informacje",0)
480 if atrybut then
481 if xmlNodeGetAttribute(atrybut,"kupione") ~= "Tak" then
482 local konto = getAccountName(getPlayerAccount(plr))
483 local JSON = {}
484 JSON[konto] = {}
485 for i=1,3 do
486 if tablica['brama_'..i] then
487 JSON[konto]["brama_"..i] = "TAK"
488 end
489 end
490 JSON[konto]['tenty'] = "TAK"
491 local bases_id = fromJSON(getElementData(plr,"Global_Base_Id"))
492 bases_id[tablica["id"]] = true
493 setElementData(plr,"Global_Base_Id",toJSON(bases_id))
494 xmlNodeSetAttribute(atrybut,'lider',konto)
495 xmlNodeSetAttribute(atrybut,'kupione',"Tak")
496 xmlNodeSetAttribute(atrybut,'dni',"30")
497 xmlNodeSetAttribute(atrybut,'gracze',toJSON(JSON))
498 xmlNodeSetAttribute(atrybut,'grupa',toJSON({}))
499 bazy_marker[tablica["marker"]]["lider"] = konto
500 bazy_marker[tablica["marker"]]["kupione"] = "Tak"
501 bazy_marker[tablica["marker"]]["dni"] = "30"
502 bazy_marker[tablica["marker"]]["grupa"] = toJSON({})
503 bazy_marker[tablica["marker"]]["gracze"] = toJSON(JSON)
504 setElementData(tablica["marker"],"Blip_id",32)
505 setMarkerColor(tablica["marker"],255,0,0,0)
506 setPickupType(bazy_marker[tablica["marker"]]["Pickup"],3,1272,0)
507 setElementData(plr,tablica['platnosc'],(getElementData(plr,tablica['platnosc']) or 0)-tablica["cena"])
508 outputChatBox("* Zakupiłeś bazę! Automatycznie została opłacona na 30 dni!",plr,255,255,255)
509 triggerClientEvent(plr,"PokazGUI",resourceRoot,false)
510 setElementData(plr,"Dane_bazy",nil)
511 end
512 end
513 xmlSaveFile(file)
514 xmlUnloadFile(file)
515 end
516end)
517
518function math.round(number)
519 return tonumber(string.format("%.0f", tostring(number)))
520end
521
522addEvent("SellBaze",true)
523addEventHandler("SellBaze",resourceRoot,function(plr)
524 if not getElementData(plr,'Dane_bazy') then outputChatBox("* Wystąpił problem spróbuj ponownie za 1 minute!",plr,255,255,255) return end
525 if not getPlayerAccount(plr) then outputChatBox("* Wystąpił problem spróbuj ponownie za 1 minute!",plr,255,255,255) return end
526 local tablica = getElementData(plr,'Dane_bazy')
527 local file = xmlLoadFile("bazy/baza_"..tablica["id"]..".xml")
528 if file then
529 local atrybut = xmlFindChild(file,"informacje",0)
530 if atrybut then
531 if xmlNodeGetAttribute(atrybut,"kupione") ~= "Nie" then
532 local konto = getAccountName(getPlayerAccount(plr))
533 if konto == tablica['lider'] then
534 local bases_id = fromJSON((getElementData(plr,"Global_Base_Id") or {}))
535 bases_id[tablica["id"]] = nil
536 local di3n31 = tonumber(xmlNodeGetAttribute(atrybut,'dni'))
537 local cena = tonumber(xmlNodeGetAttribute(atrybut,'cena'))
538 setElementData(plr,"Global_Base_Id",toJSON(bases_id))
539 xmlNodeSetAttribute(atrybut,'lider',"-")
540 xmlNodeSetAttribute(atrybut,'kupione',"Nie")
541 xmlNodeSetAttribute(atrybut,'dni',"-")
542 xmlNodeSetAttribute(atrybut,'grupa',"")
543 xmlNodeSetAttribute(atrybut,'gracze',"")
544 removeAllVehicles(bazy_marker[tablica["marker"]]["col"])
545 local punkty_otrzymane = math.round(((cena/2)/30) * di3n31)
546 for i,v in pairs(fromJSON(bazy_marker[tablica["marker"]]["gracze"])) do
547 local konto = getAccount(i)
548 local ides = fromJSON(getAccountData(konto,"Global_Base_Id"))
549 ides[bazy_marker[tablica["marker"]]["id"]] = nil
550 setAccountData(konto,"Global_Base_Id",toJSON(ides))
551 end
552 bazy_marker[tablica["marker"]]["lider"] = "-"
553 bazy_marker[tablica["marker"]]["kupione"] = "Nie"
554 bazy_marker[tablica["marker"]]["dni"] = "-"
555 bazy_marker[tablica["marker"]]["grupa"] = ""
556 bazy_marker[tablica["marker"]]["gracze"] = ""
557 setElementData(plr,tablica["platnosc"],(getElementData(plr,tablica["platnosc"]) or 0) + punkty_otrzymane)
558 outputChatBox("* Sprzedałeś bazę! Otrzymałeś: "..punkty_otrzymane.." "..tablica["platnosc"],plr,255,255,255)
559 setElementData(tablica["marker"],"Blip_id",31)
560 setMarkerColor(tablica["marker"],0,255,0,0)
561 setPickupType(bazy_marker[tablica["marker"]]["Pickup"],3,1273,0)
562 triggerClientEvent(plr,"PokazGUI",resourceRoot,false)
563 setElementData(plr,"Dane_bazy",nil)
564 local get_id_base
565 if tonumber(tablica["id"]) < 10 then
566 get_id_base = "0"..tablica["id"]
567 else
568 get_id_base = tablica["id"]
569 end
570 for i=1,3 do
571 if tablica["brama_"..i] then
572 local brama = getElementByID("brama_"..get_id_base.."_0"..i)
573 local data = getElementData(brama,'Status')
574 local pos = getElementData(brama,"Default-pos",false)
575 setElementData(brama,'Status',"Zamknięta")
576 moveObject(brama,500,pos[1],pos[2],pos[3])
577 end
578 end
579
580 else
581 outputChatBox("* Nie jesteś właścicielem tej bazy!",plr,255,255,255)
582 end
583 end
584 end
585 xmlSaveFile(file)
586 xmlUnloadFile(file)
587 end
588end)
589
590addEvent("OplacBaze",true)
591addEventHandler("OplacBaze",resourceRoot,function(plr)
592 if not getElementData(plr,'Dane_bazy') then outputChatBox("* Wystąpił problem spróbuj ponownie za 1 minute!",plr,255,255,255) return end
593 if not getPlayerAccount(plr) then outputChatBox("* Wystąpił problem spróbuj ponownie za 1 minute!",plr,255,255,255) return end
594 local tablica = getElementData(plr,'Dane_bazy')
595 if (getElementData(plr,tablica["platnosc"]) or 0)< (tonumber(tablica['cena'])/2) then
596 outputChatBox("* Nie posiadasz wystarczajÄ…co "..tablica["platnosc"],plr,255,255,255)
597 return
598 end
599 local file = xmlLoadFile("bazy/baza_"..tablica["id"]..".xml")
600 if file then
601 local atrybut = xmlFindChild(file,"informacje",0)
602 if atrybut then
603 if xmlNodeGetAttribute(atrybut,"kupione") ~= "Nie" then
604 local konto = getAccountName(getPlayerAccount(plr))
605 if konto == tablica['lider'] then
606 xmlNodeSetAttribute(atrybut,'dni',tostring(tonumber(bazy_marker[tablica["marker"]]["dni"]) + 30))
607 setElementData(plr,tablica["platnosc"],(getElementData(plr,tablica["platnosc"]) or 0) - tonumber(tablica['cena'])/2)
608 bazy_marker[tablica["marker"]]["dni"] = tostring(tonumber(bazy_marker[tablica["marker"]]["dni"]) + 30)
609 outputChatBox("* Opłaciłeś bazę! Straciłeś: "..(tonumber(tablica['cena'])).." "..tablica["platnosc"],plr,255,255,255)
610 triggerClientEvent(plr,"PokazGUI",resourceRoot,false)
611 setElementData(plr,"Dane_bazy",nil)
612 else
613 outputChatBox("* Nie jesteś właścicielem tej bazy!",plr,255,255,255)
614 end
615 end
616 end
617 xmlSaveFile(file)
618 xmlUnloadFile(file)
619 end
620end)
621
622
623addEventHandler("onMarkerHit",resourceRoot,function(hit)
624 if hit and getElementType(hit) == "player" then
625 if isPedInVehicle(hit) then return end
626 if not bazy_marker[source] then return end
627 local konto = getPlayerAccount(hit)
628 if not konto then return end
629 local lider = bazy_marker[source]["lider"]
630 local admin = getElementData(hit,"Administrator-Open")
631 if not admin and bazy_marker[source]['kupione'] == "Tak" and lider ~= getAccountName(konto) then
632 outputChatBox("* Baza została już kupiona!",hit,255,255,255)
633 return
634 end
635 local zgodnosc = false
636 if bazy_marker[source]['kupione'] == "Tak" and lider == getAccountName(konto) then
637 zgodnosc = true
638 end
639 bazy_marker[source]["marker"] = source
640 triggerClientEvent(hit,"PokazGUI",resourceRoot,true,bazy_marker[source],zgodnosc)
641 setElementData(hit,"Dane_bazy",bazy_marker[source])
642 end
643end)
644
645addEventHandler("onMarkerLeave",resourceRoot,function(hit)
646 if hit and getElementType(hit) == "player" then
647 if not bazy_marker[source] then return end
648 triggerClientEvent(hit,"PokazGUI",resourceRoot,false)
649 setElementData(hit,"Dane_bazy",nil)
650 end
651end)
652
653local tickers = {}
654local last_base_id = {}
655local last_data = {}
656
657addEventHandler("onPlayerLogin",root,function()
658 local data = getAccountData(getPlayerAccount(source),"Global_Base_Id")
659 if not data then
660 setElementData(source,"Global_Base_Id",toJSON({}))
661 else
662 setElementData(source,"Global_Base_Id",data)
663 end
664end)
665
666addEventHandler("onPlayerQuit",root,function()
667 if not getElementData(source,'logedin') then return end
668 local data = getElementData(source,"Global_Base_Id")
669 if data then
670 setAccountData(getPlayerAccount(source),"Global_Base_Id",data)
671 else
672 setAccountData(getPlayerAccount(source),"Global_Base_Id",toJSON({}))
673 end
674end)
675
676function checkIsAdded(t,konto)
677 t = fromJSON(t)
678 if t[konto] then
679 return true
680 end
681 return false
682end
683
684function openPanel (player)
685 if not getElementData(player,'logedin') then return end
686
687 local baza = fromJSON((getElementData(player,"Global_Base_Id") or {}))
688 if last_base_id[player] and last_base_id[player] ~= baza then
689 tickers[player] = nil
690 end
691 last_base_id[player] = baza
692 local refreshed_table = {}
693 local are_lider = false
694 if not tickers[player] or getTickCount()-tickers[player] > 1 then
695 local konto = getAccountName(getPlayerAccount(player))
696 for i,v in pairs(baza) do
697 local file = xmlLoadFile("bazy/baza_"..i..".xml")
698 if file then
699 local atrybut = xmlFindChild(file,'informacje',0)
700 if atrybut then
701 local baza_kupiona = xmlNodeGetAttribute(atrybut,'kupione')
702 local players = xmlNodeGetAttribute(atrybut,'gracze')
703 if players == "" then
704 players = toJSON({})
705 end
706 if not checkIsAdded(players,getElementData(player,"logedin")) then
707 baza[i] = nil
708 setElementData(player,"Global_Base_Id",toJSON(baza))
709 end
710 if baza_kupiona == "Tak" and checkIsAdded(players,getElementData(player,"logedin")) then
711 table.insert(refreshed_table,{
712 id = xmlNodeGetAttribute(atrybut,'id_bazy'),
713 dni = xmlNodeGetAttribute(atrybut,'dni'),
714 lider = xmlNodeGetAttribute(atrybut,'lider'),
715 gracze = players,
716 grupa = xmlNodeGetAttribute(atrybut,'grupa') or toJSON({}),
717 bramy = {xmlNodeGetAttribute(atrybut,'brama_1'),xmlNodeGetAttribute(atrybut,'brama_2'),xmlNodeGetAttribute(atrybut,'brama_3')},
718 player_lider = xmlNodeGetAttribute(atrybut,'lider')
719 })
720 elseif baza_kupiona == "Nie" and checkIsAdded(players,getElementData(player,"logedin")) then
721 baza[i] = nil
722 setElementData(player,"Global_Base_Id",toJSON(baza))
723 end
724 end
725 xmlUnloadFile(file)
726 end
727 end
728 tickers[player] = getTickCount() + 10000
729 else
730 triggerClientEvent(player,"openBasePanel",resourceRoot,last_data[player][1])
731 return
732 end
733 last_data[player] = {refreshed_table}
734 triggerClientEvent(player,"openBasePanel",resourceRoot,last_data[player][1])
735end
736
737
738addEvent("Base_add_elements",true)
739addEventHandler("Base_add_elements",resourceRoot,function(player,data,element)
740 if not data then return end
741 if not element[1] then return end
742 local marker = getElementByID("baza_marker_"..data[1],0)
743 local xml = xmlLoadFile("bazy/baza_"..data[1]..".xml")
744 if xml then
745 local atrybut = xmlFindChild(xml,"informacje",0)
746 if atrybut then
747 if data[2] == "gracze" then
748 local find_player = getPlayerFromName(element[1])
749 if not find_player then
750 outputChatBox("* Nie ma takiego gracza",player,255,255,255)
751 xmlUnloadFile(xml)
752 return
753 end
754 if not getElementData(find_player,'logedin') then
755 outputChatBox("* Gracz nie jest zalogowany!",player,255,255,255)
756 xmlUnloadFile(xml)
757 return
758 end
759 local wartosc = fromJSON(xmlNodeGetAttribute(atrybut,"gracze"))
760 wartosc[getElementData(find_player,'logedin')] = {}
761 for i=1,3 do
762 if xmlNodeGetAttribute(atrybut,'brama_'..i) then
763 wartosc[getElementData(find_player,'logedin')]["brama_"..i] = "NIE"
764 end
765 end
766 wartosc[getElementData(find_player,'logedin')]["tenty"] = "NIE"
767 bazy_marker[marker]["gracze"] = toJSON(wartosc)
768 xmlNodeSetAttribute(atrybut,'gracze',toJSON(wartosc))
769 local bases_id = fromJSON((getElementData(find_player,"Global_Base_Id") or {}))
770 bases_id[bazy_marker[marker]["id"]] = true
771 setElementData(find_player,"Global_Base_Id",toJSON(bases_id))
772 elseif data[2] == "grupa" then
773 local grupa = element[1]
774 local grupy = fromJSON(xmlNodeGetAttribute(atrybut,"grupa"))
775 bazy_marker[marker]["grupa"] = toJSON(grupy)
776 grupy[grupa] = true
777 xmlNodeSetAttribute(atrybut,"grupa",toJSON(grupy))
778 end
779 end
780 xmlSaveFile(xml)
781 xmlUnloadFile(xml)
782 triggerClientEvent(player,"chujcyckichujcycki",resourceRoot)
783 else
784 outputChatBox("* Wystąpił problem skontaktuj się z administracja!",player,255,255,255)
785 end
786end)
787
788local anty_cpu = {}
789
790addEvent("Base_OpenGate",true)
791addEventHandler("Base_OpenGate",resourceRoot,function(player,data,id_bramy)
792 if not data or not data[1] then return end
793 if anty_cpu[player] and getTickCount()-anty_cpu[player]<1 then
794 return
795 end
796 local gracze = fromJSON(data[2])
797 local konto = getElementData(player,'logedin')
798 if not gracze[konto] then return end
799 if not gracze[konto]["brama_"..id_bramy] or gracze[konto]["brama_"..id_bramy] ~= "TAK" then
800 outputChatBox("* Nie posiadasz uprawnień, aby otwierać tą bramę!",player,255,255,255)
801 return
802 end
803 anty_cpu[player] = getTickCount() + 500
804 local get_id_base
805 if tonumber(data[1]) < 10 then
806 get_id_base = "0"..data[1]
807 else
808 get_id_base = data[1]
809 end
810 local brama = getElementByID("brama_"..get_id_base.."_0"..id_bramy)
811 local id_Bazy = data[1]
812 local data = getElementData(brama,'Status')
813 local pos = getElementData(brama,"Default-pos",false)
814 if data == "Otwarta" then
815 setElementData(brama,'Status',"Zamknięta")
816 if getElementModel(brama) == 10828 then
817 local rotacja,_,_ = getElementRotation(brama)
818 if rotacja > 88 and rotacja < 92 then
819 rotacja = 90
820 end
821 if rotacja == 90 then
822 moveObject(brama,5000,pos[1],pos[2],pos[3])
823 else
824 moveObject(brama,500,pos[1],pos[2],pos[3])
825 end
826 else
827 moveObject(brama,500,pos[1],pos[2],pos[3])
828 end
829 data = "Zamknięta"
830 else
831 data = "Otwarta"
832 setElementData(brama,'Status',"Otwarta")
833 if getElementModel(brama) == 10828 then
834 local rotacja,_,_ = getElementRotation(brama)
835 if rotacja > 88 and rotacja < 92 then
836 rotacja = 90
837 end
838 if rotacja == 90 then
839 moveObject(brama,9000,pos[1],pos[2],pos[3]-35)
840 else
841 moveObject(brama,500,pos[1],pos[2],pos[3]-15)
842 end
843 else
844 moveObject(brama,500,pos[1],pos[2],pos[3]-10)
845 end
846 end
847 outputChatBox("* Obecny status bramy: "..data,player,255,255,255)
848end)
849
850addCommandHandler("baza.open",function(player,cmd,id_bazy,ktora_brama)
851 if not id_bazy or not tonumber(id_bazy) then return end
852 if not ktora_brama or not tonumber(ktora_brama) then return end
853 ktora_brama = tonumber(ktora_brama)
854 local file = xmlLoadFile("bazy/baza_"..id_bazy..".xml")
855 if file then
856 local atrybut = xmlFindChild(file,"informacje",0)
857 if atrybut then
858 local brama = xmlNodeGetAttribute(atrybut,"brama_"..ktora_brama)
859 if brama == "1" then
860 local gracze = fromJSON(xmlNodeGetAttribute(atrybut,"gracze")) or {}
861 if gracze == "" then
862 gracze = {}
863 end
864 local lider = xmlNodeGetAttribute(atrybut,"lider")
865 if (gracze[getElementData(player,"logedin")] and gracze[getElementData(player,"logedin")]["brama_"..ktora_brama] == "TAK") or lider == getElementData(player,"logedin") then
866 triggerEvent("Base_OpenGate",resourceRoot,player,{tonumber(id_bazy),toJSON(gracze)},tonumber(ktora_brama))
867 end
868 xmlUnloadFile(file)
869 else
870 xmlUnloadFile(file)
871 end
872 end
873 end
874end)
875
876local tp_veh = {-3609.5712890625,68.0576171875,-0.55000001192093}
877
878function removeAllVehicles(cuboid)
879 local back_pos = getElementData(cuboid,'back_pos')
880 for i,v in pairs(getElementsWithinColShape(cuboid)) do
881 if getElementType(v) == "player" then
882 setElementPosition(v,unpack(back_pos))
883 elseif getElementType(v) == "vehicle" then
884 setElementFrozen(v,false)
885 setVehicleDamageProof(v,true)
886 setElementPosition(v,unpack(tp_veh))
887 elseif getElementType(v) == "object" then
888 if getElementData(v,'parent') then
889 destroyElement(getElementData(v,'parent'))
890 destroyElement(v)
891 end
892 end
893 end
894end
895
896
897
898function removeBaseOwner(marker,atrybut)
899 local lider = bazy_marker[marker]['lider']
900 local machinKurwa = getAccountPlayer(getAccount(lider))
901 local global_id = getAccountData(getAccount(lider),"Global_Base_Id") or {}
902 if machinKurwa then
903 outputChatBox("* Nie opłaciłeś bazy, została ona usunięta!",machinKurwa,255,255,255)
904 local bases_id = fromJSON((getElementData(machinKurwa,"Global_Base_Id") or {}))
905 bases_id[bazy_marker[marker]["id"]] = nil
906 setElementData(machinKurwa,"Global_Base_Id",toJSON(bases_id))
907 setPickupType(bases_id[bazy_marker[marker]["Pickup"]],3,1273,0)
908 else
909 local bases_id = fromJSON(global_id) or {}
910 bases_id[bazy_marker[marker]["id"]] = nil
911 setAccountData(getAccount(lider),"Global_Base_Id",toJSON(bases_id))
912 setPickupType(bases_id[bazy_marker[marker]["Pickup"]],3,1273,0)
913 end
914 setElementData(marker,"Blip_id",31)
915 setMarkerColor(marker,0,255,0,0)
916
917 for i,v in pairs(fromJSON(bazy_marker[marker]["gracze"])) do
918 local konto = getAccount(i)
919 if konto then
920 local ides = fromJSON((getAccountData(konto,"Global_Base_Id") or {}))
921 ides[bazy_marker[marker]["id"]] = nil
922 setAccountData(konto,"Global_Base_Id",toJSON(ides))
923 end
924 end
925 bazy_marker[marker]["lider"] = "-"
926 bazy_marker[marker]["kupione"] = "Nie"
927 bazy_marker[marker]["dni"] = "-"
928 bazy_marker[marker]["grupa"] = ""
929 bazy_marker[marker]["gracze"] = ""
930 xmlNodeSetAttribute(atrybut,'lider',"-")
931 xmlNodeSetAttribute(atrybut,'kupione',"Nie")
932 xmlNodeSetAttribute(atrybut,'dni',"-")
933 xmlNodeSetAttribute(atrybut,'grupa',"")
934 xmlNodeSetAttribute(atrybut,'gracze',"")
935end
936
937function removeOneDay()
938 for i=1,99999 do
939 if not fileExists("bazy/baza_"..i..".xml") then break end
940 local file = xmlLoadFile("bazy/baza_"..i..".xml")
941 if file then
942 local atrybut = xmlFindChild(file,'informacje',0)
943 if atrybut then
944 local id = xmlNodeGetAttribute(atrybut,'id_bazy')
945 local marker = getElementByID("baza_marker_"..id,0)
946 if marker and bazy_marker[marker]['kupione'] == "Tak" then
947 bazy_marker[marker]["dni"] = tonumber(bazy_marker[marker]["dni"]) - 1
948 if tonumber(bazy_marker[marker]["dni"]) <= 0 then
949 removeAllVehicles(bazy_marker[marker]['col'])
950 removeBaseOwner(marker,atrybut)
951 end
952 xmlNodeSetAttribute(atrybut,'dni',bazy_marker[marker]["dni"])
953 end
954 end
955 xmlSaveFile(file)
956 xmlUnloadFile(file)
957 end
958 end
959end
960
961--addCommandHandler("removeOneDay",removeOneDay)
962
963local time_checked = false
964
965
966setTimer(function()
967 local time = getRealTime().hour
968 if time == 0 then
969 if not time_checked then
970 time_checked = true
971 removeOneDay()
972 end
973 else
974 time_checked = false
975 end
976end,60000,0)
977
978for i,v in pairs(getElementsByType("player")) do
979 bindKey(v,"F2","down",openPanel)
980end
981
982addEventHandler('onPlayerJoin',root,function()
983 bindKey(source,"F2","down",openPanel)
984end)
985--[[
986setTimer(function()
987 for _,marker in pairs(getElementsByType("marker",resourceRoot)) do
988 if bazy_marker[marker]['platnosc'] == "GP" then
989 local id = bazy_marker[marker]['id']
990 local xml = xmlLoadFile("bazy/baza_"..id..".xml")
991 local child = xmlFindChild(xml,"informacje",0)
992 local cena = xmlNodeGetAttribute(child,"cena")
993 xmlNodeSetAttribute(child,"cena",tonumber(cena) * 3.5)
994 xmlSaveFile(xml)
995 xmlUnloadFile(xml)
996 end
997 end
998end,50,1)]]
999--[[
1000setTimer(function()
1001 for _,marker in pairs(getElementsByType("marker",resourceRoot)) do
1002 if bazy_marker[marker]['platnosc'] == "PP" then
1003 local id = bazy_marker[marker]['id']
1004 local xml = xmlLoadFile("bazy/baza_"..id..".xml")
1005 local child = xmlFindChild(xml,"informacje",0)
1006 local cena = xmlNodeGetAttribute(child,"cena")
1007 xmlNodeSetAttribute(child,"cena",tonumber(cena) * 0.7)
1008 xmlSaveFile(xml)
1009 xmlUnloadFile(xml)
1010 end
1011 end
1012end,50,1)]]
1013
1014function Bases_GetAllBases()
1015 local tabela = {}
1016 for i,v in pairs(getElementsByType('marker',resourceRoot)) do
1017 local x,y = getElementPosition(v)
1018 local lider = bazy_marker[v]["lider"] or "Brak"
1019 local cena = bazy_marker[v]["cena"] or 9999999
1020 local blip = (bazy_marker[v]["kupione"] == "Tak" and 32)
1021 if bazy_marker[v]['kupione'] == "Nie" then
1022 lider = "Brak"
1023 blip = 31
1024 end
1025 table.insert(tabela,{x,y,blip,lider,cena,bazy_marker[v]["platnosc"]})
1026 end
1027 if #tabela>0 then
1028 return tabela
1029 end
1030 return false
1031end
1032--[[
1033for i,v in pairs(getElementsByType("object",resourceRoot)) do
1034 createBlipAttachedTo(v,34)
1035end
1036]]
1037
1038function doBaseBackup()
1039 local tajm = getRealTime()
1040 local text = (1900 + tajm.year).."-"..(tajm.month + 1).."-"..(tajm.monthday).."-"..tajm.hour
1041 for i=1,9999 do
1042 if fileExists("bazy/baza_"..i..".xml") then
1043 fileCopy("bazy/baza_"..i..".xml","backupy/"..text.."/".."/baza_"..i..".xml",true)
1044 else
1045 break
1046 end
1047 end
1048end
1049-- doBaseBackup()
1050setTimer(doBaseBackup,3600000 * 24,0)
1051--[[
1052setTimer(function()
1053 for i,v in pairs(bazy_marker) do
1054 local konto = getAccount(v["lider"])
1055 if getAccountData(konto,"Grupa") then
1056 local grupa = fromJSON(getAccountData(konto,"Grupa"))
1057 if grupa.nazwa == "undead" then
1058 outputChatBox(v["id"])
1059 end
1060 end
1061 end
1062end,500,1)]]
1063
1064
1065
1066function seachDelTarget(id)
1067 for i,v in pairs(bazy_marker) do
1068 if v["id"] == id then
1069 return v
1070 end
1071 end
1072 return false
1073end
1074
1075function usunBaze(p,cmd,id)
1076 local acc = getElementData(p,"logedin")
1077 if not acc then return end
1078 if not id then return end
1079 if isObjectInACLGroup("user."..acc,aclGetGroup("Admin")) then
1080 local v = seachDelTarget(id)
1081 if v then
1082 local connect = xmlLoadFile("bazy/baza_"..v["id"]..".xml")
1083 local marker = getElementByID("baza_marker_"..v["id"],0)
1084 if connect and marker then
1085 local atrybut = xmlFindChild(connect,"informacje",0)
1086 removeAllVehicles(v['col'])
1087 removeBaseOwner(marker,atrybut)
1088 xmlSaveFile(connect)
1089 xmlUnloadFile(connect)
1090 outputChatBox("* Usunięto baze o id: #FF0000"..v["id"].."#FFFFFF, której właścicielem był: #FF0000"..v["lider"],p,255,255,255,true)
1091 end
1092 else
1093 outputChatBox("* Niepoprawne id",p,255,255,255)
1094 end
1095 end
1096end
1097addCommandHandler("baza.usun",usunBaze)
1098
1099
1100
1101addCommandHandler("flip",function(player)
1102 if players_in_col[player] then
1103 if not getPedOccupiedVehicle(player) then return end
1104 local rotacja = {getElementRotation(player)}
1105 setElementRotation(getPedOccupiedVehicle(player),0,0,rotacja[3])
1106 end
1107end)