Jump to content

[Help]VIP system


Best-Killer1

Recommended Posts

How I can add access to jetpack for vip's players

vip_c

function isPlayerVIP ( ) 
    return tostring ( getElementData ( localPlayer, "VIP" ) ):lower ( ) ~= "none" 
end  
  
  
function getVipLevelFromName ( l ) 
    local levels = { ['none'] = 0, ['bronze'] = 1, ['silver'] = 2, ['gold'] = 3, ['premium'] = 4 } 
    return levels[l:lower()] or 0; 
end 
  

vip_s

print_ = print 
print = outputChatBox 
  
exports.scoreboard:scoreboardAddColumn ( "VIP", root, 50, "VIP", 10 ) 
for i, v in pairs ( getElementsByType ( "player" ) ) do 
    if ( not getElementData ( v, "VIP" ) ) then 
        setElementData ( v, "VIP", "None" ) 
    end 
end 
  
addEventHandler ( "onPlayerJoin", root, function ( ) 
    setElementData ( source, "VIP", "None" ) 
end ) 
  
-- VIP Chat -- 
addCommandHandler ( "vipchat", function ( p, cmd, ... ) 
    if ( not isPlayerVIP ( p ) ) then 
        return exports.SAEGMessages:sendClientMessage ( "This command is for VIP users only", p, 255, 0, 0 ) 
    end 
     
    if ( isPlayerMuted ( p ) ) then 
        return exports.SAEGMessages:sendClientMessage ( "This command is disabled when you're muted", p, 255, 255, 0 ) 
    end 
     
    if ( not getElementData ( p, "userSettings" )['usersetting_display_vipchat'] ) then 
        return exports.SAEGMessages:sendClientMessage ( "Please enable VIP chat in your phone settings to use this command.", 0, 255, 255 ) 
    end 
     
    local msg = table.concat ( { ... }, " " ) 
    if ( msg:gsub ( " ", "" ) == "" ) then 
        return exports.SAEGMessages:sendClientMessage ( "Syntax: /"..tostring(cmd).." [message]", p, 255, 255, 0 ) 
    end 
     
    local tags = "(VIP)"..tostring(exports.SAEGChat:getPlayerTags ( p )) 
    local msg = tags..getPlayerName ( p )..": #ffffff"..msg 
    for i,v in pairs ( getElementsByType ( 'player' ) ) do 
        if ( ( isPlayerVIP ( v ) or exports.SAEGAdministration:isPlayerStaff ( p ) ) and getElementData ( v, "userSettings" )['usersetting_display_vipchat'] ) then 
            outputChatBox ( msg, v, 200, 200, 0, true ) 
        end 
    end 
end ) 
  
  
  
  
  
function checkPlayerVipTime ( p ) 
    local vip = getElementData ( p, "VIP" ) 
    if ( vip == "None" ) then return end 
    local expDate = getElementData ( p, "SAEGVIP.expDate" )  or "0000-00-00"  -- Format: YYYY-MM-DD 
    if ( isDatePassed ( expDate ) ) then 
        setElementData ( p, "VIP", "None" ) 
        setElementData ( p, "SAEGVIP.expDate", "0000-00-00" ) 
        exports.SAEGMessages:sendClientMessage ( "Your VIP time has been expired.", p, 255, 0, 0 ) 
    end 
end 
  
function checkAllPlayerVIP ( ) 
    for i, v in pairs ( getElementsByType ( "player" ) ) do 
        checkPlayerVipTime ( v ) 
    end 
end 
  
function isPlayerVIP ( p ) 
    checkPlayerVipTime ( p ) 
    return tostring ( getElementData ( p, "VIP" ) ):lower ( ) ~= "none" 
end  
  
function getVipLevelFromName ( l ) 
    local levels = { ['none'] = 0, ['bronze'] = 1, ['silver'] = 2, ['gold'] = 3, ['premium'] = 4 } 
    return levels[l:lower()] or 0; 
