Jump to content

Dimos7

Members
  • Posts

    1,546
  • Joined

  • Last visited

Everything posted by Dimos7

  1. ---------------------------------------- -- Developer Note: -- THIS RESOURCE CANNOT BE RESTARTED -- WHILE THE SERVER IS RUNNING, IT CAN -- MAKE MINUTES OF NETWORK TROUBLE -- WHILE QUERYING ALL GROUPS DATA ----------------------------------------- local groups = { } addEventHandler ( "onResourceStart", resourceRoot, function ( ) exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS groups ( id INT, name VARCHAR(20), info TEXT )" ); exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS group_members ( id INT, member_name VARCHAR(30), rank VARCHAR(20), join_date VARCHAR(40) )"); exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS group_rank ( id INT, rank VARCHAR(30), perms TEXT )" ) exports.NGSQL:db_exec ( "CREATE TABLE IF NOT EXISTS group_logs ( id INT, time VARCHAR(40), account VARCHAR(40), log TEXT )" ) exports.scoreboard:scoreboardAddColumn ( "Group", getRootElement ( ), 90, "Group", 5 ) exports.scoreboard:scoreboardAddColumn ( "Group Rank", getRootElement ( ), 90, "Group Rank", 6 ) for i, v in pairs ( getElementsByType ( "player" ) ) do local g = getElementData ( v, "Group" ) if ( not g ) then setElementData ( v, "Group", "None" ) setElementData ( v, "Group Rank", "None") end if ( not getElementData ( v, "Group Rank" ) ) then setElementData ( v, "Group Rank", "None" ) end end end ) addEventHandler ( "onPlayerJoin", root, function ( ) setElementData ( source, "Group", "None" ) setElementData ( source, "Group Rank", "None") end ) groups = { } --[[ example: groups = { ['ownfexrf__s'] = { info = { founder = "xXMADEXx", -- this CANNOT change founded_time = "2014-06-18:01-35-57", desc = "This is my group", color = { 255, 255, 0 }, type = "Gang", bank = 0, id = 0 }, members = { ["xXMADEXx"] = { rank="Founder", joined="2014-06-18:01-35-57" } }, ranks = { ['Founder'] = { -- member access ['member_kick'] = true, ['member_invite'] = true, ['member_setrank'] = true, ['member_viewlog'] = true -- General group changes ['group_modify_color'] = true,, ['group_modify_motd'] = true, -- banks ['bank_withdraw'] = true, ['bank_deposit'] = true, -- logs ['logs_view'] = true, ['logs_clear'] = true, -- ranks ['ranks_create'] = true, ['ranks_delete'] = true, ['ranks_modify'] = true } }, log = { -- { time, log } { time="2014-06-18 05:05:05", account="xXMADEXx", log="Group Created" } }, pendingInvites = { ['account'] = { inviter = "Inviter Account", time="Time Invite Sent"} } } }]] function saveGroups ( ) exports.NGSQL:db_exec ( "DELETE FROM groups" ) exports.NGSQL:db_exec ( "DELETE FROM group_rank" ) exports.NGSQL:db_exec ( "DELETE FROM group_members") exports.NGSQL:db_exec ( "DELETE FROM group_logs") for i, v in pairs ( groups ) do exports.NGSQL:db_exec ( "INSERT INTO groups ( id, name, info ) VALUES ( ?, ?, ? )", tostring ( v.info.id ), tostring ( i ), toJSON ( v.info ) ) for k, val in pairs ( v.ranks ) do exports.NGSQL:db_exec ( "INSERT INTO group_rank ( id, rank, perms ) VALUES ( ?, ?, ? )", tostring ( v.info.id ), k, toJSON ( val ) ) end for k, val in pairs ( v.members ) do exports.NGSQL:db_exec ( "INSERT INTO group_members ( id, member_name, rank, join_date ) VALUES ( ?, ?, ?, ? )", tostring ( v.info.id ), k, val.rank, val.joined ) end for k, val in ipairs ( v.log ) do exports.NGSQL:db_exec ( "INSERT INTO group_logs ( id, time, account, log ) VALUES ( ?, ?, ?, ? )", tostring ( v.info.id ), val.time, val.account, val.log ) end end end function loadGroups ( ) local start = getTickCount ( ) local groups_ = exports.NGSQL:db_query ( "SELECT * FROM groups" ) for i, v in pairs ( groups_ ) do if ( v and v.name and not groups [ v.name ] ) then groups [ v.name ] = { } groups [ v.name ].info = { } groups [ v.name ].ranks = { } groups [ v.name ].members = { } groups [ v.name ].log = { } -- load info table groups [ v.name ].info = fromJSON ( v.info ) groups [ v.name ].info.id = tonumber ( v.id ) -- load rank table local ranks = exports.NGSQL:db_query ( "SELECT * FROM group_rank WHERE id=?", tostring ( v.id ) ) for i, val in pairs ( ranks ) do if ( not groups [ v.name ].ranks[val.rank] ) then groups [ v.name ].ranks[val.rank] = fromJSON ( val.perms ) end end -- load member table local members = exports.NGSQL:db_query ( "SELECT * FROM group_members WHERE id=?", tostring ( v.id ) ) for i, val in pairs ( members ) do groups [v.name].members[val.member_name] = { } groups [v.name].members[val.member_name].rank = val.rank groups [v.name].members[val.member_name].joined = val.join_date for _, player in pairs ( getElementsByType ( "player" ) ) do local a = getPlayerAccount ( player ) if ( a and not isGuestAccount ( a ) ) then local acc = getAccountName ( a ) if ( val.member_name == acc ) then setElementData ( player, "Group", tostring ( v.name ) ) setElementData ( player, "Group Rank", tostring ( val.rank ) ) end end end end -- load logs table local log = exports.NGSQL:db_query ( "SELECT * FROM group_logs WHERE id=?", tostring ( v.id ) ) for i, val in ipairs ( log ) do table.insert ( groups[v.name].log, { time=val.time, account=val.account, log=val.log } ) end groups [ v.name ].pendingInvites = { } else local reason = "Variable 'v' not set" if ( v and not v.name ) then reason = "Variable 'v.name' not set" elseif ( v and v.name and groups [ v.name ] ) then reason = "Group already exists in table" else reason = "Undetected" end outputDebugString ( "NGGroups: Failed to load group ".. tostring ( v.name ).." - ".. tostring ( reason ), 1 ) end end local load = math.ceil ( getTickCount()-start ) local tLen = table.len ( groups ) outputDebugString ( "NGGroups: Successfully loaded "..tLen.." groups from the sql database ("..tostring(load).."MS - About "..math.floor(load/tLen).."MS/group)" ) end addEventHandler ( "onResourceStart", resourceRoot, loadGroups ) addEventHandler ( "onResourceStop", resourceRoot, saveGroups ) function getGroups ( ) return groups end addEvent ( "NGGroups->Events:onClientRequestGroupList", true ) addEventHandler ( "NGGroups->Events:onClientRequestGroupList", root, function ( ) local g = getGroups ( ) triggerClientEvent ( source, "NGGroups->onServerSendClientGroupList", source, g ) g = nil end ) ------------------------------ -- Group Creating -- ------------------------------ function createGroup ( name, color, type, owner ) if ( doesGroupExist ( name ) ) then return false end local id = 0 local ids = { } for i, v in pairs ( groups ) do ids [ v.info.id ] = true end while ( ids [ id ] ) do id = id + 1 end groups [ name ] = { info = { founder = owner, -- this CANNOT change founded_time = getThisTime ( ), desc = "", color = color, type = type, bank = 0, id = id }, members = { [owner] = { rank="Founder", joined=getThisTime ( ) } }, ranks = { ['Founder'] = { -- member access ['member_kick'] = true, ['member_invite'] = true, ['member_setrank'] = true, ['member_viewlog'] = true, -- General group changes ['group_modify_color'] = true, ['group_modify_motd'] = true, -- banks ['bank_withdraw'] = true, ['bank_deposit'] = true, -- logs ['logs_view'] = true, ['logs_clear'] = true, -- ranks ['ranks_create'] = true, ['ranks_delete'] = true, ['ranks_modify'] = true }, ["Member"] = { -- button access ['view_member_list'] = true, ['view_ranks'] = false, ['view_bank'] = true, -- member access ['member_kick'] = false, ['member_invite'] = false, ['member_setrank'] = false, -- General group changes ['group_modify_color'] = false, ['group_modify_motd'] = false, -- banks ['bank_withdraw'] = false, ['bank_deposit'] = true, -- logs ['logs_view'] = false, ['logs_clear'] = false, -- ranks ['ranks_create'] = false, ['ranks_delete'] = false, ['ranks_modify'] = false } }, log = { -- { time, log } { time=getThisTime ( ), account="Server", log="Group Created" } }, pendingInvites = { } } return true, groups [ name ] end ------------------------------ -- Group Deleting -- ------------------------------ function deleteGroup ( group ) if ( not doesGroupExist ( group ) ) then return false end local id = groups [ group ].info.id groups [ group ] = nil exports.NGSQL:db_exec ( "DELETE FROM groups WHERE id=?", tostring ( id ) ) exports.NGSQL:db_exec ( "DELETE FROM group_logs WHERE id=?", tostring ( id ) ) exports.NGSQL:db_exec ( "DELETE FROM group_members WHERE id=?", tostring ( id ) ) exports.NGSQL:db_exec ( "DELETE FROM group_rank WHERE id=?", tostring ( id ) ) exports.NGLogs:outputServerLog ( "Group "..tostring ( group ).." deleted" ) for i, v in pairs ( getElementsByType ( "player" ) ) do local gang = getElementData ( v, "Group" ) if ( gang == group ) then setElementData ( v, "Group", "None" ) setElementData ( v, "Group Rank", "None" ) end end exports.NGSQL:db_exec ( "UPDATE accountdata SET GroupName=?, GroupRank=? WHERE GroupName=?", "None", "None", tostring ( group ) ) end addEvent ( "NGGroups->Modules->Gangs->Force->DeleteGroup", true ) addEventHandler ( "NGGroups->Modules->Gangs->Force->DeleteGroup", root, deleteGroup ) addEvent ( "NGGroups->GEvents:onPlayerAttemptGroupMake", true ) addEventHandler ( "NGGroups->GEvents:onPlayerAttemptGroupMake", root, function ( data ) --[[ data = { name = "Group Name", type = "Group Type", color = { r = GroupColorR, g = GroupColorG, b = GroupColorB } } ]] if ( doesGroupExist ( data.name ) or tostring ( data.name ):lower() == "none" ) then return exports.ngmessages:sendClientMessage ( "A group with this name already exists", source, 255, 255, 0 ) end local created, __ = createGroup ( data.name, data.color, data.type, getAccountName ( getPlayerAccount ( source ) ) ) if ( created ) then setElementData ( source, "Group", data.name ); setElementData ( source, "Group Rank", "Founder" ); outputDebugString ( "CREATED GROUP "..tostring(data.name)..". Owner: "..getPlayerName(source) ); refreshPlayerGroupPanel ( source ) return true else outputDebugString ( "FAILED TO CREATE GROUP "..tostring(data.name).." FROM "..getplayerName(source) ); end return false end ) addEvent ( "NGGroups->gEvents:onPlayerDeleteGroup", true ) addEventHandler ( "NGGroups->gEvents:onPlayerDeleteGroup", root, function ( group ) deleteGroup ( group ) exports.NGLogs:outputActionLog ( getPlayerName(source).." ("..getAccountName(getPlayerAccount(source))..") deleted the group: "..tostring(group).." | id: "..tostring ( id ) ) refreshPlayerGroupPanel ( source ) end ) ------------------------------ -- Group Banking Functions -- ------------------------------ function getGroupBank ( group ) if ( groups [ group ] and groups [ group ].info ) then local a = groups [ group ].info.bank or 0 return a end return false end function setGroupBank ( group, money ) if ( groups [ group ] and groups [ group ].info ) then groups [ group ].info.bank = money local a = true return a end return false end function depositGroupBank(group, money) if (not groups[group]) then return end local balance = getGroupBank(group) or 0; setGroupBank(group, balance + money); return true; end addEvent ( "NGGroups:Module->Bank:returnBankBalanceToClient", true ) addEventHandler ( "NGGroups:Module->Bank:returnBankBalanceToClient", root, function ( group ) local bank = getGroupBank ( group ) or 0 triggerClientEvent ( source, "NGGroups:Module->Bank:onServerSendClientBankLevel", source, bank ) end ) addEvent ( "NGGroups:Modules->BankSys:onPlayerAttemptWithdawl", true ) addEventHandler ( "NGGroups:Modules->BankSys:onPlayerAttemptWithdawl", root, function ( group, amount ) if ( not doesGroupExist ( group ) ) then exports.ngmessages:sendClientMessage ( "Something went wrong with the server (Error Code: ngroup-1)", source, 255, 0, 0 ); setElementData ( source, "Group", "None" ); setElementData ( source, "Group Rank", "None" ); refreshPlayerGroupPanel ( source ); return false end local bank = getGroupBank ( group ); if ( amount > bank ) then return exports.ngmessages:sendClientMessage ( "Your group doesn't have $"..tostring(amount).." in their bank account", source, 255, 0, 0 ) end exports.ngmessages:sendClientMessage ( "You have withdrawn $"..tostring(amount).." from your groups bank... Actions logged", source, 0, 255, 0 ) givePlayerMoney ( source, amount ) setGroupBank ( group, bank - amount ) outputGroupLog ( group, "Withdrew $"..tostring(amount).." from the group bank", source ) end ) addEvent ( "NGGroups:Modules->BankSys:onPlayerAttemptDeposit", true ) addEventHandler ( "NGGroups:Modules->BankSys:onPlayerAttemptDeposit", root, function ( group, amount ) if ( not doesGroupExist ( group ) ) then exports.ngmessages:sendClientMessage ( "Something went wrong with the server (Error Code: ngroup-2)", source, 255, 0, 0 ); setElementData ( source, "Group", "None" ); setElementData ( source, "Group Rank", "None" ); refreshPlayerGroupPanel ( source ); return false end local m = source.money; if ( amount > m ) then return exports.ngmessages:sendClientMessage ( "You don't have $"..tostring(amount), source, 255, 0, 0 ) end exports.ngmessages:sendClientMessage ( "You deposited $"..tostring(amount).." into your group bank", source, 0, 255, 0 ) source.money = m - amount; outputGroupLog ( group, "Deposited $"..tostring(amount).." into the group bank", source ) setGroupBank ( group, getGroupBank ( group ) + amount ) end ) ------------------------------ -- Group Member Functions -- ------------------------------ function getPlayerGroup ( player ) local g = getElementData ( player, "Group" ) or "None" if ( g:lower ( ) == "none" ) then g = nil end return g end function refreshPlayerGroupPanel ( player ) triggerClientEvent ( player, "NGGroups->pEvents:onPlayerRefreshPanel", player ) player = nil end function setPlayerGroup ( player, group ) local acc = getPlayerAccount ( player ) if ( isGuestAccount ( acc ) ) then return false end if ( not group ) then group = "None" end if ( group ~= "None" ) then if ( not groups [ group ] ) then return false end end setElementData ( player, "Group", group ) if ( group == "None" ) then return setElementData ( player, "Group Rank", "None" ) else groups [ group ].members [ getAccountName ( acc ) ] = { rank="Member", joined=getThisTime() } return setElementData ( player, "Group Rank", "Member" ) end return false end addEvent ( "NGGroups->Modules->Gangs->kickPlayer", true ) addEventHandler ( "NGGroups->Modules->Gangs->kickPlayer", root, function ( group, account ) exports.ngsql:db_exec ( "UPDATE accountdata SET GroupName=?, GroupRank=? WHERE Username=?", "None", "None", account ) for i, v in pairs ( getElementsByType ( "player" ) ) do local a = getPlayerAccount ( v ) if ( not isGuestAccount ( a ) and getAccountName ( a ) == account ) then setElementData ( v, "Group", "None" ) setElementData ( v, "Group Rank", "None" ) outputChatBox ( "You got kicked from your group.", v, 255, 0, 0) break end end groups [ group ].members [ account ] = nil exports.ngmessages:sendClientMessage ( "You kicked "..tostring(account).." from "..tostring(group), source, 255, 255, 0 ) outputGroupLog ( group, "Kicked account "..tostring(account), source ) refreshPlayerGroupPanel ( source ) end ) addEvent ( "NGGroups->Modules->Groups->OnPlayerLeave", true ) addEventHandler ( "NGGroups->Modules->Groups->OnPlayerLeave", root, function ( g ) groups[g].members[getAccountName(getPlayerAccount(source))] = nil setPlayerGroup ( source, nil ) refreshPlayerGroupPanel ( source ) outputGroupLog ( g, "Has left the group", source ) end ) ------------------------------------------ -- Players -> Group Ranking Functions -- ------------------------------------------ function setAccountRank ( group, account, newrank ) local account, newrank = tostring ( account ), tostring ( newrank ) exports.ngsql:db_exec ( "UPDATE accountdata SET GroupRank=? WHERE Username=?", newrank, account ) groups[group].members[account].rank = newrank for i, v in pairs ( getElementsByType ( "player" ) ) do local a = getPlayerAccount ( v ) if ( a and not isGuestAccount ( a ) and a == account ) then setElementData ( v, "Group Rank", tostring ( newrank ) ) outputChatBox ( "You rank has been changed to "..tostring ( newrank ), v, 255, 255, 0) break end end return true end addEvent ( "NGGroups->Modules->Gangs->Ranks->UpdatePlayerrank", true ) addEventHandler ( "NGGroups->Modules->Gangs->Ranks->UpdatePlayerrank", root, function ( group, account, newrank ) if ( not groups[group] or not groups[group].ranks[newrank] ) then exports.ngmessages:sendClientMessage ( "Oops, something went wrong. Please try again", source, 255, 0, 0 ) refreshPlayerGroupPanel ( source ) return false end outputGroupLog ( group, "Changed "..account.."'s rank from "..groups[group].members[account].rank.." to "..newrank, source ) setAccountRank ( group, account, newrank ) exports.ngmessages:sendClientMessage ( "You have changed "..tostring ( account ).."'s rank!", source, 255, 255, 0) refreshPlayerGroupPanel ( source ) end ) function sendPlayerInvite ( player, group, inviter ) local a = getPlayerAccount ( player ) if ( isGuestAccount( a ) ) then return false end local a = getAccountName ( a ) if ( groups [ group ].pendingInvites [ a ] ) then return false end table.insert ( groups [ group ].pendingInvites, { to=getAccountName(getPlayerAccount(player)), inviter=getAccountName(getPlayerAccount(inviter)), time=getThisTime() } ); return true end addEvent ( "NGGroups->Modules->Groups->InvitePlayer", true ) addEventHandler ( "NGGroups->Modules->Groups->InvitePlayer", root, function ( group, plr ) local a = getPlayerAccount ( plr ) if ( isGuestAccount ( a ) ) then return exports.ngmessages:sendClientMessage ( "Your group request couldn't be sent to "..plr.name, source, 255, 0, 0 ) end local a = getAccountName ( a ) for _, info in pairs ( groups [ group ].pendingInvites ) do if ( info.to == a ) then return exports.ngmessages:sendClientMessage ( "This player is already invited by "..tostring(info.from), source, 255, 255, 0 ) end end outputGroupLog ( group, "Invited "..plr.name.." ("..a..")", source ) local r, g, b = getGroupColor ( group ); exports.ngmessages:sendClientMessage ( source.name.." invited you to "..group..". Accept it in F3", plr, r, g, b ) exports.ngmessages:sendClientMessage ( "You have invited "..plr.name.." to the group", source, r, g, b ) sendPlayerInvite ( plr, group, source ) end ) addEvent ( "NGGroups->Modules->Groups->Invites->OnPlayerDeny", true ) addEventHandler( "NGGroups->Modules->Groups->Invites->OnPlayerDeny", root, function ( g ) local a = getAccountName ( getPlayerAccount ( source ) ) groups [ g ].pendingInvites [ a ] = nil refreshPlayerGroupPanel ( source ) end ) addEvent ( "NGGroups->Modules->Groups->Invites->OnPlayerAccept", true ) addEventHandler ( "NGGroups->Modules->Groups->Invites->OnPlayerAccept", root, function ( g ) local a = getAccountName ( getPlayerAccount ( source ) ) for index, info in pairs ( groups [ g ].pendingInvites ) do if ( info.to == a ) then table.remove ( groups [ g ].pendingInvites, index ) end end groups [ g ].members [ a ] = { rank="Member", joined = getThisTime() } setPlayerGroup ( source, g ) outputGroupMessage ( getPlayerName ( source ).." has joined the group!", g ) refreshPlayerGroupPanel ( source ) end ) function addRankToGroup ( group, name, info ) if ( not groups [ group ] ) then return false end for i, v in pairs ( groups [ group ].ranks ) do if ( i:lower() == name:lower() ) then return false end end groups [ group ].ranks [ name ] = info return true end addEvent ( "NGGroups->Modules->Groups->Ranks->AddRank", true ) addEventHandler ( "NGGroups->Modules->Groups->Ranks->AddRank", root, function ( group, name, info ) outputGroupLog ( group, "Added rank '"..tostring(name).."'", source ) addRankToGroup ( group, name, info ) refreshPlayerGroupPanel ( source ) exports.ngmessages:sendClientMessage ( "The rank has been added.", source, 0, 255, 0 ) end ) function setGroupMotd ( group, motd ) if ( groups [ group ] ) then groups[group].info.desc = tostring ( motd ) return true end return false end addEvent ( "NGGroups->Modules->Groups->MOTD->Update", true ) addEventHandler ( "NGGroups->Modules->Groups->MOTD->Update", root, function ( g, mo ) outputGroupLog ( g, "Changed the group MOTD", source ) setGroupMotd ( g, mo ) refreshPlayerGroupPanel ( source ) end ) ------------------------------ -- Group Checking Functions -- ------------------------------ function doesGroupExist ( group ) local group = tostring ( group ):lower ( ) for i, v in pairs ( groups ) do if ( tostring ( i ):lower ( ) == group ) then group = nil return true end end group = nil return false end function isRankInGroup ( group, rank ) local group = tostring ( group ):lower ( ) for i, v in pairs ( groups ) do if ( i:lower() == group ) then if ( v.ranks and v.ranks [ rank ] ) then return true end break end end return false end ------------------------------ -- Group Logging -- ------------------------------ function groupClearLog ( group ) if ( groups [ group ] ) then groups [ group ].log = nil exports.NGSQL:db_exec ( "DELETE FROM group_logs WHERE id=?", groups[group].info.id ) groups [ group ].log = { } group = nil return true end group = nil return false end function outputGroupLog ( group, log, element ) if ( not groups[group] ) then return end if ( not groups[group].log ) then groups[group].log = { } end local e = "Server" if ( element ) then e = element if ( type ( element ) == "userdata" ) then if ( getElementType ( element ) == "player" ) then local a = getPlayerAccount ( element ) if ( not isGuestAccount ( a ) ) then e = getAccountName ( a ) end a = nil end end end table.insert ( groups[group].log, 1, { time=getThisTime(), account=e, log=log } ) end function getGroupLog ( group ) if ( group and groups [ group ] ) then local f = groups [ group ].log return f end end addEvent ( "NGGroups->GEvents:onPlayerClearGroupLog", true ) addEventHandler ( "NGGroups->GEvents:onPlayerClearGroupLog", root, function ( group ) groupClearLog ( group ) outputGroupLog ( group, "Cleared the logs", source ) refreshPlayerGroupPanel ( source ) -- memory sweep group = nil end ) addEvent( "NGGroups->GroupStaff:OnAdminDeleteGroup", true ); addEventHandler ( "NGGroups->GroupStaff:OnAdminDeleteGroup", root, function ( group ) exports.nglogs:outputActionLog ( "Staff "..source.name.." ("..source.account.name..") delete the '"..group.."' group" ); for _, p in pairs ( getElementsByType ( "player" ) ) do if ( tostring ( getElementData ( p, "Group" ) ) == group ) then outputChatBox ( "Admin "..tostring(source.name).." has deleted your group.", p, 255, 0, 0 ); end end deleteGroup ( group ); refreshPlayerGroupPanel ( source ); end ); ------------------------------ -- Misc Functions -- ------------------------------ function getThisTime ( ) local time = getRealTime ( ) local year = time.year + 1900 local month = time.month + 1 local day = time.monthday local hour = time.hour local min = time.minute local sec = time.second if ( month < 10 ) then month = 0 .. month end if ( day < 10 ) then day = 0 .. day end if ( hour < 10 ) then hour = 0 .. hour end if ( min < 10 ) then min = 0 .. min end if ( sec < 10 ) then sec = 0 .. sec end return table.concat ( { year, month, day }, "-") .. " "..table.concat ( { hour, min, sec }, ":" ) end function getGroupColor ( group ) local r, g, b = 0, 0, 0 if ( groups [ group ] ) then r, g, b = groups[group].info.color.r, groups[group].info.color.g, groups[group].info.color.b end return r, g, b end function setGroupColor ( group, r, g, b ) if ( groups [ group ] ) then groups[group].info.color.r = r groups[group].info.color.g = g groups[group].info.color.b = b exports.ngturf:updateTurfGroupColor ( group ) return true end return false end addEvent("NGGroups->Modules->Groups->Colors->UpdateColor",true) addEventHandler("NGGroups->Modules->Groups->Colors->UpdateColor",root,function(group,r,g,b) outputGroupLog ( group, "Changed group color to ".. table.concat ( { r, g, b }, ", " ), source ) setGroupColor ( group, r, g, b ) refreshPlayerGroupPanel ( source ) end ) function getGroupType ( name ) if ( doesGroupExist ( name ) ) then return groups [ name ].info.type; end return false; end function isRankInGroup ( group, rank ) if ( doesGroupExist ( group ) ) then if ( groups [ group ].ranks [ rank ] ) then return true end end return false end function outputGroupMessage ( message, group, blockTag ) local blockTag = blockTag or false if ( not blockTag ) then message = "("..tostring(group)..") "..tostring(message) end local r, g, b = getGroupColor ( group ) local group = tostring ( group ):lower ( ) for i, v in ipairs ( getElementsByType ( "player" ) ) do if ( tostring ( getElementData ( v, "Group" ) ):lower ( ) == group:lower() ) then outputChatBox ( message, v, r, g, b, true ) end end end function table.len ( t ) local c = 0 for i in pairs ( t ) do c = c + 1 end return c end -- group chat -- addCommandHandler ( "clanc", function ( plr, _, ... ) local message = table.concat ( { ... }, " " ) local g = getPlayerGroup ( plr ) if ( not g ) then return exports.ngmessages:sendClientMessage ( "You cannot use this command, you're not in a group", plr, 255, 0, 0 ) end if ( message:gsub ( " ", "" ) == "" ) then return exports.ngmessages:sendClientMessage ( "You didn't enter a message. Syntax: /clanc message", plr, 255, 0, 0 ) end outputGroupMessage("Group| ".. exports.ngchat:getChatLine ( plr, message ), g, true ) end ) When i set someone rank it good on gui but in scoreboard not change why?
  2. help e please why you ingore my post
  3. arresties = { } tased = { } addEventHandler ( "onPlayerDamage", root, function ( cop, weapon, _, loss ) -- arrest system if ( isElement ( cop ) and weapon and cop ~= source ) then if ( getElementData ( cop, "NGEvents:IsPlayerInEvent" ) or getElementData ( source, "NGEvents:IsPlayerInEvent" ) ) then return end if ( cop == source ) then return end if ( getElementType ( cop ) == 'vehicle' ) then cop = getVehicleOccupant ( cop ) end if ( not isElement ( cop ) or getElementType ( cop ) ~= 'player' ) then return end if ( not getPlayerTeam ( cop ) ) then return end if ( exports['NGPlayerFunctions']:isTeamLaw ( getTeamName ( getPlayerTeam ( cop ) ) ) ) then if ( getElementData ( source, "isSpawnProtectionEnabled" ) == true ) then return exports['NGMessages']:sendClientMessage ( "This player has spawn-protection enabled.", cop, 255, 0, 0 ) end if ( getPlayerTeam ( source ) and getTeamName ( getPlayerTeam ( source ) ) == "Staff" ) then return exports['NGMessages']:sendClientMessage ( "You cannot arrest/tase on-duty staff.", cop, 255, 0, 0 ) end if ( arresties[source] ) then return exports['NGMessages']:sendClientMessage ( "This player is already arrested.", cop, 255, 0, 0 ) end if ( getPlayerWantedLevel ( source ) >= 1 ) then if ( weapon == 3 ) then -- Arrest arrestPlayer ( source, cop ) exports['NGMessages']:sendClientMessage ( "You have arrested "..getPlayerName ( source )..", take him to a police station.", cop, 0, 255, 0 ) exports['NGMessages']:sendClientMessage ( getPlayerName ( cop ).." arrested you!", source, 255, 255, 0 ) setElementHealth ( source, getElementHealth ( source ) + loss ) setElementData ( source, "NGJobs:ArrestingOfficer", cop ) addEventHandler ( "onPlayerQuit", source, onPlayerAttmemptArrestAvoid ); elseif ( weapon == 23 ) then -- Taze Player if ( tased [ source ] ) then return exports.NGMessages:sendClientMessage ( "This player is already tased", cop, 255, 255, 255 ) end local a = cop local t = getPlayerTeam ( a ) if ( not t ) then return end if ( getPlayerWantedLevel ( source ) == 0 ) then return end if ( exports.NGPlayerFunctions:isTeamLaw ( getTeamName ( t ) ) and not getElementData ( source, "NGJobs:ArrestingOfficer" ) ) then -- now we know: -- source -> wanted, not arrested -- w -> teaser toggleAllControls ( source, false ) if ( isPedInVehicle ( source ) ) then removePedFromVehicle ( source ) end setPedAnimation(source, "CRACK", "crckdeth2", 4000, false, true, false) exports.NGMessages:sendClientMessage ( "You have tased ".. getPlayerName ( source ), a, 0, 255, 0 ) exports.NGMessages:sendClientMessage ( "You have been tased by "..getPlayerName ( a ), source, 255, 0, 0 ) tased [ source ] = true setTimer ( function ( p, c ) if ( isElement ( p ) ) then setPedAnimation ( p ) toggleAllControls ( p, true ) exports.NGMessages:sendClientMessage ( "You are no longer tased", p, 0, 255, 0 ) if ( isElement ( c ) ) then exports.NGMessages:sendClientMessage ( getPlayerName ( p ).." is now un-tased!", c, 255, 255, 0 ) end end tased [ p ] = false end, 4000, 1, source, a ) end else if ( isPedInVehicle ( cop ) ) then return end exports['NGMessages']:sendClientMessage ( "Use a nightstick to arrest and a silenced pistol to tase", cop, 255, 255, 255 ) end else local f = math.floor ( loss * 1.2) setElementHealth ( cop, getElementHealth ( cop ) - f ) exports['NGMessages']:sendClientMessage ( "You've lost "..tostring ( f ).."% health for hurting an innocent player.", cop, 255, 255, 0 ) end end end end ) function onPlayerAttmemptArrestAvoid ( ) --outputChatBox ( getPlayerName ( source ).. " attempted to arrest avoid" ) triggerEvent ( "ngpolice:onJailCopCrimals", getElementData ( source, "NGJobs:ArrestingOfficer" ) ) end addCommandHandler ( "release", function ( p, _, p2 ) if ( getPlayerTeam ( p ) and exports['NGPlayerFunctions']:isTeamLaw ( getTeamName ( getPlayerTeam ( p ) ) ) ) then if ( p2 ) then local c = getPlayerFromName ( p2 ) or exports['NGPlayerFunctions']:getPlayerFromNamePart ( p2 ) if c then if ( arresties[c] ) then if ( getElementData ( c, "NGJobs:ArrestingOfficer") == p ) then exports['NGMessages']:sendClientMessage ( "You have released "..getPlayerName ( c ), p, 0, 255, 0) exports['NGMessages']:sendClientMessage ( getPlayerName ( p ).." released you.", c, 0, 255, 0 ) releasePlayer ( c ) local arresties2 = { } for i, v in pairs ( arresties ) do if ( getElementData ( v, "NGJobs:ArrestingOfficer" ) == p ) then table.insert ( arresties2, v ) end end triggerClientEvent ( root, "onPlayerEscapeCop", root, c, p, arresties2 ) else exports['NGMessages']:sendClientMessage ( "You're not "..getPlayerName ( c ).."'s arresting officer, you cannot release him.", p, 255, 255, 0 ) end else exports['NGMessages']:sendClientMessage ( getPlayerName ( c ).." isn't being arrested", p, 255, 255, 0 ) end else exports['NGMessages']:sendClientMessage ( p2.." doesn't exist. ", p, 255, 255, 0 ) end else exports['NGMessages']:sendClientMessage ( "Syntax error. /release [player]", p, 255, 255, 0 ) end else exports['NGMessages']:sendClientMessage ( "You're not a law officer.", p, 255, 255, 0 ) end end ) function arrestPlayer ( crim, cop ) showCursor ( crim, true ) arresties[crim] = true toggleControl ( crim, 'right', false ) toggleControl ( crim, 'left', false ) toggleControl ( crim, 'forwards', false ) toggleControl ( crim, 'backwards', false ) toggleControl ( crim, 'jump', false ) toggleControl ( crim, 'sprint', false ) toggleControl ( crim, 'walk', false ) toggleControl ( crim, 'fire', false ) onTimer ( crim, cop ) triggerClientEvent ( root, "onPlayerStartArrested", root, crim, cop ) end function onTimer ( crim, cop ) if ( isElement ( crim ) and isElement ( cop ) ) then if ( not getPlayerTeam ( cop ) or not exports['NGPlayerFunctions']:isTeamLaw ( getTeamName ( getPlayerTeam ( cop ) ) ) ) then return releasePlayer ( crim ) end if ( not arresties[crim] ) then return end local cx, cy, cz = getElementPosition ( crim ) local px, py, pz = getElementPosition ( cop ) local rot = findRotation ( cx, cy, px, py ) setPedRotation ( crim, rot ) setCameraTarget ( crim, crim ) local dist = getDistanceBetweenPoints3D ( cx, cy, cz, px, py, pz ) if ( isPedInVehicle ( cop ) ) then if ( not isPedInVehicle ( crim ) ) then warpPedIntoVehicle ( crim, getPedOccupiedVehicle ( cop ), 1 ) end else if ( isPedInVehicle ( crim ) ) then removePedFromVehicle ( crim ) end end if ( not isPedInVehicle ( crim ) ) then if ( dist >= 20 ) then setElementPosition ( crim, px +1, py+1, pz ) elseif ( dist >= 15 ) then setControlState ( crim, 'walk', false ) setControlState ( crim, 'jump', true ) setControlState ( crim, 'sprint', true ) setControlState ( crim, "forwards", true ) elseif ( dist >= 10 ) then setControlState ( crim, 'walk', false ) setControlState ( crim, 'jump', false ) setControlState ( crim, 'sprint', true ) setControlState ( crim, "forwards", true ) elseif ( dist >= 7 ) then setControlState ( crim, 'walk', false ) setControlState ( crim, 'jump', true ) setControlState ( crim, 'sprint', false ) setControlState ( crim, "forwards", true ) elseif ( dist >= 2 ) then setControlState ( crim, 'walk', true ) setControlState ( crim, 'jump', false ) setControlState ( crim, 'sprint', false ) setControlState ( crim, "forwards", true ) else setControlState ( crim, 'walk', false ) setControlState ( crim, 'jump', false ) setControlState ( crim, 'sprint', false ) setControlState ( crim, "forwards", false ) end end crim.interior = cop.interior; crim.dimension = cop.dimension setTimer ( onTimer, 500, 1, crim, cop ) else arresties[crim] = false if ( not isElement ( cop ) and isElement ( crim ) ) then releasePlayer ( crim ) exports['NGMessages']:sendClientMessage ( "Your arresting officer has quit, therefore, you've been released.", crim, 0, 255, 0 ) end end 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; return t; end function releasePlayer ( p ) toggleAllControls ( p, true ) setControlState ( p, 'walk', false ) setControlState ( p, 'jump', false ) setControlState ( p, 'sprint', false ) setControlState ( p, "forwards", true ) setElementData ( p, "NGJobs:ArrestingOfficer", nil ) arresties[p] = nil showCursor ( p, false ) removeEventHandler ( "onPlayerQuit", p, onPlayerAttmemptArrestAvoid ); end function onJailCopCriminals( ) for v, _ in pairs ( arresties ) do if ( getElementData ( v, "NGJobs:ArrestingOfficer" ) == source ) then releasePlayer ( v ) local time = math.floor ( ( getElementData ( v, "WantedPoints" ) * 2 ) or 50 ) local orgTime = time local vip = getElementData ( v, "VIP" ) if ( exports.NGVIP:getVipLevelFromName ( vip ) == 4 ) then time = time - ( time * 0.5 ) exports.NGMessages:sendClientMessage ( "You're serving 50% less jail time due to premium VIP! (Original time: "..orgTime.." seconds)", v, 0, 255, 0 ) elseif ( exports.NGVIP:getVipLevelFromName ( vip ) == 3 ) then time = time - ( time * 0.25 ) exports.NGMessages:sendClientMessage ( "You're serving 25% less jail time due to gold VIP! (Original time: "..orgTime.." seconds)", v, 0, 255, 0 ) elseif ( exports.NGVIP:getVipLevelFromName ( vip ) == 2 ) then time = time - ( time * 0.15 ) exports.NGMessages:sendClientMessage ( "You're serving 15% less jail time due to silver VIP! (Original time: "..orgTime.." seconds)", v, 0, 255, 0 ) elseif ( exports.NGVIP:getVipLevelFromName ( vip ) == 1 ) then time = time - ( time * 0.05 ) exports.NGMessages:sendClientMessage ( "You're serving 5% less jail time due to bronze VIP! (Original time: "..orgTime.." seconds)", v, 0, 255, 0 ) end local time = math.floor ( time ) givePlayerMoney ( source, math.floor ( orgTime*2 ) ) exports['NGMessages']:sendClientMessage ( "You were paid $"..math.floor ( orgTime*2 ).." for arresting "..getPlayerName ( v ).."!", source, 0, 255, 0 ) exports['NGPolice']:jailPlayer ( v, time, false, source, "Police Arrest" ) updateJobColumn ( getAccountName ( getPlayerAccount ( source ) ), "Arrests", "AddOne" ) end end end addEvent ( "ngpolice:onJailCopCrimals", true ) addEventHandler ( "ngpolice:onJailCopCrimals", root, onJailCopCriminals ) -- Prevent arrest avoid by disconnect addEventHandler ( "onPlayerLeave", root, function ( ) if ( arresties [ source ] ) then end end ); I want to release the player when a officer die and not follow him when he dies ty
  4. function job_trailerAttach(veh) cancelEvent() detachTrailerFromVehicle(veh, source) end addEventHandler("onTrailerAttach", getRootElement(), job_trailerAttach)
  5. Dimos7

    [HELP] Markers

    I dont want change it i want it like this
  6. data = { -- Free: { x, y, z [, rz=0, sx=x, sy=y, sz=y ] } ['Free'] = { { 1538.88, -1686.07, 13.55, 90 }, { 1188.35, -1331.75, 13.56 }, { 2034.61, -1437.47, 17.32, 140 }, { 1374.35, 416.79, 19.78, 68.7 }, { 1624.37, 1817.87, 10.82 }, { 2578.49, 1978.19, 10.82, -90 }, { -331.47, 1063.28, 19.74, -90 }, { -1504.19, 2533.95, 55.69, 90 }, { -2641.08, 620.4, 14.45, 90 }, { -2206.39, -2299.49, 30.63, 324 }, { -1568.97, 653.7, 7.19, 180 }, { 2242.02, 26.46, 26.44 }, { 1682.8000488281, -2248.1999511719, 13. }, { -1404.3000488281, -314.10000610352, 13.9 }, { 1714.5, 1471.5, 10.5 }, { 2219.5, 2441.3000488281, 10.5 }, }, ---- END OF FREE -- Start of Jobs -- -- { job, x, y, z, { r, g, b } [, rz=0, sx=x, sy=y, sz=y ] } ['Jobs'] = { { "Criminal", 2138.91, -1727.17, 13.54, { 255, 50, 50 }, -90 }, { "Criminal", 1619.44, -1515.73, 13.58, { 255, 50, 50 }, 180 }, { "Criminal", -1850.41, 587.29, 35.16, { 255, 50, 50 }, 0 }, { "Criminal", -2530.29, -602.73, 132.56, { 255, 50, 50 }, 180 }, { "Criminal", 1995.12, 2298.61, 10.81, { 255, 50, 50 }, 90 }, { "Criminal", 2449.5, 1328.18, 10.82, { 255, 50, 50 }, 0 }, { "Criminal", 2130.48, 887.71, 10.81, { 255, 50, 50 }, 0 }, { "Mechanic", 2283.34, -2350.81, 13.55, { 255, 255, 0 }, 41.5 }, { "Mechanic", -1705.72, 389.96, 7.18, { 255, 255, 0 }, 230.3 }, { "Mechanic", 1657.99, 2195.29, 10.82, { 255, 255, 0 }, 90 }, { "Medic", 1179.02, -1339.01, 13.86, { 0, 255, 255 }, -90 }, { "Medic", 1179.02, -1309, 13.86, { 0, 255, 255 }, -90 }, { "Medic", 1590.05, 1820.54, 10.82, { 0, 255, 255 }, 0 }, { "Police Officer", 1555.09, -1610.62, 13.38, { 0, 100, 255 }, 180 }, { "Police Officer", 1565, -1610.62, 13.38, { 0, 100, 255 }, 180 }, { "Police Officer", 1575, -1610.62, 13.38, { 0, 100, 255 }, 180 }, { "Police Officer", -1612.39, 674.73, 7.19, { 0, 100, 255 }, 180 }, { "Police Officer", -1606, 674.73, 7.19, { 0, 100, 255 }, 180 }, { "Police Officer", -1600.5, 674.73, 7.19, { 0, 100, 255 }, 180 }, { "Police Officer", -1594.2, 674.73, 7.19, { 0, 100, 255 }, 180 }, { "Police Officer", -1587.7, 674.73, 7.19, { 0, 100, 255 }, 180 }, { "Police Officer", 2251.78, 2477.21, 10.82, { 0, 100, 255 }, 180 }, { "Police Officer", 2256.34, 2477.21, 10.82, { 0, 100, 255 }, 180 }, { "Police Officer", 2259.96, 2477.21, 10.82, { 0, 100, 255 }, 180 }, { "Police Officer", 2269.49, 2477.21, 10.82, { 0, 100, 255 }, 180 }, { "Police Officer", 2273.05, 2477.21, 10.82, { 0, 100, 255 }, 180 }, { "Police Officer", 2277.39, 2477.21, 10.82, { 0, 100, 255 }, 180 }, { "Police Officer", 2281.58, 2477.21, 10.82, { 0, 100, 255 }, 180 }, { "Military", 3314.8999023438, -1960.9000244141, 27.3, { 0, 128, 0 }, 90 }, { "Military", 3309, -1963.3000488281, 11.3, { 0, 128, 0 }, 90 }, { "Military", 3466.8000488281, -1863.5999755859, 25.3, { 0, 128, 0 }, 180 }, { "Military", 2251.89, 2442.97, 10.82, { 0, 128, 0 }, 180 }, { "ZETAS", -2073.06, 1466.9, 13.05, { 0, 0, 0 }, 180 }, { "ZETAS", -2178.06, 1450.22, 20.09, { 0, 0, 0 }, 90 }, { "SWAT", 861.39605712891, -1984.6593017578, 12.620330047607, { 0, 0, 255 }, 0 }, { "SWAT", 905.19989013672, -2053.8337402344, 35.600001525879, { 0, 0, 255 }, 90 }, { "SWAT", 904.6220703125, -1957.6130371094, 45.528125, { 0, 0, 255 }, 0 }, { "SWAT", 2260.11, 2442.97, 10.82, { 0, 0, 255 }, 0 }, { "Terrorists", -70.295547485352, -1758.0194091797, 10.0921878814697, { 255, 140, 0 }, -90 }, { "Terrorists", -97.74853515625, -1836.6586914063, 4.0843750953674, { 255, 140, 0 }, -90 }, { "Pilot", 1983.21, -2301.92, 13.55, { 255, 255, 0 }, 90 }, { "Pilot", -1243.48, -26.32, 14.15, { 255, 255, 0 }, 131 }, { "Pilot", -1257.59, -12.07, 14.15, { 255, 255, 0 }, 131 }, { "Pilot",1638.02, 1548.39, 10.8, { 255, 255, 0 }, 50 }, { "Stunter", 1945.67, -1378, 18.58, { 200, 200, 0 }, 90 }, } } jobSettings = { ["Military"] = { group = "Military" }, ["SWAT"] = { group = "SWAT" }, ["Terrorists"] = { group = "Terrorists" }, ["ZETAS"] = { group = "ZETAS" } } JobVehicles = { ['Free'] = { 412, 457, 468 }, ['Criminal'] = { 522, 459 }, ['Terrorists'] = { 522, 411, 470, 433, 432, 425, 520 }, ['Mechanic'] = { 525 }, ['Police Officer'] = { 596, 597, 598, 599, 560 }, ['Military'] = { 522, 411, 470, 433, 432, 425, 520 }, ['ZETAS'] = { 411, 546, 522, 506, 603, 519 }, ['SWAT'] = { 522, 411, 470, 433, 432, 425, 520 }, ['Medic'] = { 416 }, ['Fisherman'] = { 453 }, ['Detective'] = { 596, 597, 598, 599, 560 }, ['Pilot'] = { 519, 513 }, ['Stunter'] = { 481 } } VipVehicles = { [0] = { }, -- None [1] = { 522 }, -- Bronze [2] = { 522, 560 }, -- Silver [3] = { 522, 560, 546, 411 }, -- gold [4] = { 522, 560, 546, 411 } -- diamond } local sx, sy = guiGetScreenSize ( ) local rsx, rsy = sx / 1280, sy / 1024 local window = guiCreateWindow( ( sx / 2 - ( rsx*354 ) / 2 ), ( sy / 2 - (rsy*400) / 2 ), (rsx*354), (rsy*400), "Spawners", false) local vehList = guiCreateGridList((rsx*9), (rsy*26), (rsx*335), (rsy*315), false, window) local btnSpawn = guiCreateButton((rsx*13), (rsy*346), (rsx*149), (rsy*43), "Spawn", false, window) local btnClose = guiCreateButton((rsx*195), (rsy*346), (rsx*149), (rsy*43), "Cancel", false, window) guiWindowSetSizable(window, false) guiSetVisible ( window, false ) guiGridListAddColumn(vehList, "Vehicle", 0.9) local marker = nil addEvent ( "NGSpawners:ShowClientSpawner", true ) addEventHandler ( "NGSpawners:ShowClientSpawner", root, function ( cars, mrker ) if ( wasEventCancelled ( ) ) then return end if ( not guiGetVisible ( window ) ) then bindKey ( "space", "down", spawnClickingFunctions ) showCursor ( true ) guiSetVisible ( window, true ) guiGridListClear ( vehList ) addEventHandler ( 'onClientMarkerLeave', mrker, closeWindow ) marker = mrker job = getElementData ( marker, "NGVehicles:JobRestriction" ) guiGridListSetItemText ( vehList, guiGridListAddRow ( vehList ), 1, "Free Vehicles", true, true ) for i, v in ipairs ( cars ) do local name = getVehicleNameFromModel ( v ) local row = guiGridListAddRow ( vehList ) guiGridListSetItemText ( vehList, row, 1, name, false, false ) guiGridListSetItemData ( vehList, row, 1, v ) end if ( exports.NGVIP:isPlayerVIP ( ) ) then local level = exports.NGVIP:getVipLevelFromName ( getElementData ( localPlayer, "VIP" ) ) if ( level and level > 0 and VipVehicles [ level ] and #VipVehicles [ level ] > 0 ) then guiGridListSetItemText ( vehList, guiGridListAddRow ( vehList ), 1, "VIP Vehicles", true, true ) for i, v in pairs ( VipVehicles [ level ] ) do local name = getVehicleNameFromModel ( v ) local row = guiGridListAddRow ( vehList ) guiGridListSetItemText ( vehList, row, 1, name, false, false ) guiGridListSetItemData ( vehList, row, 1, v ) end end end guiGridListSetSelectedItem ( vehList, 0, 1 ) addEventHandler ( "onClientGUIClick", btnSpawn, spawnClickingFunctions ) addEventHandler ( "onClientGUIClick", btnClose, spawnClickingFunctions ) end end ) function spawnClickingFunctions ( ) if ( source == btnClose ) then closeWindow ( localPlayer ) elseif ( source == btnSpawn ) or getKeyState( "space" ) == true then local row, col = guiGridListGetSelectedItem ( vehList ) if ( row == -1 ) then return exports['NGMessages']:sendClientMessage ( "Select a vehicle to be spawn.", 255, 255, 0 ) end local id = guiGridListGetItemData ( vehList, row, 1 ) triggerServerEvent ( "NGSpawners:spawnVehicle", localPlayer, id, marker, true ) closeWindow ( localPlayer ) end end function closeWindow ( p ) if ( not p or p == localPlayer ) then removeEventHandler ( 'onClientMarkerLeave', marker, closeWindow ) marker = nil guiSetVisible ( window, false ) showCursor ( false ) guiGridListClear ( vehList ) removeEventHandler ( "onClientGUIClick", btnSpawn, spawnClickingFunctions ) removeEventHandler ( "onClientGUIClick", btnClose, spawnClickingFunctions ) unbindKey ( "space", "down", spawnClickingFunctions ) end end addEvent ( "NGSpawners:CloseWindow", true ) addEventHandler ( "NGSpawners:CloseWindow", root, closeWindow ) I want to make some militrary marker to only have plane and helicopter and other have the other vehicles isElementWithMarker need name for marker?
  7. It will be good if that functions made shared setVehicleWindowOpen isVehicleWindowOpen
  8. local WARP_LOCS = { DEFAULT = { }, ADMIN = { }, RELEASE = {} } addEventHandler ( "onResourceStart", resourceRoot, function ( ) local warp_default = get ( "*JAIL_WARP_LOCATION" ); local warp_admin = get ( "*JAIL_WARP_ADMIN_LOCATION" ); local warp_release = get ( "*JAIL_WARP_RELEASE_LOCATION" ); if ( not warp_default ) then outputDebugString ( "Couldn't find '*JAIL_WARP_LOCATION' setting in NGPolice" ); WARP_LOCS.DEFAULT = { 0, 0, 0 } else local warp_default = split ( warp_default, "," ); if ( #warp_default ~= 3 ) then outputDebugString ( "'*JAIL_WARP_LOCATION' setting value should be x,y,z (no spaces, please confirm format is correct)" ); WARP_LOCS.DEFAULT = { 0, 0, 0 } elseif ( not tonumber ( warp_default[1] ) or not tonumber ( warp_default[2] ) or not tonumber ( warp_default[3] ) ) then outputDebugString ( "Failed to convert all '*JAIL_WARP_LOCATION' coordinates to floats. Please confirm they are numbers" ); WARP_LOCS.DEFAULT = { 0, 0, 0 } else WARP_LOCS.DEFAULT = { tonumber(warp_default[1]), tonumber(warp_default[2]), tonumber(warp_default[3]) }; end end if ( not warp_release ) then outputDebugString ( "Couldn't find '*JAIL_WARP_RELEASE_LOCATION' setting in NGPolice" ); WARP_LOCS.RELEASE = { 0, 0, 0 } else local warp_release = split ( warp_release, "," ); if ( #warp_release ~= 3 ) then outputDebugString ( "'*JAIL_WARP_RELEASE_LOCATION' setting value should be x,y,z (no spaces, please confirm format is correct)" ); WARP_LOCS.RELEASE = { 0, 0, 0 } elseif ( not tonumber ( warp_release[1] ) or not tonumber ( warp_release[2] ) or not tonumber ( warp_release[3] ) ) then outputDebugString ( "Failed to convert all '*JAIL_WARP_RELEASE_LOCATION' coordinates to floats. Please confirm they are numbers" ); WARP_LOCS.RELEASE = { 0, 0, 0 } else WARP_LOCS.RELEASE = { tonumber(warp_release[1]), tonumber(warp_release[2]), tonumber(warp_release[3]) }; end end if ( not warp_admin ) then outputDebugString ( "Couldn't find '*JAIL_WARP_ADMIN_LOCATION' setting in NGPolice" ); WARP_LOCS.ADMIN = { 0, 0, 0 } else local warp_admin = split ( warp_admin, "," ); if ( #warp_admin ~= 3 ) then outputDebugString ( "'*JAIL_WARP_ADMIN_LOCATION' setting value should be x,y,z (no spaces, please confirm format is correct)" ); WARP_LOCS.ADMIN = { 0, 0, 0 } elseif ( not tonumber ( warp_admin[1] ) or not tonumber ( warp_admin[2] ) or not tonumber ( warp_admin[3] ) ) then outputDebugString ( "Failed to convert all '*JAIL_WARP_ADMIN_LOCATION' coordinates to floats. Please confirm they are numbers" ); WARP_LOCS.ADMIN = { 0, 0, 0 } else WARP_LOCS.ADMIN = { tonumber(warp_admin[1]), tonumber(warp_admin[2]), tonumber(warp_admin[3]) }; end end outputDebugString ( "Default jail warp location: "..tostring ( table.concat( WARP_LOCS.DEFAULT, ", " ) ) ) outputDebugString ( "Admin jail warp location: "..tostring ( table.concat( WARP_LOCS.ADMIN, ", " ) ) ) outputDebugString ( "Release jail warp location: "..tostring ( table.concat( WARP_LOCS.RELEASE, ", " ) ) ) end ) local jailedPlayers = { } function getPlayerArea(p) if isElement(p) and getElementType(p) == "player" then x, y, z = getElementPosition(p) city = getZoneName(x, y, z, true) end end function isPlayerJailed ( p ) if ( p and getElementType ( p ) == 'player' ) then if ( jailedPlayers[p] ) then return tonumber ( getElementData ( p, 'NGPolice:JailTime' ) ) else return false end end return nil end function jailPlayer ( p, dur, announce, element, reason ) if( p and dur ) then local announce = announce or false jailedPlayers[p] = dur setElementInterior ( p, 0 ) setElementDimension ( p, 33 ) local __x, __y, __z = unpack ( WARP_LOCS.DEFAULT ) if ( element and reason ) then __x, __y, __z = unpack ( WARP_LOCS.ADMIN ) end setElementPosition ( p, __x, __y, __z ) if isPedInVehicle then removePedFromVehicle(p) setElementPosition ( p, __x, __y, __z ) end --outputChatBox ( table.concat ( { __x, __y, __z }, ", " ) ); setElementData(p, "WantedPoints", getElementData(p, "WantedPoints")*0) setElementData ( p, 'NGPolice:JailTime', tonumber ( dur ) ) setElementData ( p, "isGodmodeEnabled", true ) exports['NGJobs']:updateJobColumn ( getAccountName ( getPlayerAccount ( p ) ), 'TimesArrested', "AddOne" ) if ( announce ) then local reason = reason or "Classified" local msg = "" if ( element and reason ) then msg = getPlayerName ( p ).." has been jailed by "..getPlayerName ( element ).." for "..tostring ( dur ).." seconds ("..reason..")" elseif ( element ) then msg = getPlayerName ( p ).." has been jailed by "..getPlayerName ( element ).." for "..tostring ( dur ).." seconds" end outputChatBox( msg, root, 255, 0, 0 ) exports['NGLogs']:outputPunishLog ( p, element or "Console", tostring ( msg ) ) end triggerEvent ( "onPlayerArrested", p, dur, element, reason ) triggerClientEvent ( p, "onPlayerArrested", p, dur, element, reason ) return true end return false end function unjailPlayer ( p, triggerClient ) local p = p or source setElementDimension ( p, 0 ) setElementInterior ( p, 0 ) if city == "Los Santos" then setElementPosition ( p, 1543.32, -1675.6, 13.56 ) elseif city == "San Fierro" then setElementPosition(p, -1629.84, 675.85, 7.19) elseif city == "Las Venturas" then setElementPosition(p, 2246.84, 2452.95, 10.8) end exports["NGMessages"]:sendClientMessage( "You've been released from jail! Behave next time.", p, 0, 255, 0 ) jailedPlayers[p] = nil setElementData ( p, "NGPolice:JailTime", nil ) setElementData ( p, "isGodmodeEnabled", nil ) exports['NGLogs']:outputActionLog ( getPlayerName ( p ).." has been unjailed" ) if ( triggerClient ) then triggerClientEvent ( p, 'NGJail:StopJailClientTimer', p ) end end addEvent ( "NGJail:UnjailPlayer", true ) addEventHandler ( "NGJail:UnjailPlayer", root, unjailPlayer ) function getJailedPlayers ( ) return jailedPlayers end addCommandHandler ( "jail", function ( p, _, p2, time, ... ) if ( exports['NGAdministration']:isPlayerStaff ( p ) ) then if ( p2 and time ) then local toJ = getPlayerFromName ( p2 ) or exports['NGPlayerFunctions']:getPlayerFromNamePart ( p2 ) if toJ then jailPlayer ( toJ, time, true, p, table.concat ( { ... }, " " ) ) else exports['NGMessages']:sendClientMessage ( "No player found with \""..p2.."\" in their name.", p, 255, 0, 0 ) end else exports['NGMessages']:sendClientMessage ( "Syntax: /jail [player name/part of name] [seconds] [reason]", p, 255, 255, 0 ) end end end ) addCommandHandler ( "unjail", function ( p, _, p2 ) if ( not exports['NGAdministration']:isPlayerStaff ( p ) ) then return false end if ( not p2 ) then return exports['NGMessages']:sendClientMessage ( "Syntax: /unjail [player]", p, 255, 255, 0 ) end if ( not getPlayerFromName ( p2 ) ) then p2 = exports['NGPlayerFunctions']:getPlayerFromNamePart ( p2 ) if not p2 then return exports['NGMessages']:sendClientMessage ( "That player doesn't exist on the server.", p, 255, 0, 0 ) end end if ( jailedPlayers[p2] ) then outputChatBox ( "You've unjailed "..getPlayerName ( p2 ).."!", p, 0, 255, 0 ) outputChatBox ( "You've been unjailed by "..getPlayerName ( p ).."!", p2, 0, 255, 0 ) unjailPlayer ( p2, true ) else exports['NGMessages']:sendClientMessage ( "That player isn't jailed.", p, 255, 0, 0 ) end end ) addEventHandler ( "onResourceStop", resourceRoot, function ( ) exports['NGSQL']:saveAllData ( false ) end ) addEventHandler ( "onResourceStart", resourceRoot, function ( ) setTimer ( function ( ) local q = exports['NGSQL']:db_query ( "SELECT * FROM accountdata" ) local data = { } for i, v in ipairs ( q ) do data[v['Username']] = v['JailTime'] end for i, v in pairs ( data ) do local p = exports['NGPlayerFunctions']:getPlayerFromAco:O ( i ) if p then local t = tonumber ( getElementData ( p, 'NGPolice:JailTime' ) ) or i jailPlayer ( p, tonumber ( t ), false ) end end end, 500, 1 ) end ) addEvent ( "onPlayerArrested", true ) jail work find i want when a player was in lv for example spawn there say lv etc for the other city but not work it spawn it in ls in middle of air a mullholand intersection any idea why?
  9. Dimos7

    [HELP]VIP

    Thank you i will try it
  10. Dimos7

    [HELP]VIP

    Hello there i have a VIP system and i want to give nos to vehicle for some name of vip and jet pack but its not working print_ = print print = outputChatBox exports.scoreboard:scoreboardAddColumn ( "VIP", root, 50, "VIP", 12 ) 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.NGMessages:sendClientMessage ( "This command is for VIP users only", p, 255, 0, 0 ) end if ( isPlayerMuted ( p ) ) then return exports.NGMessages: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.NGMessages: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.NGMessages:sendClientMessage ( "Syntax: /"..tostring(cmd).." [message]", p, 255, 255, 0 ) end local tags = "(VIP)"..tostring(exports.NGChat:getPlayerTags ( p )) local msg = tags..getPlayerName ( p )..": #ffffff"..msg for i,v in pairs ( getElementsByType ( 'player' ) ) do if ( ( isPlayerVIP ( v ) or exports.NGAdministration: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, "NGVIP.expDate" ) or "0000-00-00" -- Format: YYYY-MM-DD if ( isDatePassed ( expDate ) ) then setElementData ( p, "VIP", "None" ) setElementData ( p, "NGVIP.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] = 25000, [2] = 50000, [3] = 100000, [4] = 150000 } VipPayoutTimer = setTimer ( function ( ) exports.NGLogs: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.NGMessages: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 - $25000/hour - 5% less jail time Silver: - Laser - Able to warp your vehicle to you - Additional 6 vehicles in spawners - $50000/hour - 15% less jail time Gold: - Laser - Able to warp your vehicle to you - Additional 6 vehicles in spawner - $100000/hour - %25 less jail time diamond: - Laser - Able to warp your vehicle to you - Additional 6 vehicles in spawners - $150000/hour - Half jail time ]] function giveVIPNOS(p) if isPlayerVIP(p) then local level = getVipLevelFromName(getElementData(p,"VIP")) if level == "bronze" then addVehicleupgrade(source, 1009) elseif level == "silver" then addVehicleupgrade(source, 1008) elseif level == "premium" then addVehicleupgrade(source, 1010) end end end addEventHandler("onVehicleEnter", root, giveVIPNOS) function giveVIPJetPack(p) if isPlayerVIP(p) then local level = getVipLevelFromName(getElementData(p,"VIP")) if level == "gold" or level == "premium" then if not doesPedHaveJetPack(p) then givePedJetPack(p) else removePedJetPack(p) end else return exports["NGMessages"]:sendClientMessage("You are not gold vip or premium!", p, 255, 0, 0) end else return exports["NGMessages"]:sendClientMessage("You are not vip !", p, 255, 0, 0) end end bindKey(source, "j", "both", giveVIPJetPack)
  11. --- i want this str = "Level "..tostring(i) local staff = { ['Level 1'] = {"Trial Staff"} , ['Level 2'] = {"Moderator"} , ['Level 3'] = {"Super Moderator"}, ['Level 4'] = {"Co- Ownwer"}, ['Level 5'] = {"Ownwer"} , } -- apear that
  12. i want to apear the Trial Staff Instead of Level 1 and so on for next ranks
  13. function isPlayerStaff ( p ) if ( p and getElementType ( p ) == 'player' ) then if ( isPlayerInACL ( p, "Level 1" ) or isPlayerInACL ( p, "Level 2" ) or isPlayerInACL ( p, "Level 3" ) or isPlayerInACL ( p, "Level 4" ) or isPlayerInACL ( p, "Level 5" ) or isPlayerInACL ( p, "Admin" ) or isPlayerInACL ( p, "Console" ) ) then return true end return false end end function getPlayerStaffLevel ( p, var ) if ( isPlayerStaff ( p ) ) then local str = nil local num = nil for i=1,5 do if ( isPlayerInACL ( p, 'Level '..tostring ( i ) ) ) then num = i str = "Level "..tostring(i) break end end if ( var == 'string' ) then return str elseif ( var == 'int' ) then return num else return str, num end end return 0,0 end function getAllStaff ( ) local staff = { ['Level 1'] = {"Trial Staff"} , ['Level 2'] = {"Moderator"} , ['Level 3'] = {"Super Moderator"}, ['Level 4'] = {"Co- Ownwer"}, ['Level 5'] = {"Ownwer"} , } for i=1,5 do for k, v in ipairs ( aclGroupListObjects ( aclGetGroup ( "Level "..tostring ( i ) ) ) ) do if ( string.find ( tostring ( v ), 'user.' ) ) then local name = tostring ( v:gsub ( "user.", "" ) ) staff['Level '..tostring ( i )][#staff['Level '..tostring ( i )]+1] = name end end end return staff end function isPlayerInACL ( player, acl ) local account = getPlayerAccount ( player ) if ( isGuestAccount ( account ) ) then return false end if ( aclGetGroup ( acl ) ) then return isObjectInACLGroup ( "user."..getAccountName ( account ), aclGetGroup ( acl ) ) end return false; end function getOnlineStaff ( ) local online = { } for i, v in ipairs ( getElementsByType ( "player" ) ) do if ( isPlayerStaff ( v ) ) then table.insert ( online, v ) end end return online end -- NG 1.1.4 -- -- Set element data to make getting staff on client side -- function setNewPlayerStaffData ( p ) if ( isPlayerStaff ( p ) ) then setElementData ( p, "staffLevel", getPlayerStaffLevel ( p, 'int' ) ) else setElementData ( p, 'staffLevel', 0 ) end end addEventHandler ( "onPlayerLogin", root, function ( ) setNewPlayerStaffData ( source ) end ); addEventHandler ( "onResourceStart", resourceRoot, function ( ) for _, p in pairs ( getElementsByType ( "player" ) ) do setNewPlayerStaffData ( p ) end end ) I want apear the Trail Staff etc not Level 1 etc help me
  14. can someone help i want player when are in colshpae not be able kicked for be afk can you help me local AFKZones = { {-2697.25, 366.05, 4.4, 100, 100}, {1222.77, -1424.77, 13.35, 100, 100}, {1898.62, 2317.56, 10.82, 100, 100}, }, local AFKZoneArea = { {-2697.25, 366.05, 100, 100}, {1222.77, -1424.77, 100, 100}, {1898.62, 2317.56, 100, 100}, }, function createAFKZones() for #AFKZones do AFKCols = createColRectangle(unpack(AFKZones)) end for #AFKZoneArea do AFKarea = createRadarArea(unpack(AFKZoneArea)) setRadarAreaColor(AFKarea, 0, 255, 0) end end addEventHandler("onResourceStart", resourceRoot, createAFKZones) addEventHandler("onColShapeHit", root, function(player) setPedWeaponSlot(player, 0) toggleControl(player, "next_weapon", false) toggleControl(player, "previous_weapon", false) toggleControl(player, "fire", false) toggleControl(player, "aim_weapon", false) setElementData(player , "afk", true) end) addEventHandler("onColShapeLeave", root, function(player) toggleControl(player, "next_weapon", true) toggleControl(player, "previous_weapon", true) toggleControl(player, "fire", true) toggleControl(player, "aim_weapon", true) setElementData(player, "afk", false) end)
  15. Hello there i have make some afk zone and i want when player is that possition not get kicked what mater the time afk there are and cancel the damange local AFKZones = { {-2697.25, 366.05, 4.4, 100, 100}, {1222.77, -1424.77, 13.35, 100, 100}, {1898.62, 2317.56, 10.82, 100, 100}, }, function createAFKZones(player) for #AFKZones do AFKCols = createColRectangle(unpack(AFKZones)) AFKarea = createRadarArea(unpack(AFKZones)) setRadarAreaColor(AFKarea, 0, 255, 0) end end addEventHandler("onColShapeHit", root, createAFKZOnes)
  16. Then provide the code to help you
  17. getVehicleColor Use this before change it
×
×
  • Create New...