Best-Killer Posted November 26, 2015 Share Posted November 26, 2015 Hi all i have my own script to spawn cars that has a gui when the player hits the marker. And i want to add some cars to the Gui but only for players in Vip Script group called "getVipLevelFromName" Codes : Vip server side : 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.NGMessages: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 ) Vip Client Side : function isPlayerVIP ( ) return tostring ( getElementData ( localPlayer, "VIP" ) ):lower ( ) ~= "none" end function getVipLevelFromName ( l ) local levels = { ['none'] = 0, ['bronze'] = 1, ['silver'] = 2, ['gold'] = 3, ['diamond'] = 4 } return levels[l:lower()] or 0; end Spawners Client Side jWin = guiCreateWindow(550,560,200,200,"SAEG Vehicle Spawner",false) guiSetVisible(jWin,false) function openGui() guiSetVisible(jWin,true) function spawnveh(button, press) if(press) then if(button == "1") then x, y, z = getElementPosition(localPlayer) triggerServerEvent("crVeh", getRootElement(), 468, x, y, z, localPlayer) end if(button == "2") then x, y, z = getElementPosition(localPlayer) triggerServerEvent("crVeh", getRootElement(), 457, x, y, z, localPlayer) end if(button == "3") then x, y, z = getElementPosition(localPlayer) triggerServerEvent("crVeh", getRootElement(), 412, x, y, z, localPlayer) end end end addEventHandler("onClientKey", getRootElement(), spawnveh) guiWindowSetSizable(jWin,false) tGrid = guiCreateGridList(0,20,190,170,false,jWin) guiGridListAddColumn(tGrid, "Key", 0.20) guiGridListAddColumn(tGrid, "Name", 0.65) row1 = guiGridListAddRow(tGrid) row2 = guiGridListAddRow(tGrid) row3 = guiGridListAddRow(tGrid) guiGridListSetItemText(tGrid, row1, 1, tostring(row1+1), false, false) guiGridListSetItemText(tGrid, row1, 2, "Sanchez", false, false) guiGridListSetItemText(tGrid, row2, 1, tostring(row2+1), false, false) guiGridListSetItemText(tGrid, row2, 2, "Caddy", false, false) guiGridListSetItemText(tGrid, row3, 1, tostring(row3+1), false, false) guiGridListSetItemText(tGrid, row3, 2, "Voodoo", false, false) end addEvent("markerHitted", true) addEventHandler("markerHitted", getRootElement(), openGui) function hideGui() guiSetVisible(jWin,false) removeEventHandler("onClientKey", getRootElement(), spawnveh) end addEvent("markerLeaved", true) addEventHandler("markerLeaved", getRootElement(), hideGui) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now