end 
  
  
  
  
  
  
  
  
  
  
------------------------------------------ 
-- Give VIP players free cash           -- 
------------------------------------------ 
local payments = { [1] = 500, [2] = 700, [3] = 1000, [4] = 1500 } 
  
VipPayoutTimer = setTimer ( function ( ) 
    exports.SAEGLogs:outputServerLog ( "Sending out VIP cash...." ) 
    print_ ( "Sending out VIP cash...." ) 
    outputDebugString ( "Sending VIP cash" ) 
     
    for i, v in ipairs ( getElementsByType ( "player" ) ) do 
        if ( isPlayerVIP ( v ) ) then 
            local l = getVipLevelFromName ( getElementData ( v, "VIP" ) ) 
            local money = payments [ l ] 
            givePlayerMoney ( v, money ) 
            exports.SAEGMessages:sendClientMessage ( "Here is a free $"..money.." for being a VIP player!", v, 0, 255, 0 ) 
        end 
    end 
end, (60*60)*1000, 0 )  
  
  
function getVipPayoutTimerDetails ( )  
    return getTimerDetails ( VipPayoutTimer ) 
end 
  
function isDatePassed ( date ) 
    -- date format: YYYY-MM-DD 
    local this = { } 
    local time = getRealTime ( ); 
    this.year = time.year + 1900 
    this.month = time.month + 1 
    this.day = time.monthday  
    local old = { } 
    local data = split ( date, "-" ) 
    old.year = data[1]; 
    old.month = data[2]; 
    old.day = data[3]; 
    for i, v in pairs ( this ) do 
        this [ i ] = tonumber ( v ) 
    end for i, v in pairs ( old ) do 
        old [ i ] = tonumber ( v ) 
    end 
    if ( this.year > old.year ) then 
        return true 
    elseif ( this.year == old.year and this.month > old.month ) then 
        return true 
    elseif ( this.year == old.year and this.month == old.month and this.day > old.day ) then 
        return true 
    end 
    return false 
end 
  
  
  
  
  
  
addEventHandler( "onResourceStart", resourceRoot, function ( ) 
    checkAllPlayerVIP ( ) 
    setTimer ( checkAllPlayerVIP, 120000, 0 ) 
end ) 
  
  
--[[ 
  
Bronze:  
    - Laser 
    - Able to warp vehicle to you 
    - Additional 6 vehicles in spawners 
    - $500/hour 
    - 5% less jail time 
  
  
     
Silver:  
    - Laser 
    - Able to warp your vehicle to you 
    - Additional 6 vehicles in spawners 
    - $700/hour 
    - 15% less jail time 
     
     
Gold: 
    - Laser 
    - Able to warp your vehicle to you 
    - Additional 6 vehicles in spawner 
    - $1000/hour 
    - %25 less jail time 
     
     
Premium: 
    - Laser 
    - Able to warp your vehicle to you 
    - Additional 6 vehicles in spawners 
    - $1500/hour 
    - Half jail time 
  
  
]] 
  
  
  
  
  
  
  
  

  • Like 1
Link to comment
Where's your jetpack script part?

i don't have i wanna add it

Okay no problem, i made this jetpack code for you, copy it correctly and put it to server side

--Server side:

bindKey(source,"J","down",jetpack) 
  
function jetpack(player,key,state) 
 if ( exports.SAEGVIP:isPlayerVIP () ) then 
    if (doesPedHaveJetPack(player)) then 
        removePedJetPack(player) 
        outputChatBox("Jetpack Removed.",player,255,0,0) 
    else 
    if (not doesPedHaveJetPack(player)) then 
        givePedJetPack(player) 
        outputChatBox("Jetpack Actived.",player,0,255,0) 
      end 
    end 
  end 
end 
  

Link to comment

he stole the script

Where's your jetpack script part?

i don't have i wanna add it

Okay no problem, i made this jetpack code for you, copy it correctly and put it to server side

