Jump to content

مشكلتين بسيطة :!


ivor

Recommended Posts

VIP_server.lua

  
local theVehicle = {}
local latestSpawn = {}
local latestGetArmor = {}
local latestGetSkin = {}
local latestGetMonture = {}
local latestHideAnimal = {}
local latestHideVehilces = {}
local latestUseHats = {}
local theTimer = {}
local hatObjects = {}
local timers = {}
 
function getPremiumHoursToString ( thePlayer )
    if ( isElement( thePlayer ) ) then
        local userID = getElementData( thePlayer, "accountUserID" )
        if getElementData(thePlayer, "isPlayerVIP" ) then
            local premiumData = exports.TNSmysql:querySingle( "SELECT * FROM premium WHERE id=?", userID )
            if ( premiumData ) and ( premiumData.premium ) then
             if ( premiumData.premium < 60 ) then
                return ""..premiumData.premium.." minutes"
            else
                local premiumtime = math.floor(premiumData.premium/60)
                if( premiumtime == 1 ) then
                return ""..premiumtime.." hour"
                 else
                return ""..premiumtime.." hours"
              end
            end
        else
            return false
        end
    else
        return false
    end
    else
      return false
    end
end
 
addEvent( "OnClientGetPreminumTime", true )
addEventHandler( "OnClientGetPreminumTime", root,
    function ()
        local GetTime = getPremiumHoursToString ( source ) or "N/A"
            triggerClientEvent( source, "OpenVIPanel", source, GetTime )
    end
)
 
function updatetheVipTimeForAllPlayers ()
    for index , player in ipairs ( getElementsByType ( "player" ) ) do
        if not isGuestAccount ( getPlayerAccount ( player ) ) then
            if getElementData(player, "isPlayerVIP") then
                if (getPlayerIdleTime( player ) < 600000) then
                    local playerID = exports.TNS:playerID( player )
                    local premiumData = exports.TNSmysql:querySingle( "SELECT * FROM premium WHERE id = ?",playerID )
                    if premiumData.premium > 4 then
                        convertedTime = premiumData.premium - 5
                    elseif premiumData.premium == 4 then
                        convertedTime = premiumData.premium - 4
                    elseif premiumData.premium == 3 then
                        convertedTime = premiumData.premium - 3
                    elseif premiumData.premium == 2 then
                        convertedTime = premiumData.premium - 2
                    elseif premiumData.premium == 1 then
                        convertedTime = premiumData.premium - 1
                    end
               
                    if convertedTime == 0 then
                        setElementData(player, "isPlayerVIP", false)
                        setElementData(player, "vip", "No")
                    end
               
                    local updateViptime = exports.TNSmysql:exec("UPDATE premium SET premium=? WHERE id = '" .. playerID .. "'"
                         ,tonumber(convertedTime)
                        )
                end
            end
        end
    end
