function getVariableTyp ( var )
elseif tostring ( var ) == "true" or tostring ( var ) == "false" then
elseif tonumber ( var ) then
function isReallyInsideRadarArea ( theArea, x, y )
local posX, posY = getElementPosition ( theArea )
local sizeX, sizeY = getRadarAreaSize ( theArea )
return (x >= posX) and (x <= posX + sizeX) and (y >= posY) and (y <= posY + sizeY)
function sortArray ( tbl )
local size = table.size ( tbl )
if tbl[i] > curBiggest then
function outputArray ( table )
outputServerLog ( "Value: "..table[i] )
function isPedAiming ( ped )
return getPedControlState ( ped, "aim_weapon" )
return getPedControlState ( ped, "aim_weapon" )
function damagePlayer ( player, amount, damager, weapon )
if isElement ( player ) then
local armor = getPedArmor ( player )
local health = getElementHealth ( player )
setPedArmor ( player, armor - amount )
setPedArmor ( player, 0 )
local newamount = amount - armor
if health - newamount <= 0 then
killPed ( player, damager, weapon, 3, false )
setElementHealth ( player, health - newamount )
if health - amount <= 0 then
killPed ( player, damager, weapon, 3, false )
setElementHealth ( player, health - amount )
vioSetElementData ( player, "lasthp", getElementHealth ( player )+ getPedArmor ( player ))
vioSetElementData ( player, "DamageBekommen", vioGetElementData ( player, "DamageBekommen" ) + amount )
vioSetElementData ( damager, "DamageGemacht", vioGetElementData ( damager, "DamageGemacht" ) + amount )
function formNumberToMoneyString ( value )
if tonumber ( value ) then
value = tostring ( value )
if string.sub ( value, 1, 1 ) == "-" then
return "-"..setDotsInNumber ( string.sub ( value, 2, #value ) ).." $"
return setDotsInNumber ( value ).." $"
function setDotsInNumber ( value )
return setDotsInNumber ( string.sub ( value, 1, #value - 3 ) ).."."..string.sub ( value, #value - 2, #value )
function isPlayerUnarmed ( player )
if getPedWeapon ( player, i ) > 0 then
if getPedTotalAmmo ( player, i ) > 0 then
function getFreeDimension ()
local rnd = math.random ( 10, 65000 )
if not freeDimensions[rnd] then
freeDimensions[rnd] = true
function setMoveable ( player, bool )
elseif isElement ( player ) then
function timestampOptical ()
local regtime = getRealTime()
local year = regtime.year + 1900
local month = regtime.month+1
local day = regtime.monthday
local hour = regtime.hour
local minute = regtime.minute
return tostring(day.."."..month.."."..year..", "..hour..":"..minute)
function getDaysInMonth ( month, year )
local leap = isYearALeapYear ( year )
if month == 2 and leap then
function isYearALeapYear(year)
if (not year) then year = getRealTime().year + 1900 end
return ((year % 4 == 0 and year % 100 ~= 0) or year % 400 == 0)
function toggleVehicleTrunk ( veh )
if vioGetElementData ( veh, "stuning1" ) then
local vx, vy, vz = getElementVelocity ( veh )
local x, y, z = getElementPosition ( veh )
setElementFrozen ( veh, true )
setElementPosition ( veh, x, y, z - 50 )
local state = vioGetElementData ( veh, "trunkState" )
if vioGetElementData ( veh, "trunkState" ) == nil then
vioSetElementData ( veh, "trunkState", false )
setVehicleDoorState ( veh, 1, 0 )
vioSetElementData ( veh, "trunkState", not state )
setVehicleDoorState ( veh, 1, 0 )
setVehicleDoorState ( veh, 1, 4 )
setElementFrozen ( veh, false )
setElementPosition ( veh, x, y, z )
setElementVelocity ( veh, vx, vy, vz )
function getVehicleTrunkState ( veh )
if vioGetElementData ( veh, "trunkState" ) then
function getDistanceBetweenMinutes ( m1, h1, m2, h2 )
return math.abs ( 1440 - t1 + t2 )
function attachElementsInCorrectWay ( element1, element2 )
local x1, y1, z1 = getElementPosition ( element1 )
--local rx1, ry1, rz1 = getElementRotation ( element1 )
local x2, y2, z2 = getElementPosition ( element2 )
--local rx2, ry2, rz2 = getElementRotation ( element1 )
attachElements ( element1, element2, x1-x2, y1-y2, z1-z2--[[, rx1-rx2, ry1-ry2, rz1-rz2]] )
function attachElementsInVeryCorrectWay ( element1, element2 )
local x1, y1, z1 = getElementPosition ( element1 )
local rx1, ry1, rz1 = getElementRotation ( element1 )
local x2, y2, z2 = getElementPosition ( element2 )
local rx2, ry2, rz2 = getElementRotation ( element1 )
attachElements ( element1, element2, x1-x2, y1-y2, z1-z2, rx2, ry2, rz2 )
for key, value in pairs(tab) do
if ( type ( value ) == "table" ) then
ret [ key ] = table.copy ( value )
function table.size ( tab )
for _ in pairs ( tab ) do length = length + 1 end
function findRotation ( x1, y1, x2, y2 )
local t = - math.deg ( math.atan2 ( x2 - x1, y2 - y1 ) )
if t < 0 then t = t + 360 end
function getPointFromDistanceRotation ( x, y, dist, angle )
local a = math.rad ( 90 - angle )
local dx = math.cos ( a ) * dist
local dy = math.sin ( a ) * dist
function isString ( text )
if not tonumber ( text ) and tostring ( text ) ~= "true" and tostring ( text ) ~= "false" and tostring ( text ) ~= "nil" then
local regtime = getRealTime()
local year = regtime.year + 1900
local month = regtime.month + 1
local day = regtime.monthday
local hour = regtime.hour + winterzeit
if hour == 24 then hour = 0 end
local minute = regtime.minute
local timestamp = tostring(day.."."..month.."."..year..", "..hour..":"..minute)
function timestampDays ( add )
local regtime = getRealTime()
local day = regtime.monthday + add
local year = regtime.year + 1900
local month = regtime.month + 1
local hour = regtime.hour + winterzeit
if hour == 24 then hour = 0 end
local minute = regtime.minute
local timestamp = day.."."..month.."."..year
function setVehicleStatic ( vehicle, boolean )
local x, y, z = getElementPosition ( vehicle )
local rx, ry, rz = getElementRotation ( vehicle )
local master = createObject ( 1337, x, y, z )
setElementRotation ( master, rx, ry, rz )
setElementAlpha ( master, 0 )
--attachElementsInCorrectWay ( vehicle, master )
attachElementsInCorrectWay ( vehicle, master )
setVehicleDamageProof ( vehicle, true )
setVehicleDoorsUndamageable ( vehicle, true )
setVehicleLocked ( vehicle, true )
function isWithinNightTime ()
local time = getRealTime()
if hour >= 20 or hour <= 8 then
function fadeElementInterior ( player, int, intx, inty, intz, rot, dim )
if player and isElement ( player ) and getElementType ( player ) == "player" then
if not vioGetElementData ( player, "intchange" ) then
vioSetElementData ( player, "intchange", true )
fadeCamera ( false, 1, 0, 0, 0 )
setTimer ( fadeCamera, 1000, 1, true )
setTimer ( setElementInterior, 1000, 1, player, int )
setTimer ( setElementDimension, 1000, 1, player, dim )
setTimer ( setElementPosition, 1000, 1, player, intx, inty, intz )
setTimer ( setPedRotation, 1000, 1, player, rot )
setTimer ( vioSetElementData, 2000, 1, player, "intchange", false )
fadeCamera ( player, false, 1, 0, 0, 0 )
setTimer ( fadeCamera, 1000, 1, player, true )
setTimer ( setElementInterior, 1000, 1, player, int )
setTimer ( setElementPosition, 1000, 1, player, intx, inty, intz )
setTimer ( setPedRotation, 1000, 1, player, rot )
setTimer ( vioSetElementData, 2000, 1, player, "intchange", false )
function vanishElement ( element )
if isElement ( element ) then
setTimer ( setElementAlpha, 100 * i, 1, element, 255 / 25 * ( 25 - i ) )
setTimer ( destroyElement, 2500, 1, element )
function addPlayerHealth ( player, value )
if isElement ( player ) then
local total = getElementHealth ( player ) + value
setElementHealth ( player, 100 )
setElementHealth ( player, total )
function toggleChatControls ( bool )
toggleControl ( "chatbox", bool )
function getSecTime ( duration )
local time = getRealTime()
local minute = time.minute
local total = year * 365 * 24 * 60 + day * 24 * 60 + ( hour + duration ) * 60 + minute
function getSecondTime ( duration )
local time = getRealTime ()
local minute = time.minute
local seconds = time.second
total = year * 365 * 24 * 60 * 60
total = total + day * 24 * 60 * 60
total = total + hour * 60 * 60
total = total + minute * 60
total = total + seconds + duration