--Server side:

bindKey(source,"J","down",jetpack) 
  
function jetpack(player,key,state) 
 if ( exports.SAEGVIP:isPlayerVIP () ) then 
    if (doesPedHaveJetPack(player)) then 
        removePedJetPack(player) 
        outputChatBox("Jetpack Removed.",player,255,0,0) 
    else 
    if (not doesPedHaveJetPack(player)) then 
        givePedJetPack(player) 
        outputChatBox("Jetpack Actived.",player,0,255,0) 
      end 
    end 
  end 
end 
  

Link to comment
he stole the script

I stole the script O_o? lmao, read the topic well

-You just saw this line in my code, it's because he asked me to do for him jetpack script for vip players only and it's an exports on his code

if ( exports.SAEGVIP:isPlayerVIP () ) then 

Please next time be sure of something before tell to someone or name him stealer,

Thank you!

Link to comment

--Should works, after starting the resource , disconnect and login again to get the bind

  
addEventHandler ( "onPlayerLogin", getRootElement (),   
function  ( ) 
bindKey(source,"J","down",jetpack) 
end) 
  
  
function jetpack(player,key,state) 
 if ( exports.SAEGVIP:isPlayerVIP () ) then 
    if (doesPedHaveJetPack(player)) then 
        removePedJetPack(player) 
        outputChatBox("Jetpack Removed.",player,255,0,0) 
    else 
    if (not doesPedHaveJetPack(player)) then 
        givePedJetPack(player) 
        outputChatBox("Jetpack Actived.",player,0,255,0) 
      end 
    end 
  end 
end 

Link to comment
--Should works, after starting the resource , disconnect and login again to get the bind
  
addEventHandler ( "onPlayerLogin", getRootElement (),   
function  ( ) 
bindKey(source,"J","down",jetpack) 
end) 
  
  
function jetpack(player,key,state) 
 if ( exports.SAEGVIP:isPlayerVIP () ) then 
    if (doesPedHaveJetPack(player)) then 
        removePedJetPack(player) 
        outputChatBox("Jetpack Removed.",player,255,0,0) 
    else 
    if (not doesPedHaveJetPack(player)) then 
        givePedJetPack(player) 
        outputChatBox("Jetpack Actived.",player,0,255,0) 
      end 
    end 
  end 
end 

thanx <3 <3 <3 :******

karim you can tell me how i can make it not work for cops vip's players ?? and for crims not work when have stars

Link to comment

Here you go,all what you need

addEventHandler ( "onPlayerLogin", getRootElement (),   
function  ( ) 
bindKey(source,"J","down",jetpack) 
end) 
   
function jetpack(player,key,state) 
 if ( exports.SAEGVIP:isPlayerVIP () ) then 
 if getTeamName(getPlayerTeam(player)) == "Police" or getTeamName(getPlayerTeam(player)) == "SWAT" or getTeamName(getPlayerTeam(player)) == "Military" then return end 
 if ( getPlayerWantedLevel ( player ) > 0 ) then return end 
    if (doesPedHaveJetPack(player)) then 
        removePedJetPack(player) 
        outputChatBox("Jetpack Removed.",player,255,0,0) 
    else 
    if (not doesPedHaveJetPack(player)) then 
        givePedJetPack(player) 
        outputChatBox("Jetpack Actived.",player,0,255,0) 
      end 
    end 
  end 
end 

Link to comment

thanx <3 <3 <3 :******

karim you can tell me how i can make it not work for cops vip's players ?? and for crims not work when have stars

You mean all LAW team SWAT/Military and Police?

i mean vip's players can't use jetpack when they playing as cop and when vip's players playing as criminal can't use jetpack when have stars
Link to comment

I already did that, im sure you didn't try this last code that i made , it's with all features that you need

addEventHandler ( "onPlayerLogin", getRootElement (),   
function  ( ) 
bindKey(source,"J","down",jetpack) 
end) 
  