end
setTimer ( updatetheVipTimeForAllPlayers , 600000, 0 )
 
 
addEvent( "onClientSpawnVIPvehicles", true )
addEventHandler( "onClientSpawnVIPvehicles", root,
    function ()
        if not isGuestAccount ( getPlayerAccount ( source ) ) then
            if getElementData(source, "isPlayerVIP") and ( getElementInterior(source) == 0 ) then
            if not ( getElementData ( source, "isPlayerJailed" ) ) and not ( getElementData ( source, "isPlayerArrested" ) ) then
                if ( latestSpawn[getPlayerSerial(source)] ) and ( getTickCount()-latestSpawn[getPlayerSerial(source)] < 30000 ) then
            --  exports.TNSDxChatBox:CreatDxChatBoxForPlayer(thePlayer, "You can only use this feature once every 30 seconds!", 225, 255, 0)
                local wantedLvl = getPlayerWantedLevel (source)
                 elseif ( getElementData( source, "wantedPoints" ) > 1000 ) then
                    exports.TNSDxChatBox:CreatDxChatBoxForPlayer(source, "You are wanted, You can't take VIP car!", 225, 0, 0)
                 else
                    if not ( isPedInVehicle(source) ) then
                        if ( isElement( theVehicle[source] ) ) then destroyElement( theVehicle[source] ) end
                        latestSpawn[getPlayerSerial(source)] = getTickCount()
                        local x, y, z = getElementPosition(source)
                        local rx, ry, rz = getElementRotation(source)
                        theVehicle[source] = createVehicle( 517, x+2, y+2, z+1, rx, ry, rz, "VIP" )
                        --warpPedIntoVehicle(thePlayer, theVehicle[thePlayer])
                        setElementData(theVehicle[source], "vehicleType", "vipCar")
                        setElementData(theVehicle[source], "vehicleOwner", source)
                        local handlingTable = getVehicleHandling ( theVehicle[source] )
                        local newVelocity = ( handlingTable["maxVelocity"] + ( handlingTable["maxVelocity"] / 100 * 22 ) )
                        setVehicleHandling ( theVehicle[source], "numberOfGears", 3 )
                        setVehicleHandling ( theVehicle[source], "driveType", 'awd' )
                        setVehicleHandling ( theVehicle[source], "maxVelocity", newVelocity )
                        setVehicleHandling ( theVehicle[source], "engineAcceleration", handlingTable["engineAcceleration"] +5 )
                        triggerClientEvent ( source, "CloseVIPanel", getRootElement())
                    end
               end
          end
        end
    end
end)
 
addEventHandler ( "onPlayerQuit", root,
function()
    if ( isElement( theVehicle[source] ) ) then
        destroyElement( theVehicle[source] )
        theVehicle[source] = nil
    end
end
)
 
 
 
addEventHandler("onVehicleExplode", root,
function ()
    if ( getElementData(source, "vehicleType") == "vipCar" ) then
        local theOwner = getElementData(source, "vehicleOwner")
        theTimer[theOwner] = setTimer(destroyVehicle, 2000, 1, source, theOwner)
    end
end
)
 
addEventHandler("onVehicleStartEnter", root,
function ( player, seat, jacked )
    if ( getElementData(source, "vehicleType") == "vipCar" ) and ( seat == 0 ) then
     local wanted = getPlayerWantedLevel ( player )
        if ( wanted == 0 ) then
            if ( player ~= getElementData(source, "vehicleOwner") ) then
                cancelEvent()
            end
        end
    end
end
)
 
 
function currentZone(player)
    local x, y, z = getElementPosition(player)
    if x < -920 then
        return "SF"
    elseif y < 420 then
        return "LS"
    else
        return "LV"
    end
end
 
addEvent('onClientGivJetPackPlayer', true)
addEventHandler('onClientGivJetPackPlayer', root,
function ()
if not ( getElementData ( source, "isPlayerJailed" ) ) and not ( getElementData ( source, "isPlayerArrested" ) )  then
   if getElementData(source, "isPlayerVIP") and ( getElementInterior(source) == 0 ) then
      if ( getElementData( source, "wantedPoints" ) > 1000 ) then
        exports.TNSDxChatBox:CreatDxChatBoxForPlayer(source, "Your WP 1000, You can't take a jetpack!", 225, 0, 0)
     elseif ( getElementInterior(source) ~= 0 ) then
        exports.TNSDxChatBox:CreatDxChatBoxForPlayer(source, "You can't use jetpack in this interior!", 225, 0, 0)
       else
     if ( doesPedHaveJetPack ( source ) ) then
        removePedJetPack ( source )
    else
       if ( getPedOccupiedVehicle ( source ) ) then
        exports.TNSDxChatBox:CreatDxChatBoxForPlayer(source,"You are in a vehicle, you can't give use a jetpack!", 225, 0, 0)
    else
      if ( currentZone(source) == "LS" ) then
      givePedJetPack ( source )
      triggerClientEvent ( source, "CloseVIPanel", getRootElement())
      end
    end
  end
end
end
end
end)
 
