53 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
| local QBCore = exports['qb-core']:GetCoreObject()
 | |
| 
 | |
| RegisterNetEvent("kennzeichen:useTool", function()
 | |
|     local playerPed = PlayerPedId()
 | |
|     local veh = QBCore.Functions.GetClosestVehicle(GetEntityCoords(playerPed))
 | |
|     if veh and veh ~= 0 then
 | |
|         local input = lib.inputDialog("Kennzeichen ändern", {
 | |
|             {type = "input", label = "Neues Kennzeichen", required = true}
 | |
|         })
 | |
|         if input and input[1] then
 | |
|             local plate = input[1]
 | |
|             TriggerServerEvent("kennzeichen:updatePlate", VehToNet(veh), plate)
 | |
|         end
 | |
|     else
 | |
|         QBCore.Functions.Notify("Kein Fahrzeug in der Nähe", "error")
 | |
|     end
 | |
| end)
 | |
| 
 | |
| local plateBackup = {}
 | |
| 
 | |
| RegisterNetEvent("kennzeichen:useTuch", function()
 | |
|     local playerPed = PlayerPedId()
 | |
|     local veh = QBCore.Functions.GetClosestVehicle(GetEntityCoords(playerPed))
 | |
|     if veh and veh ~= 0 then
 | |
|         local covered = plateBackup[veh] ~= nil
 | |
|         if covered then
 | |
|             SetVehicleNumberPlateText(veh, plateBackup[veh])
 | |
|             plateBackup[veh] = nil
 | |
|         else
 | |
|             plateBackup[veh] = GetVehicleNumberPlateText(veh)
 | |
|             SetVehicleNumberPlateText(veh, "-----")
 | |
|         end
 | |
|         TriggerServerEvent("kennzeichen:syncCover", VehToNet(veh), not covered)
 | |
|     end
 | |
| end)
 | |
| 
 | |
| RegisterNetEvent("kennzeichen:applyPlate", function(netVeh, plate)
 | |
|     local veh = NetToVeh(netVeh)
 | |
|     if veh ~= 0 then
 | |
|         SetVehicleNumberPlateText(veh, plate)
 | |
|     end
 | |
| end)
 | |
| 
 | |
| RegisterNetEvent("kennzeichen:applyCover", function(netVeh, state)
 | |
|     local veh = NetToVeh(netVeh)
 | |
|     if veh ~= 0 then
 | |
|         if state then
 | |
|             SetVehicleNumberPlateText(veh, "-----")
 | |
|         else
 | |
|             -- Wenn Enttarnung erfolgt, müsste der Spieler es neu setzen
 | |
|         end
 | |
|     end
 | |
| end)
 | 