function jetpack(player,key,state) 
 if ( exports.SAEGVIP:isPlayerVIP () ) then 
 if getTeamName(getPlayerTeam(player)) == "Police" or getTeamName(getPlayerTeam(player)) == "SWAT" or getTeamName(getPlayerTeam(player)) == "Military" then return end 
 if ( getPlayerWantedLevel ( player ) > 0 ) then return end 
    if (doesPedHaveJetPack(player)) then 
        removePedJetPack(player) 
        outputChatBox("Jetpack Removed.",player,255,0,0) 
    else 
    if (not doesPedHaveJetPack(player)) then 
        givePedJetPack(player) 
        outputChatBox("Jetpack Actived.",player,0,255,0) 
      end 
    end 
  end 
end 

Link to comment
I already did that, im sure you didn't try this last code that i made , it's with all features that you need
addEventHandler ( "onPlayerLogin", getRootElement (),   
function  ( ) 
bindKey(source,"J","down",jetpack) 
end) 
  
function jetpack(player,key,state) 
 if ( exports.SAEGVIP:isPlayerVIP () ) then 
 if getTeamName(getPlayerTeam(player)) == "Police" or getTeamName(getPlayerTeam(player)) == "SWAT" or getTeamName(getPlayerTeam(player)) == "Military" then return end 
 if ( getPlayerWantedLevel ( player ) > 0 ) then return end 
    if (doesPedHaveJetPack(player)) then 
        removePedJetPack(player) 
        outputChatBox("Jetpack Removed.",player,255,0,0) 
    else 
    if (not doesPedHaveJetPack(player)) then 
        givePedJetPack(player) 
        outputChatBox("Jetpack Actived.",player,0,255,0) 
      end 
    end 
  end 
end 

lol when i use j for jetpack showing they said jetpack actived jetpack removed in 1 time and jetpack not showing

Link to comment

Try it and tell me the result

addEventHandler ( "onPlayerLogin", getRootElement (),   
function  ( ) 
bindKey(source,"J","down",jetpack) 
end) 
  
function jetpack(player,key,state) 
     if ( state == "down" ) then 
     if ( exports.SAEGVIP:isPlayerVIP () ) then 
    if getTeamName(getPlayerTeam(player)) == "Police" or getTeamName(getPlayerTeam(player)) == "SWAT" or      getTeamName(getPlayerTeam(player)) == "Military" then return end 
    if ( getPlayerWantedLevel ( player ) > 0 ) then return end 
    if (doesPedHaveJetPack(player)) then 
        removePedJetPack(player) 
        outputChatBox("Jetpack Removed.",player,255,0,0) 
    else 
 if (not doesPedHaveJetPack(player)) then 
    givePedJetPack(player) 
    outputChatBox("Jetpack Actived.",player,0,255,0) 
     end 
    end 
  end 
 end 
end 

Link to comment
Try it and tell me the result
addEventHandler ( "onPlayerLogin", getRootElement (),   
function  ( ) 
bindKey(source,"J","down",jetpack) 
end) 
  
function jetpack(player,key,state) 
     if ( state == "down" ) then 
     if ( exports.SAEGVIP:isPlayerVIP () ) then 
    if getTeamName(getPlayerTeam(player)) == "Police" or getTeamName(getPlayerTeam(player)) == "SWAT" or      getTeamName(getPlayerTeam(player)) == "Military" then return end 
    if ( getPlayerWantedLevel ( player ) > 0 ) then return end 
    if (doesPedHaveJetPack(player)) then 
        removePedJetPack(player) 
        outputChatBox("Jetpack Removed.",player,255,0,0) 
    else 
 if (not doesPedHaveJetPack(player)) then 
    givePedJetPack(player) 
    outputChatBox("Jetpack Actived.",player,0,255,0) 
     end 
    end 
  end 
 end 
end 

same problem *

Link to comment

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...