addEvent('onClientCheckZone', true)
addEventHandler('onClientCheckZone', root,
function ()
 
 if ( getTeamName( getPlayerTeam ( source ) ) == "Staff" ) or ( getElementData( source, "developer" ) ) then
    return
 end
 
   if ( getElementData(source, "isPlayerVIP") and ( getElementInterior(source) == 0 ) ) then
     if ( currentZone(source) ~= "LS" ) then
       if ( doesPedHaveJetPack ( source ) ) then
        removePedJetPack ( source )
        end
    end
   end
 
end)
 
addEvent('onClinetGiveVIPArmor', true)
addEventHandler('onClinetGiveVIPArmor', root,
function ()
if not ( getElementData ( source, "isPlayerJailed" ) ) and not ( getElementData ( source, "isPlayerArrested" ) )  then
   if getElementData(source, "isPlayerVIP") and ( getElementInterior(source) == 0 ) then
    if ( latestGetArmor[getPlayerSerial(source)] ) and ( getTickCount()-latestGetArmor[getPlayerSerial(source)] < 600000 ) then
    exports.TNSDxChatBox:CreatDxChatBoxForPlayer(source, "You can take 100% armor only every 5 minutes!", 225, 0, 0)
    else
     setPedArmor(source, 100)
     setPedStat ( source, 24, 989 )
     setElementHealth ( source, 200 )
     latestGetArmor[getPlayerSerial(source)] = getTickCount()
        end
      end
   end
end)
 
addEvent('onClinetHideLion', true)
addEventHandler('onClinetHideLion', root,
function ()
if not ( getElementData ( source, "isPlayerJailed" ) ) and not ( getElementData ( source, "isPlayerArrested" ) )  then
   if getElementData(source, "isPlayerVIP") then
    if ( latestHideAnimal[getPlayerSerial(source)] ) and ( getTickCount()-latestHideAnimal[getPlayerSerial(source)] < 120000 ) then
    exports.TNSDxChatBox:CreatDxChatBoxForPlayer(source, "You can use this button only every 2 minutes!", 225, 0, 0)
    else
     onHideAnimalForVips( source )
     triggerClientEvent ( source, "CloseVIPanel", getRootElement())
     exports.TNSDxChatBox:CreatDxChatBoxForPlayer(source, "You have successfully hide your Lion!", 0, 230, 0)
     latestHideAnimal[getPlayerSerial(source)] = getTickCount()
        end
      end
   end
end)
 
 
addEvent('onClinetTakeVIPSkin', true)
addEventHandler('onClinetTakeVIPSkin', root,
function ( ID )
  if not ( getElementData ( source, "isPlayerJailed" ) ) and not ( getElementData ( source, "isPlayerArrested" ) )  then
   if getElementData(source, "isPlayerVIP") then
    if ( latestGetSkin[getPlayerSerial(source)] ) and ( getTickCount()-latestGetSkin[getPlayerSerial(source)] < 30000 ) then
    exports.TNSDxChatBox:CreatDxChatBoxForPlayer(source, "You can take vip skin only every 30 seconds!", 225, 0, 0)
   
Link to comment
ومين قال ان هي بالرتب اساسا :lol:

ذا الفيب عن طريق داتا اسمها isPlayerVIP

طيب وش اعمل يعنى شو الحل ؟؟؟؟

استخدم التحقق من الرتبه بدلا من التحقق من الداتا

ذي الفنكشنات الى راح تستخدمها

getAccountName 
getPlayerAccount 
aclGetGroup 
isObjectInACLGroup 

Link to comment
ومين قال ان هي بالرتب اساسا :lol:

ذا الفيب عن طريق داتا اسمها isPlayerVIP

طيب وش اعمل يعنى شو الحل ؟؟؟؟

استخدم التحقق من الرتبه بدلا من التحقق من الداتا

ذي الفنكشنات الى راح تستخدمها

getAccountName 
getPlayerAccount 
aclGetGroup 
isObjectInACLGroup 

مب اعرف اخي ضض :D:?:cry:

Link to comment
  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...