Dimos7 Posted October 15, 2016 Share Posted October 15, 2016 (edited) gTimerTable = {} gMapsTable = {} comcounter = 0 local g_AdminRanks = { [1] = "Xtreme-Players Trial Member", [2] = "Xtreme-Players Member", [3] = "Xtreme-Players Moderator", [4] = "Xtreme-Players Admin", [5] = "Xtreme-Players Team Manager", [6] = "Xtreme-Players Server Owner", } function hasRights(thePlayer,level) if not isElement(thePlayer) then return false -- Error, there's no player! end local adminLevel = tonumber (getElementData(thePlayer,"pAdminlevel")) if adminLevel and adminLevel >= level then local team = getPlayerTeam(thePlayer) if team then if g_AdminRanks[adminLevel] and getTeamName(team) == g_AdminRanks[adminLevel] then return true end end end return false end addEvent("getSerial",true) addEventHandler("getSerial",getRootElement(), function (player) triggerClientEvent("giveBack",getRootElement(),getPlayerSerial(player),getPlayerIP(player)) end) addEventHandler("onPlayerJoin",getRootElement(), function () mysql_close(handler) handler = mysql_connect ( "localhost", "race-db", "KVU6we7XAFTEeE3T", "styla" ) end) addEventHandler("onPlayerQuit",getRootElement(), function ( ) local name = getPlayerName(source) mysql_query( handler, 'DELETE FROM whishlist WHERE name = "'..name..'"') end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () handler = mysql_connect ( "localhost", "race-db", "KVU6we7XAFTEeE3T", "styla" ) commandlog = xmlLoadFile("commandlog.xml") local i = 1 while i ~= 0 do idnode = xmlFindChild(commandlog, "id"..comcounter, 0) if idnode then comcounter = comcounter + 1 else i = 0 end end end) addEvent("deleteAccount",true) addEventHandler("deleteAccount",root, function(theAccount) if not hasRights(source,5) then return end if theAccount then mysql_query( handler, 'DELETE FROM account WHERE Name = "'..theAccount..'"') --//Refresh. triggerClientEvent(source,"onAccountDeleted",root) outputChatBox("Account "..theAccount.." has been deleted!",source,255,0,0) end end ) addEvent("getBans",true) addEventHandler("getBans",getRootElement(), function (player) if not hasRights(source,5) then return end local query = "SELECT * FROM ban ORDER BY Eintragedatum DESC" local result = mysql_query( handler, query ) if ( result and mysql_num_rows( result ) > 0) then row = mysql_fetch_assoc(result) while row do local name = row["Name"] local admin = row["Admin"] local reason = row["Grund"] local ip = row["IP"] local serial = row["Serial"] row = mysql_fetch_assoc(result) triggerClientEvent("giveBans",player,name,admin,reason,ip,serial) end end end) addEvent("Kick",true) addEventHandler("Kick",getRootElement(), function (admin,kicked,grund) if client ~= admin then return end if kicked == admin then outputChatBox("Try /disconnect ;)",admin,255,0,0,true) return end if not hasRights(admin, 2) then return end if kicked then outputChatBox("Player "..getPlayerName(kicked).. " was kicked by " ..getPlayerName(admin).. "!",getRootElement(),255,0,0) outputChatBox("Reason: "..grund,getRootElement(),255,255,0,true) kickPlayer(kicked,admin,grund) end end) --Ban function addBanPlayer ( name,player,text) if not hasRights(source, 4) then return end if client ~= getPlayerFromName(name) then return end local name2 = getPlayerName(player) local ip = getPlayerIP(player) local serial = getPlayerSerial(player) local zeit = 0 local query = "INSERT INTO ban ( Name, Admin, Grund, Datum, IP, Serial ) VALUES ( '"..name2.."', '"..name.."', '"..text.."', '"..tonumber(zeit).."', '"..ip.."', '"..serial.."' )" local result = mysql_query( handler, query ) local query2 = "UPDATE account SET Banned = '1' WHERE Name = '"..name2.."'" local result2 = mysql_query( handler, query2 ) kickPlayer(player,"You were banned permanently \Reason: "..text) addBan(ip, serial, getPlayerAccount(player) , name, text, zeit) outputChatBox(name2.." Was permanently banned by " ..name.. ".",getRootElement(),255,0,0,true) outputChatBox("Reason: "..text,getRootElement(),255,255,0,true) if result then mysql_free_result(result) mysql_free_result(result2) return true else return false end end addEvent("Banperm",true) addEventHandler("Banperm",getRootElement(),addBan) --TBan function addTimeBan ( name,player,text,zeit ) if hasRights(source, 3) then return end if client ~= getPlayerFromName(name) then return end local name2 = getPlayerName(player) local ip = getPlayerIP(player) local serial = getPlayerSerial(player) time = zeit*3600 local _stamp = getRealTime() _stamp = _stamp.timestamp local stamp = getRealTime( tonumber(_stamp+time) ) stamp = stamp.timestamp local query = "INSERT INTO ban ( Name, Admin, Grund, Datum, IP, Serial ) VALUES ( '"..name2.."', '"..name.."', '"..text.."', '"..stamp.."', '"..ip.."', '"..serial.."' )" local result = mysql_query( handler, query ) kickPlayer(player,"You were banned for "..zeit.." hours /Reason: "..text) addBan(ip, serial, getPlayerAccount(player), name, text, zeit) outputChatBox(name2.." Was banned by " ..name.. " for " ..zeit.. " hour/s",getRootElement(),255,0,0,true) outputChatBox("Grund: "..text,getRootElement(),255,255,0,true) if result then mysql_free_result(result) return true else return false end end addEvent("Tban",true) addEventHandler("Tban",getRootElement(),addTimeBan) --Ban abfrage addEventHandler ( "onPlayerConnect", getRootElement(), function (playerNick, playerIP, playerUsername, playerSerial, playerVersionNumber ) local pname = playerNick local pserial = playerSerial local query = mysql_query( handler, "SELECT Name, Datum FROM ban WHERE Name = '"..pname.."'") local _query = mysql_query( handler, "SELECT Name, Datum FROM ban WHERE Serial = '"..pserial.."'") local rows = mysql_num_rows ( query ) local _rows = mysql_num_rows ( _query ) local _stamp = getRealTime() _stamp = tonumber(_stamp.timestamp) if rows > 0 then local dsatz = mysql_fetch_assoc ( query ) if _stamp > tonumber(dsatz["Datum"]) and tonumber(dsatz["Datum"]) == 0 then cancelEvent( true, "You are permanently banned" ) elseif _stamp > tonumber(dsatz["Datum"]) then mysql_query( handler, "DELETE FROM ban WHERE Name = '"..pname.."'") elseif _stamp < tonumber(dsatz["Datum"]) then cancelEvent( true, "You are still banned" ) end return true elseif _rows > 0 then local dsatz = mysql_fetch_assoc ( _query ) if _stamp > tonumber(dsatz["Datum"]) and tonumber(dsatz["Datum"]) == 0 then cancelEvent( true, "You are permanently banned" ) elseif _stamp > tonumber(dsatz["Datum"]) then mysql_query( handler, "DELETE FROM ban WHERE Serial = '"..pserial.."'") elseif _stamp < tonumber(dsatz["Datum"]) then cancelEvent( true, "You are still banned" ) end return true end end ) --Blow addEvent("Blow",true) addEventHandler("Blow",getRootElement(), function (admin,vehicle,player) if client ~= admin then return end if admin == player then return end if not hasRights(admin, 1) then return end blowVehicle(vehicle,false) outputChatBox("Your vehicle was Blown by "..getPlayerName(admin),player,255,0,0,true) for i, playerid in pairs (getElementsByType("player")) do local player22 = string.gsub(getPlayerName(player),"#%x%x%x%x%x%x", "") outputChatBox(getPlayerName(admin).." has blowed "..player22.."!", playerid, 255, 0, 0) end end ) addEvent("Mute",true) addEventHandler("Mute",getRootElement(), function (admin,player,time) if not hasRights(admin, 2) then return end if client ~= admin then return end local time = time*60000 if isPlayerMuted(player) == true then mutedby = (tonumber(getElementData(player, "mutedby"))) --muteteam = getTeamName(getPlayerTeam(admin)) muteteamnumber = (tonumber(getElementData(admin,"pAdminlevel"))) --[[if muteteam == "Xtreme-Players Server Owner" then muteteamnumber = 6 elseif muteteam == "Xtreme-Players Tean Manager" then muteteamnumber = 5 elseif muteteam == "Xtreme-Players Admins" then muteteamnumber = 4 elseif muteteam == "Xtreme-Players Moderators" then muteteamnumber = 3 elseif muteteam == "Xtreme-Players Member" then muteteamnumber = 2 end--]] if (muteteamnumber <= mutedby-1) then if admin == player then outputChatBox("You dont have the premissions to unmute yourself!", admin, 255, 0, 0) return else outputChatBox("You dont have the premissions to unmute "..getPlayerName(player).."!", admin, 255, 0, 0) return end elseif muteteamnumber >= mutedby then setPlayerMuted(player,false) removeEventHandler("onPlayerQuit",player,quit) if gTimerTable[getPlayerName(player)] then killTimer(gTimerTable[getPlayerName(player)]) end outputChatBox(getPlayerName(player).. " is not longer Muted!",getRootElement(),0,255,0,true) end elseif isPlayerMuted(player) == false then setPlayerMuted(player,true) setElementData(player,"mutedby",tonumber(getElementData(admin,"pAdminlevel"))) outputChatBox(getPlayerName(player).." has been Muted by "..getPlayerName(admin),getRootElement(),255,0,0,true) addEventHandler("onPlayerQuit",player,quit) gTimerTable[getPlayerName(player)] = setTimer(function (player) setPlayerMuted(player,false) outputChatBox(getPlayerName(player).." is not longer Muted!",getRootElement(),0,255,0,true) removeEventHandler("onPlayerQuit",player,quit) end,time,1,player) end end) function quit () if isTimer(gTimerTable[getPlayerName(source)]) then killTimer(gTimerTable[getPlayerName(source)]) removeEventHandler("onPlayerQuit",source,quit) end end --Tab2 --Gravity addEvent("gravity",true) addEventHandler("gravity",getRootElement(), function (player, gravity) if not hasRights(source,5) then return end setGravity(tonumber(gravity)) for id, player in ipairs ( getElementsByType ( "player" ) ) do setPedGravity ( player, getGravity() ) end outputChatBox("You setted the Gravitylevel to "..gravity, player, 255,0,0) end) --Weather addEvent("weather",true) addEventHandler("weather",getRootElement(), function (player, weather) if not hasRights(source,5) then return end if (weather == "Blue Sky, Sunny") then setWeather(0) end if (weather == "Blue Sky, Clouds") then setWeather(2) end if (weather == "Storming") then setWeather(8) end if (weather == "Cloudy and Foggy") then setWeather(9) end if (weather == "Clear Blue Sky") then setWeather(10) end if (weather == "Sunny, Scorching Hot") then setWeather(11) end if (weather == "Very Dull, Colourless, Hazy") then setWeather(12) end if (weather == "Dull, Cloudy, Rainy") then setWeather(16) end if (weather == "Sunny, Scorching Hot") then setWeather(17) end if (weather == "Sandstorm") then setWeather(19) end outputChatBox("You setted the Weather to "..weather, player, 255,0,0) end) --Time addEvent("time",true) addEventHandler("time",getRootElement(), function (player, hour, min) if not hasRights(source,5)then return end setTime(tonumber(hour), tonumber(min)) outputChatBox("You setted the Time to "..hour..":"..min, player, 255,0,0) end) --Waves addEvent("waves",true) addEventHandler("waves",getRootElement(), function (player, waves) if not hasRights(source,5) then return end setWaveHeight(tonumber(waves)) outputChatBox("You setted the Waves to "..waves, player, 255,0,0) end) --Gamespeed addEvent("gamespeed",true) addEventHandler("gamespeed",getRootElement(), function (player, gamespeed) if not hasRights(source,5) then return end setGameSpeed(tonumber(gamespeed)) outputChatBox("You setted the Gamespeed to "..gamespeed, player, 255,0,0) end) --GetCommandList addEvent("get_commands", true) addEventHandler("get_commands", getRootElement(), function (text, lines, resultcounter, fulllist) fulllist = fulllist commandtablelist = {} for index = comcounter - lines + 99, comcounter - lines - 1, -1 do if index >= 0 then peniscounter = 1 tragodie = {} commandlog = xmlLoadFile("commandlog.xml") idnode = xmlFindChild(commandlog, "id"..index, 0) if idnode then attribute = xmlNodeGetAttributes(idnode) for name,value in pairs ( attribute ) do tragodie[tonumber(peniscounter)] = value peniscounter = peniscounter + 1 end if string.find(string.lower(tragodie[1]), text) or string.find(string.lower(tragodie[2]), text) or string.find(string.lower(tragodie[3]), text) or string.find(string.lower(tragodie[4]), text) or string.find(string.lower(tragodie[5]), text) then resultcounter = resultcounter + 1 commandtablelist[resultcounter] = tragodie end end else fulllist = true end end triggerClientEvent("set_commands", getRootElement(), commandtablelist, resultcounter, fulllist) end) --Tab3 addEvent("unbann",true) addEventHandler("unbann",getRootElement(), function (player,ban) if not hasRights(source,5) then return end if client ~= player then return end mysql_query( handler, "DELETE FROM ban WHERE Name = '"..ban.."'") mysql_query( handler, "UPDATE account SET Banned = '0' WHERE Name = '"..ban.."'" ) end) --ADMINCMDS --Muten/Unmuten --[[addCommandHandler("pmute", function( player, cmd, target ) if ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Member" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Moderators" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Admins" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Server Owner" ) then local player2 = findPlayerByName( target ) if getElementData(player2,"pAdminlevel") == "4" then outputChatBox(":O You Bitch!", player,255,0,0) return end if ( player2 == nil ) then outputChatBox("Invalid username!", player,255,0,0) else setPlayerMuted(player2,true) if getTeamName(getPlayerTeam(player)) == "Xtreme-Players Server Owner" then setElementData(player2, "mutedby", 4) elseif getTeamName(getPlayerTeam(admin)) == "Xtreme-Players Team Manager" then setElementData(player2, "mutedby", 3) elseif getTeamName(getPlayerTeam(player)) == "Xtreme-Players Admins" then setElementData(player2, "mutedby", 2) elseif getTeamName(getPlayerTeam(player)) == "Xtreme-Players Moderators" then setElementData(player2, "mutedby", 1) elseif getTeamName(getPlayerTeam(player)) == "Xtreme-Players Member" then setElementData(player2, "mutedby", 0) end outputChatBox("You muted "..getPlayerName(player2).."!",player,255,0,0) outputChatBox("You have been muted by"..getPlayerName(player).."!",player2,255,0,0) if ( fileExists( "commandlog.txt" ) ) then logfile = fileOpen( "commandlog.txt" ) time = getRealTime() hour = time.hour min = time.minute sec = time.second day = time.monthday month = time.month + 1 year = time.year + 1900 while not fileIsEOF( logfile ) do buffer = fileRead( logfile, 500 ) end fileWrite( logfile, "["..day.."."..month.."."..year.."]["..hour..":"..min..":"..sec.."] command: "..cmd.." source: "..getPlayerName(player).." target: "..getPlayerName(player2).."\n" ) fileClose( logfile ) else logfile = fileCreate( "commandlog.txt" ) time = getRealTime() hour = time.hour min = time.minute sec = time.second day = time.monthday month = time.month + 1 year = time.year + 1900 fileWrite( logfile, "["..day.."."..month.."."..year.."]["..hour..":"..min..":"..sec.."] command: "..cmd.." source: "..getPlayerName(player).." target: "..getPlayerName(player2).."\n" ) fileClose( logfile ) end if fileExists("commandlog.xml") then commandlog = xmlLoadFile("commandlog.xml") newnode = xmlCreateChild(commandlog, "id"..comcounter) xmlNodeSetAttribute ( newnode, "Befehl", cmd ) xmlNodeSetAttribute ( newnode, "Benutzer", getPlayerName(player) ) xmlNodeSetAttribute ( newnode, "Ziel", getPlayerName(player2) ) xmlNodeSetAttribute ( newnode, "Zeit", hour..":"..min..":"..sec ) xmlNodeSetAttribute ( newnode, "Datum", day.."."..month.."."..year ) xmlSaveFile(commandlog) xmlUnloadFile(commandlog) comcounter = comcounter + 1 else commandlog = xmlCreateFile("commandlog.xml", "log") newnode = xmlCreateChild(commandlog,"id"..comcounter) xmlNodeSetAttribute ( newnode, "Befehl", cmd ) xmlNodeSetAttribute ( newnode, "Benutzer", getPlayerName(player) ) xmlNodeSetAttribute ( newnode, "Ziel", getPlayerName(player2) ) xmlNodeSetAttribute ( newnode, "Zeit", hour..":"..min..":"..sec ) xmlNodeSetAttribute ( newnode, "Datum", day.."."..month.."."..year ) xmlSaveFile(commandlog) xmlUnloadFile(commandlog) comcounter = comcounter + 1 end end else outputChatBox("You dont have the premissions to use this command!",player,255,0,0) end end) addCommandHandler("punmute", function( player, cmd, target ) if ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Member" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Moderators" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Admins" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Server Owner" ) then local player2 = findPlayerByName( target ) mutedby = getElementData(player2, "mutedby") muteteam = getTeamName(getPlayerTeam(player)) muteteamnumber = 0 if muteteam == "Xtreme-Players Server Owner" then muteteamnumber = 4 elseif muteteam == "Xtreme-Players Team Manager" then muteteamnumber = 3 elseif muteteam == "Xtreme-Players Admins" then muteteamnumber = 2 elseif muteteam == "Xtreme-Players Moderators" then muteteamnumber = 1 elseif muteteam == "Xtreme-Players Member" then muteteamnumber = 0 end if ( player2 == nil ) then outputChatBox("Invalid username!", player,255,0,0) else if muteteamnumber <= mutedby-1 then if player == player2 then outputChatBox("You dont have the premissions to unmute yourself!", player, 255, 0, 0) return else outputChatBox("You dont have the premissions to unmute "..player2.."!", player, 255, 0, 0) return end elseif muteteamnumber >= mutedby then setPlayerMuted(player2,false) outputChatBox("You unmuted "..getPlayerName(player2).."!",player,0,255,0) outputChatBox("You have been unmuted by"..getPlayerName(player).."!",player2,0,255,0) end end else outputChatBox("You dont have the premissions to use this command!",player,255,0,0) end end)--]] --Blow --[[addCommandHandler("pblow", function( player, cmd, target ) if getTeamName(getPlayerTeam(player)) == "Xtreme-Players Trial Member" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Member" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Moderator" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Admin" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Team Manager" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Server Owner" then player2 = findPlayerByName(target) if ( player2 == nil ) then outputChatBox("Invalid username!", player,255,0,0) else if(player2 == player) then outputChatBox("You can't blow yourself!", player, 255, 0, 0) return end veh = getPedOccupiedVehicle(player2) blowVehicle(veh) outputChatBox("You have been blowed "..getPlayerName(player2).."'s vehicle!",player,255,0,0) if getPlayerName(player) ~= "[XP]yourdeathcomes" or getPlayerName(player) ~= "HeadSh0T~" then outputChatBox("Your vehicle has been blowed by "..getPlayerName(player).."!",player2,255,0,0) end if getTeamName(getPlayerTeam(player)) == "Xtreme-Players Trial-Member" then for i, playerid in pairs (getElementsByType("player")) do if getTeamName(getPlayerTeam(player)) == "Xtreme-Players Moderator" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Admin" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Team Manager" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Server Owner" then local player22 = string.gsub(getPlayerName(player2),"#%x%x%x%x%x%x", "") outputChatBox("Xtreme-Players Trial-Member "..getPlayerName(player).." has blowed "..player22.."!", playerid, 255, 0, 0) end end end if ( fileExists( "commandlog.txt" ) ) then logfile = fileOpen( "commandlog.txt" ) time = getRealTime() hour = time.hour min = time.minute sec = time.second day = time.monthday month = time.month + 1 year = time.year + 1900 while not fileIsEOF( logfile ) do buffer = fileRead( logfile, 500 ) end fileWrite( logfile, "["..day.."."..month.."."..year.."]["..hour..":"..min..":"..sec.."] command: "..cmd.." source: "..getPlayerName(player).." target: "..getPlayerName(player2).."\n" ) fileClose( logfile ) else logfile = fileCreate( "commandlog.txt" ) time = getRealTime() hour = time.hour min = time.minute sec = time.second day = time.monthday month = time.month + 1 year = time.year + 1900 fileWrite( logfile, "["..day.."."..month.."."..year.."]["..hour..":"..min..":"..sec.."] command: "..cmd.." source: "..getPlayerName(player).." target: "..getPlayerName(player2).."\n" ) fileClose( logfile ) end if fileExists("commandlog.xml") then commandlog = xmlLoadFile("commandlog.xml") newnode = xmlCreateChild(commandlog, "id"..comcounter) xmlNodeSetAttribute ( newnode, "Befehl", cmd ) xmlNodeSetAttribute ( newnode, "Benutzer", getPlayerName(player) ) xmlNodeSetAttribute ( newnode, "Ziel", getPlayerName(player2) ) xmlNodeSetAttribute ( newnode, "Zeit", hour..":"..min..":"..sec ) xmlNodeSetAttribute ( newnode, "Datum", day.."."..month.."."..year ) xmlSaveFile(commandlog) xmlUnloadFile(commandlog) comcounter = comcounter + 1 else commandlog = xmlCreateFile("commandlog.xml", "log") newnode = xmlCreateChild(commandlog,"id"..comcounter) xmlNodeSetAttribute ( newnode, "Befehl", cmd ) xmlNodeSetAttribute ( newnode, "Benutzer", getPlayerName(player) ) xmlNodeSetAttribute ( newnode, "Ziel", getPlayerName(player2) ) xmlNodeSetAttribute ( newnode, "Zeit", hour..":"..min..":"..sec ) xmlNodeSetAttribute ( newnode, "Datum", day.."."..month.."."..year ) xmlSaveFile(commandlog) xmlUnloadFile(commandlog) comcounter = comcounter + 1 end end else outputChatBox("You dont have the premissions to use this command!",player,255,0,0) end end)]] --pkick --[[addCommandHandler("pkick", function( player, cmd, target ) if ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Member" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Moderators" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Admins" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Server Owner" ) then local player2 = findPlayerByName( target ) --local player2 = string.gsub(player22,"#%x%x%x%x%x%x", "") --local player2 = findPlayerByName( target ) if ( player2 == nil ) then outputChatBox("Invalid username!", player,255,0,0) else if ( getElementData(player2, "state" ) ~= "not ready" ) then outputChatBox ( "You only can kick Players which state is 'not ready'. For camper use '/pblow'!", player, 255, 0, 0 ) return false end if ( fileExists( "commandlog.txt" ) ) then logfile = fileOpen( "commandlog.txt" ) time = getRealTime() hour = time.hour min = time.minute sec = time.second day = time.monthday month = time.month + 1 year = time.year + 1900 while not fileIsEOF( logfile ) do buffer = fileRead( logfile, 500 ) end fileWrite( logfile, "["..day.."."..month.."."..year.."]["..hour..":"..min..":"..sec.."] command: "..cmd.." source: "..getPlayerName(player).." target: "..getPlayerName(player2).."\n" ) fileClose( logfile ) else logfile = fileCreate( "commandlog.txt" ) time = getRealTime() hour = time.hour min = time.minute sec = time.second day = time.monthday month = time.month + 1 year = time.year + 1900 fileWrite( logfile, "["..day.."."..month.."."..year.."]["..hour..":"..min..":"..sec.."] command: "..cmd.." source: "..getPlayerName(player).." target: "..getPlayerName(player2).."\n" ) fileClose( logfile ) end if fileExists("commandlog.xml") then commandlog = xmlLoadFile("commandlog.xml") newnode = xmlCreateChild(commandlog, "id"..comcounter) xmlNodeSetAttribute ( newnode, "Befehl", cmd ) xmlNodeSetAttribute ( newnode, "Benutzer", getPlayerName(player) ) xmlNodeSetAttribute ( newnode, "Ziel", getPlayerName(player2) ) xmlNodeSetAttribute ( newnode, "Zeit", hour..":"..min..":"..sec ) xmlNodeSetAttribute ( newnode, "Datum", day.."."..month.."."..year ) xmlSaveFile(commandlog) xmlUnloadFile(commandlog) comcounter = comcounter + 1 else commandlog = xmlCreateFile("commandlog.xml", "log") newnode = xmlCreateChild(commandlog,"id"..comcounter) xmlNodeSetAttribute ( newnode, "Befehl", cmd ) xmlNodeSetAttribute ( newnode, "Benutzer", getPlayerName(player) ) xmlNodeSetAttribute ( newnode, "Ziel", getPlayerName(player2) ) xmlNodeSetAttribute ( newnode, "Zeit", hour..":"..min..":"..sec ) xmlNodeSetAttribute ( newnode, "Datum", day.."."..month.."."..year ) xmlSaveFile(commandlog) xmlUnloadFile(commandlog) comcounter = comcounter + 1 end blowVehicle(getPedOccupiedVehicle(player2), true) setTimer ( function() kickPlayer(player2, player) end, 1000, 1) end else outputChatBox("You dont have the premissions to use this command!",player,255,0,0) end end)--]] --Findplayer function findPlayerByName( Part ) local Player = getPlayerFromName( Part ) if isElement( Player ) then return Player else for i, p in ipairs ( getElementsByType( "player" ) ) do if ( string.find( getPlayerName(p), Part ) ) then return p end end end end --Tab4 addEvent("s_GetMaps",true) addEventHandler("s_GetMaps",getRootElement(), function () tableOutput = {} local gamemodes = {} gamemodes = call(getResourceFromName("mapmanager"), "getGamemodes") for id,gamemode in ipairs (gamemodes) do tableOutput[id] = {} tableOutput[id].name = getResourceInfo(gamemode, "name") or getResourceName(gamemode) tableOutput[id].maps = {} local maps = call(getResourceFromName("mapmanager"), "getMapsCompatibleWithGamemode" , gamemode) for _,map in ipairs (maps) do table.insert(tableOutput[id]["maps"] ,{name = getResourceInfo(map, "name") or getResourceName(map), resname = getResourceName(map)}) end table.sort(tableOutput[id]) end local map = call(getResourceFromName("mapmanager"), "getRunningGamemodeMap") local gamemode = call(getResourceFromName("mapmanager"), "getRunningGamemode") gamemode = gamemode and getResourceName(gamemode) or "N/A" map = map and getResourceName(map) or "N/A" triggerClientEvent(source ,"c_GetMaps", source, tableOutput,gamemode,map) end) addEvent("s_GetWhishes",true) addEventHandler("s_GetWhishes",getRootElement(), function (player) local query = "SELECT * FROM whishlist" local result = mysql_query( handler, query ) if ( result and mysql_num_rows( result ) > 0) then row = mysql_fetch_assoc(result) while row do local map = row["map"] local name = row["name"] row = mysql_fetch_assoc(result) triggerClientEvent("c_GiveWishes",player,map,name) end end end) local alreadySeted = false addEvent("onServerConfirmNexmtap",true) addEventHandler("onServerConfirmNexmtap",root, function() alreadySeted = true end ) addEvent("setMap",true) addEventHandler("setMap",getRootElement(), function (player,map,name,delvar) if delvar ~= 1 then if not hasRights(source,4) then return end end if alreadySeted then outputChatBox("One map its already setted!",player,255,0,0) return end if delvar == 1 then local mapname1 = mysql_escape_string(handler, map) local name1 = mysql_escape_string(handler, name) mysql_query( handler, 'DELETE FROM whishlist WHERE map = "'..mapname1..'" AND name = "'..name1..'"') setElementData(player,"isAllowedToSet",true) end executeCommandHandler("nextmap",player,map) end ) addEvent("whishMap",true) addEventHandler("whishMap",getRootElement(), function (player,map) local name = getPlayerName(player) local query = "SELECT * FROM whishlist WHERE name = '"..name.."'" local result = mysql_query( handler, query ) if ( result and mysql_num_rows( result ) > 1) then return end local query = "SELECT * FROM whishlist WHERE map = '"..map.."'" local result = mysql_query( handler, query ) if ( result and mysql_num_rows( result ) == 1) then outputChatBox("This map was already wished!",player,255,0,0) return end outputChatBox("You wished the map "..map,player,0,255,0) local query = 'INSERT INTO whishlist ( map,name ) VALUES ( "'..map..'", "'..name..'" )' local result = mysql_query( handler, query ) --//Tell xp members. for i, playerid in ipairs (getElementsByType("player")) do if tonumber(getElementData(playerid, "pLogin")) == 1 then local team = getPlayerTeam(playerid) local level = getElementData(playerid,"pAdminlevel") if team then if hasRights(admin, 3) then if player ~= playerid then outputChatBox("[Wishmap] "..name:gsub("#%x%x%x%x%x%x","").." wished the Map "..map..".",playerid,0,255,0) end end end end end end ) addEvent("removeWhish",true) addEventHandler("removeWhish",getRootElement(), function (player,map,name) outputChatBox("Map form wishlist removed!",player,255,0,0) mysql_query( handler, 'DELETE FROM whishlist WHERE map = "'..map..'" AND name = "'..name..'"') end) --RandomWish addCommandHandler("randomwish", function (player) if not hasRights(player, 3) then return end if not alreadySeted then local result = mysql_query( handler, 'SELECT COUNT(*) FROM whishlist' ) if result then local row = mysql_fetch_row(result) if row then local count = math.random(0,row[1]-1) local result = mysql_query( handler, 'SELECT map,name FROM whishlist LIMIT '..count..',1' ) row = mysql_fetch_assoc(result) if row then name = row["name"] map = row["map"] alreadySeted = true mysql_query( handler, 'DELETE FROM whishlist WHERE map = "'..map..'" AND name = "'..name..'"') setElementData(player, "randomwhish", 1) executeCommandHandler("nextmap",player,map) else outputChatBox("[Wishlist] Can't get final row!",player,255,0,0) end end else outputChatBox("There's no Map in the Wishlist",player,255,0,0) end else outputChatBox("One map its already setted!",player,255,0,0) end end ) addCommandHandler("nextblock", function(player) local team = getPlayerTeam(player) local name = getPlayerName(player) local level = getElementData(player,"pAdminlevel") if team then if hasRights(player, 3)then alreadySeted = not alreadySeted outputChatBox("[Admin] Nextmap block has changed map block to: "..tostring(alreadySeted)..".",root,0,255,0) end end end ) function getXtremeAdmins() local adminList = {} for k,v in ipairs(getElementsByType("player")) do if hasRights(v, 3) then adminList[#adminList+1] = v end end return adminList end function onFinishedCurrentMap() alreadySeted = false outputDebugString("[Wishlist] Map set block updated! (Changed to: "..tostring(alreadySeted)..")",player,255,0,0) end addEvent("onMapStarting",true) addEventHandler("onMapStarting",root,onFinishedCurrentMap) function onAdminChecker() --outputChatBox("[XP]AdminBot: Attempt to do auto-set if no admin.",root,255,255,255,true) local pAdmins = getXtremeAdmins() if #pAdmins < 1 then if not alreadySeted then local result = mysql_query( handler, 'SELECT COUNT(*) FROM whishlist' ) if result then row = mysql_fetch_row(result) if row then if row[1]-1 >= 0 then local count = math.random(0,row[1]-1) local result = mysql_query( handler, 'SELECT map,name FROM whishlist LIMIT '..count..',1' ) row = mysql_fetch_assoc(result) if row then map = row["map"] name = row["name"] alreadySeted = true outputDebugString("[Wishlist] Next map setted to: "..map) mysql_query( handler, 'DELETE FROM whishlist WHERE map = "'..map..'" AND name = "'..name..'"') --//Make it happen. triggerEvent("onServerWannaSetmap",getResourceRootElement(getThisResource()),map) else outputDebugString("[Wishlist] Can't get final row!") end else outputDebugString("[Wishlist] Wishlist its empty!") end else outputDebugString("[Wishlist] Can't get row!") end else outputDebugString("[Wishlist] Can't get result!") end else outputDebugString("[Wishlist] One map where already setted.") end else outputDebugString("[Wishlist] There's one or more online admin.") end end setTimer(onAdminChecker,120000,0) --//2 Minutes. --Tab5 addEvent("refreshTotalAccounts", true) addEventHandler("refreshTotalAccounts", getRootElement(), function() local query = "SELECT COUNT(*) FROM account;" local result = mysql_query(handler, query) row = mysql_fetch_row(result) if row then setElementData(root, "totalAccounts", row[1]) end end) function getRankColorName(level) if level then if level == 1 then return "#18BC5BMember" elseif level == 2 then return "#FFFF00Moderator" elseif level == 3 then return "#0000CCAdmin" elseif level == 4 then return "#F45F2FTeam-Manager" elseif level == 5 then return "#CC0000Server Owner" else return "" end end end addEvent("setUserData", true) addEventHandler("setUserData", getRootElement(), function (wert, data, player, player2) if not hasRights(source,5) then return end if data == "Adminlevel" then local RankName = getRankColorName(wert) outputDebugString(wert) outputDebugString(RankName) mysql_query(handler,"UPDATE account SET Adminlevel = '"..wert.."' WHERE NAME = '"..player.."'") mysql_query(handler,"UPDATE account SET Title = '"..RankName.."' WHERE NAME = '"..player.."'") elseif data == "Name" then local query = "SELECT * FROM account WHERE Name = '"..wert.."'" local result = mysql_query(handler, query) row = mysql_num_rows(result) if row > 0 then outputChatBox("This Name is already in use!", player2, 255, 0, 0) return end if getPlayerFromName(player) ~= false then outputChatBox("This player is Online, use the Player Managemant to change his Stats", player2, 255, 0, 0) return end mysql_query(handler,"UPDATE account SET Name = '"..wert.."' WHERE NAME = '"..player.."'") outputChatBox("You changed the Name from "..player.." to "..wert..".", player2, 255, 0, 0) elseif data == "Money" then mysql_query(handler,"UPDATE account SET Geld = '"..wert.."' WHERE NAME = '"..player.."'") elseif data == "Points" then mysql_query(handler,"UPDATE account SET Points = '"..wert.."' WHERE NAME = '"..player.."'") elseif data == "Wins" then mysql_query(handler,"UPDATE account SET Wins = '"..wert.."' WHERE NAME = '"..player.."'") end end) addEvent("searchPlayers", true) addEventHandler("searchPlayers", getRootElement(), function(wert, wert2) if not hasRights(source,5) then return end if wert2 == "Name" then local accTable = {} local query = "SELECT * FROM account WHERE Name LIKE \'%"..wert.."%\';" local result = mysql_query(handler, query) if (result and mysql_num_rows(result) > 0) then local testcounter = mysql_num_rows(result) local testcounter2 = 0 while(testcounter > 0) do testcounter2 = testcounter2 + 1 local row = mysql_fetch_assoc(result) local dataTable = {} dataTable[1] = row['Name'] dataTable[2] = row['Geld'] dataTable[3] = row['Points'] dataTable[4] = row['Wins'] dataTable[5] = row['Spielzeit'] dataTable[6] = row['Adminlevel'] accTable[testcounter2] = dataTable testcounter = testcounter - 1 end triggerClientEvent("fillPlayerlist2", source, accTable) end elseif wert2 == "Serial" then local accTable = {} local query = "SELECT * FROM account WHERE LastSerial LIKE \'%"..wert.."%\';" local result = mysql_query(handler, query) if (result and mysql_num_rows(result) > 0) then local testcounter = mysql_num_rows(result) local testcounter2 = 0 while(testcounter > 0) do testcounter2 = testcounter2 + 1 local row = mysql_fetch_assoc(result) local dataTable = {} dataTable[1] = row['Name'] dataTable[2] = row['Geld'] dataTable[3] = row['Points'] dataTable[4] = row['Wins'] dataTable[5] = row['Spielzeit'] dataTable[6] = row['Adminlevel'] accTable[testcounter2] = dataTable testcounter = testcounter - 1 end triggerClientEvent("fillPlayerlist2", source, accTable) end elseif wert2 == "Adminlevel" then local accTable = {} if wert == "" then local query = "SELECT * FROM account WHERE Adminlevel > 0;" local result = mysql_query(handler, query) if (result and mysql_num_rows(result) > 0) then local testcounter = mysql_num_rows(result) local testcounter2 = 0 while(testcounter > 0) do testcounter2 = testcounter2 + 1 local row = mysql_fetch_assoc(result) local dataTable = {} dataTable[1] = row['Name'] dataTable[2] = row['Geld'] dataTable[3] = row['Points'] dataTable[4] = row['Wins'] dataTable[5] = row['Spielzeit'] dataTable[6] = row['Adminlevel'] accTable[testcounter2] = dataTable testcounter = testcounter - 1 end triggerClientEvent("fillPlayerlist2", source, accTable) end elseif tonumber(wert) > 0 then local query = "SELECT * FROM account WHERE Adminlevel = \'"..wert.."\';" local result = mysql_query(handler, query) if (result and mysql_num_rows(result) > 0) then local testcounter = mysql_num_rows(result) local testcounter2 = 0 while(testcounter > 0) do testcounter2 = testcounter2 + 1 local row = mysql_fetch_assoc(result) local dataTable = {} dataTable[1] = row['Name'] dataTable[2] = row['Geld'] dataTable[3] = row['Points'] dataTable[4] = row['Wins'] dataTable[5] = row['Spielzeit'] dataTable[6] = row['Adminlevel'] accTable[testcounter2] = dataTable testcounter = testcounter - 1 end triggerClientEvent("fillPlayerlist2", source, accTable) end end end end) addEvent("searchPlayers2", true) addEventHandler("searchPlayers2", getRootElement(), function() if not hasRights(source,5)then return end local accTable = {} local query = "SELECT * FROM account ORDER BY LastQuit DESC LIMIT 20;" local result = mysql_query(handler, query) if (result and mysql_num_rows(result) > 0) then local testcounter = mysql_num_rows(result) local testcounter2 = 0 while(testcounter > 0) do testcounter2 = testcounter2 + 1 local row = mysql_fetch_assoc(result) local dataTable = {} dataTable[1] = row['Name'] dataTable[2] = row['Geld'] dataTable[3] = row['Points'] dataTable[4] = row['Wins'] dataTable[5] = row['Spielzeit'] dataTable[6] = row['Adminlevel'] accTable[testcounter2] = dataTable testcounter = testcounter - 1 end triggerClientEvent("fillPlayerlist3", source, accTable) end end) function addOfflineBan ( name,player,text) if not hasRights(admin, 4)then return end if client ~= getPlayerFromName(name) then return end local zeit = 0 local query1 = "SELECT LastSerial FROM account WHERE Name = '"..player.."'" local result1 = mysql_query( handler, query1 ) if (result1 and mysql_num_rows(result1) > 0) then local row = mysql_fetch_assoc(result1) local serial = row['LastSerial'] local query = "INSERT INTO ban ( Name, Admin, Grund, Datum, Serial ) VALUES ( '"..player.."', '"..name.."', '"..text.."', '"..tonumber(zeit).."', '"..serial.."' )" local result = mysql_query( handler, query ) outputChatBox(player.." Was permanently banned by " ..name.. ".",getRootElement(),255,0,0,true) outputChatBox("Reason: "..text,getRootElement(),255,255,0,true) end if result2 then mysql_free_result(result1) end if result then mysql_free_result(result) return true else return false end end addEvent("BanOffline",true) addEventHandler("BanOffline",getRootElement(),addOfflineBan) Not work as supose too without errors, at /randomwish all apear one map its already setted! without any map be seted Edited October 15, 2016 by Dimos7 Link to comment
Dimos7 Posted October 16, 2016 Author Share Posted October 16, 2016 can someone help me please Link to comment
Dimos7 Posted October 17, 2016 Author Share Posted October 17, 2016 gTimerTable = {} gMapsTable = {} comcounter = 0 local g_AdminRanks = { [1] = "Xtreme-Players Trial Member", [2] = "Xtreme-Players Member", [3] = "Xtreme-Players Moderator", [4] = "Xtreme-Players Admin", [5] = "Xtreme-Players Team Manager", [6] = "Xtreme-Players Server Owner", } function hasRights(thePlayer,level) if not isElement(thePlayer) then return false -- Error, there's no player! end local adminLevel = tonumber (getElementData(thePlayer,"pAdminlevel")) if adminLevel and adminLevel >= level then local team = getPlayerTeam(thePlayer) if team then if g_AdminRanks[adminLevel] and getTeamName(team) == g_AdminRanks[adminLevel] then return true end end end return false end addEvent("getSerial",true) addEventHandler("getSerial",getRootElement(), function (player) triggerClientEvent("giveBack",getRootElement(),getPlayerSerial(player),getPlayerIP(player)) end) addEventHandler("onPlayerJoin",getRootElement(), function () mysql_close(handler) handler = mysql_connect ( "localhost", "race-db", "KVU6we7XAFTEeE3T", "styla" ) end) addEventHandler("onPlayerQuit",getRootElement(), function ( ) local name = getPlayerName(source) mysql_query( handler, 'DELETE FROM whishlist WHERE name = "'..name..'"') end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () handler = mysql_connect ( "localhost", "race-db", "KVU6we7XAFTEeE3T", "styla" ) commandlog = xmlLoadFile("commandlog.xml") local i = 1 while i ~= 0 do idnode = xmlFindChild(commandlog, "id"..comcounter, 0) if idnode then comcounter = comcounter + 1 else i = 0 end end end) addEvent("deleteAccount",true) addEventHandler("deleteAccount",root, function(theAccount) if not hasRights(source,5) then return end if theAccount then mysql_query( handler, 'DELETE FROM account WHERE Name = "'..theAccount..'"') --//Refresh. triggerClientEvent(source,"onAccountDeleted",root) outputChatBox("Account "..theAccount.." has been deleted!",source,255,0,0) end end ) addEvent("getBans",true) addEventHandler("getBans",getRootElement(), function (player) if not hasRights(source,5) then return end local query = "SELECT * FROM ban ORDER BY Eintragedatum DESC" local result = mysql_query( handler, query ) if ( result and mysql_num_rows( result ) > 0) then row = mysql_fetch_assoc(result) while row do local name = row["Name"] local admin = row["Admin"] local reason = row["Grund"] local ip = row["IP"] local serial = row["Serial"] row = mysql_fetch_assoc(result) triggerClientEvent("giveBans",player,name,admin,reason,ip,serial) end end end) addEvent("Kick",true) addEventHandler("Kick",getRootElement(), function (admin,kicked,grund) if client ~= admin then return end if kicked == admin then outputChatBox("Try /disconnect ;)",admin,255,0,0,true) return end if not hasRights(admin, 2) then return end if kicked then outputChatBox("Player "..getPlayerName(kicked).. " was kicked by " ..getPlayerName(admin).. "!",getRootElement(),255,0,0) outputChatBox("Reason: "..grund,getRootElement(),255,255,0,true) kickPlayer(kicked,admin,grund) end end) --Ban function addBanPlayer ( name,player,text) if not hasRights(source, 4) then return end if client ~= getPlayerFromName(name) then return end local name2 = getPlayerName(player) local ip = getPlayerIP(player) local serial = getPlayerSerial(player) local zeit = 0 local query = "INSERT INTO ban ( Name, Admin, Grund, Datum, IP, Serial ) VALUES ( '"..name2.."', '"..name.."', '"..text.."', '"..tonumber(zeit).."', '"..ip.."', '"..serial.."' )" local result = mysql_query( handler, query ) local query2 = "UPDATE account SET Banned = '1' WHERE Name = '"..name2.."'" local result2 = mysql_query( handler, query2 ) kickPlayer(player,"You were banned permanently \Reason: "..text) addBan(ip, serial, getPlayerAccount(player) , getPlayerFromName(name), text, zeit) outputChatBox(name2.." Was permanently banned by " ..name.. ".",getRootElement(),255,0,0,true) outputChatBox("Reason: "..text,getRootElement(),255,255,0,true) if result then mysql_free_result(result) mysql_free_result(result2) return true else return false end end addEvent("Banperm",true) addEventHandler("Banperm",getRootElement(),addBanPlayer) --TBan function addTimeBan ( name,player,text,zeit ) if not hasRights(source, 3) then return end if client ~= getPlayerFromName(name) then return end local name2 = getPlayerName(player) local ip = getPlayerIP(player) local serial = getPlayerSerial(player) time = zeit*3600 local _stamp = getRealTime() _stamp = _stamp.timestamp local stamp = getRealTime( tonumber(_stamp+time) ) stamp = stamp.timestamp local query = "INSERT INTO ban ( Name, Admin, Grund, Datum, IP, Serial ) VALUES ( '"..name2.."', '"..name.."', '"..text.."', '"..stamp.."', '"..ip.."', '"..serial.."' )" local result = mysql_query( handler, query ) kickPlayer(player,"You were banned for "..zeit.." hours /Reason: "..text) addBan(ip, serial, getPlayerAccount(player), getPlayerFromName(name), text, zeit) outputChatBox(name2.." Was banned by " ..name.. " for " ..zeit.. " hour/s",getRootElement(),255,0,0,true) outputChatBox("Grund: "..text,getRootElement(),255,255,0,true) if result then mysql_free_result(result) return true else return false end end addEvent("Tban",true) addEventHandler("Tban",getRootElement(),addTimeBan) --Ban abfrage addEventHandler ( "onPlayerConnect", getRootElement(), function (playerNick, playerIP, playerUsername, playerSerial, playerVersionNumber ) local pname = playerNick local pserial = playerSerial local query = mysql_query( handler, "SELECT Name, Datum FROM ban WHERE Name = '"..pname.."'") local _query = mysql_query( handler, "SELECT Name, Datum FROM ban WHERE Serial = '"..pserial.."'") local rows = mysql_num_rows ( query ) local _rows = mysql_num_rows ( _query ) local _stamp = getRealTime() _stamp = tonumber(_stamp.timestamp) if rows > 0 then local dsatz = mysql_fetch_assoc ( query ) if _stamp > tonumber(dsatz["Datum"]) and tonumber(dsatz["Datum"]) == 0 then cancelEvent( true, "You are permanently banned" ) elseif _stamp > tonumber(dsatz["Datum"]) then mysql_query( handler, "DELETE FROM ban WHERE Name = '"..pname.."'") elseif _stamp < tonumber(dsatz["Datum"]) then cancelEvent( true, "You are still banned" ) end return true elseif _rows > 0 then local dsatz = mysql_fetch_assoc ( _query ) if _stamp > tonumber(dsatz["Datum"]) and tonumber(dsatz["Datum"]) == 0 then cancelEvent( true, "You are permanently banned" ) elseif _stamp > tonumber(dsatz["Datum"]) then mysql_query( handler, "DELETE FROM ban WHERE Serial = '"..pserial.."'") elseif _stamp < tonumber(dsatz["Datum"]) then cancelEvent( true, "You are still banned" ) end return true end end ) --Blow addEvent("Blow",true) addEventHandler("Blow",getRootElement(), function (admin,vehicle,player) if client ~= admin then return end if admin == player then return end if not hasRights(admin, 1) then return end blowVehicle(vehicle,false) outputChatBox("Your vehicle was Blown by "..getPlayerName(admin),player,255,0,0,true) for i, playerid in pairs (getElementsByType("player")) do local player22 = string.gsub(getPlayerName(player),"#%x%x%x%x%x%x", "") outputChatBox(getPlayerName(admin).." has blowed "..player22.."!", playerid, 255, 0, 0) end end ) addEvent("Mute",true) addEventHandler("Mute",getRootElement(), function (admin,player,time) if not hasRights(admin, 2) then return end if client ~= admin then return end local time = time*60000 if isPlayerMuted(player) == true then mutedby = (tonumber(getElementData(player, "mutedby"))) --muteteam = getTeamName(getPlayerTeam(admin)) muteteamnumber = (tonumber(getElementData(admin,"pAdminlevel"))) --[[if muteteam == "Xtreme-Players Server Owner" then muteteamnumber = 6 elseif muteteam == "Xtreme-Players Tean Manager" then muteteamnumber = 5 elseif muteteam == "Xtreme-Players Admins" then muteteamnumber = 4 elseif muteteam == "Xtreme-Players Moderators" then muteteamnumber = 3 elseif muteteam == "Xtreme-Players Member" then muteteamnumber = 2 end--]] if (muteteamnumber <= mutedby-1) then if admin == player then outputChatBox("You dont have the premissions to unmute yourself!", admin, 255, 0, 0) return else outputChatBox("You dont have the premissions to unmute "..getPlayerName(player).."!", admin, 255, 0, 0) return end elseif muteteamnumber >= mutedby then setPlayerMuted(player,false) removeEventHandler("onPlayerQuit",player,quit) if gTimerTable[getPlayerName(player)] then killTimer(gTimerTable[getPlayerName(player)]) end outputChatBox(getPlayerName(player).. " is not longer Muted!",getRootElement(),0,255,0,true) end elseif isPlayerMuted(player) == false then setPlayerMuted(player,true) setElementData(player,"mutedby",tonumber(getElementData(admin,"pAdminlevel"))) outputChatBox(getPlayerName(player).." has been Muted by "..getPlayerName(admin),getRootElement(),255,0,0,true) addEventHandler("onPlayerQuit",player,quit) gTimerTable[getPlayerName(player)] = setTimer(function (player) setPlayerMuted(player,false) outputChatBox(getPlayerName(player).." is not longer Muted!",getRootElement(),0,255,0,true) removeEventHandler("onPlayerQuit",player,quit) end,time,1,player) end end) function quit () if isTimer(gTimerTable[getPlayerName(source)]) then killTimer(gTimerTable[getPlayerName(source)]) removeEventHandler("onPlayerQuit",source,quit) end end --Tab2 --Gravity addEvent("gravity",true) addEventHandler("gravity",getRootElement(), function (player, gravity) if not hasRights(source,5) then return end setGravity(tonumber(gravity)) for id, player in ipairs ( getElementsByType ( "player" ) ) do setPedGravity ( player, getGravity() ) end outputChatBox("You setted the Gravitylevel to "..gravity, player, 255,0,0) end) --Weather addEvent("weather",true) addEventHandler("weather",getRootElement(), function (player, weather) if not hasRights(source,5) then return end if (weather == "Blue Sky, Sunny") then setWeather(0) end if (weather == "Blue Sky, Clouds") then setWeather(2) end if (weather == "Storming") then setWeather(8) end if (weather == "Cloudy and Foggy") then setWeather(9) end if (weather == "Clear Blue Sky") then setWeather(10) end if (weather == "Sunny, Scorching Hot") then setWeather(11) end if (weather == "Very Dull, Colourless, Hazy") then setWeather(12) end if (weather == "Dull, Cloudy, Rainy") then setWeather(16) end if (weather == "Sunny, Scorching Hot") then setWeather(17) end if (weather == "Sandstorm") then setWeather(19) end outputChatBox("You setted the Weather to "..weather, player, 255,0,0) end) --Time addEvent("time",true) addEventHandler("time",getRootElement(), function (player, hour, min) if not hasRights(source,5)then return end setTime(tonumber(hour), tonumber(min)) outputChatBox("You setted the Time to "..hour..":"..min, player, 255,0,0) end) --Waves addEvent("waves",true) addEventHandler("waves",getRootElement(), function (player, waves) if not hasRights(source,5) then return end setWaveHeight(tonumber(waves)) outputChatBox("You setted the Waves to "..waves, player, 255,0,0) end) --Gamespeed addEvent("gamespeed",true) addEventHandler("gamespeed",getRootElement(), function (player, gamespeed) if not hasRights(source,5) then return end setGameSpeed(tonumber(gamespeed)) outputChatBox("You setted the Gamespeed to "..gamespeed, player, 255,0,0) end) --GetCommandList addEvent("get_commands", true) addEventHandler("get_commands", getRootElement(), function (text, lines, resultcounter, fulllist) fulllist = fulllist commandtablelist = {} for index = comcounter - lines + 99, comcounter - lines - 1, -1 do if index >= 0 then peniscounter = 1 tragodie = {} commandlog = xmlLoadFile("commandlog.xml") idnode = xmlFindChild(commandlog, "id"..index, 0) if idnode then attribute = xmlNodeGetAttributes(idnode) for name,value in pairs ( attribute ) do tragodie[tonumber(peniscounter)] = value peniscounter = peniscounter + 1 end if string.find(string.lower(tragodie[1]), text) or string.find(string.lower(tragodie[2]), text) or string.find(string.lower(tragodie[3]), text) or string.find(string.lower(tragodie[4]), text) or string.find(string.lower(tragodie[5]), text) then resultcounter = resultcounter + 1 commandtablelist[resultcounter] = tragodie end end else fulllist = true end end triggerClientEvent("set_commands", getRootElement(), commandtablelist, resultcounter, fulllist) end) --Tab3 addEvent("unbann",true) addEventHandler("unbann",getRootElement(), function (player,ban) if not hasRights(source,5) then return end if client ~= player then return end mysql_query( handler, "DELETE FROM ban WHERE Name = '"..ban.."'") mysql_query( handler, "UPDATE account SET Banned = '0' WHERE Name = '"..ban.."'" ) end) --ADMINCMDS --Muten/Unmuten --[[addCommandHandler("pmute", function( player, cmd, target ) if ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Member" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Moderators" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Admins" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Server Owner" ) then local player2 = findPlayerByName( target ) if getElementData(player2,"pAdminlevel") == "4" then outputChatBox(":O You Bitch!", player,255,0,0) return end if ( player2 == nil ) then outputChatBox("Invalid username!", player,255,0,0) else setPlayerMuted(player2,true) if getTeamName(getPlayerTeam(player)) == "Xtreme-Players Server Owner" then setElementData(player2, "mutedby", 4) elseif getTeamName(getPlayerTeam(admin)) == "Xtreme-Players Team Manager" then setElementData(player2, "mutedby", 3) elseif getTeamName(getPlayerTeam(player)) == "Xtreme-Players Admins" then setElementData(player2, "mutedby", 2) elseif getTeamName(getPlayerTeam(player)) == "Xtreme-Players Moderators" then setElementData(player2, "mutedby", 1) elseif getTeamName(getPlayerTeam(player)) == "Xtreme-Players Member" then setElementData(player2, "mutedby", 0) end outputChatBox("You muted "..getPlayerName(player2).."!",player,255,0,0) outputChatBox("You have been muted by"..getPlayerName(player).."!",player2,255,0,0) if ( fileExists( "commandlog.txt" ) ) then logfile = fileOpen( "commandlog.txt" ) time = getRealTime() hour = time.hour min = time.minute sec = time.second day = time.monthday month = time.month + 1 year = time.year + 1900 while not fileIsEOF( logfile ) do buffer = fileRead( logfile, 500 ) end fileWrite( logfile, "["..day.."."..month.."."..year.."]["..hour..":"..min..":"..sec.."] command: "..cmd.." source: "..getPlayerName(player).." target: "..getPlayerName(player2).."\n" ) fileClose( logfile ) else logfile = fileCreate( "commandlog.txt" ) time = getRealTime() hour = time.hour min = time.minute sec = time.second day = time.monthday month = time.month + 1 year = time.year + 1900 fileWrite( logfile, "["..day.."."..month.."."..year.."]["..hour..":"..min..":"..sec.."] command: "..cmd.." source: "..getPlayerName(player).." target: "..getPlayerName(player2).."\n" ) fileClose( logfile ) end if fileExists("commandlog.xml") then commandlog = xmlLoadFile("commandlog.xml") newnode = xmlCreateChild(commandlog, "id"..comcounter) xmlNodeSetAttribute ( newnode, "Befehl", cmd ) xmlNodeSetAttribute ( newnode, "Benutzer", getPlayerName(player) ) xmlNodeSetAttribute ( newnode, "Ziel", getPlayerName(player2) ) xmlNodeSetAttribute ( newnode, "Zeit", hour..":"..min..":"..sec ) xmlNodeSetAttribute ( newnode, "Datum", day.."."..month.."."..year ) xmlSaveFile(commandlog) xmlUnloadFile(commandlog) comcounter = comcounter + 1 else commandlog = xmlCreateFile("commandlog.xml", "log") newnode = xmlCreateChild(commandlog,"id"..comcounter) xmlNodeSetAttribute ( newnode, "Befehl", cmd ) xmlNodeSetAttribute ( newnode, "Benutzer", getPlayerName(player) ) xmlNodeSetAttribute ( newnode, "Ziel", getPlayerName(player2) ) xmlNodeSetAttribute ( newnode, "Zeit", hour..":"..min..":"..sec ) xmlNodeSetAttribute ( newnode, "Datum", day.."."..month.."."..year ) xmlSaveFile(commandlog) xmlUnloadFile(commandlog) comcounter = comcounter + 1 end end else outputChatBox("You dont have the premissions to use this command!",player,255,0,0) end end) addCommandHandler("punmute", function( player, cmd, target ) if ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Member" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Moderators" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Admins" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Server Owner" ) then local player2 = findPlayerByName( target ) mutedby = getElementData(player2, "mutedby") muteteam = getTeamName(getPlayerTeam(player)) muteteamnumber = 0 if muteteam == "Xtreme-Players Server Owner" then muteteamnumber = 4 elseif muteteam == "Xtreme-Players Team Manager" then muteteamnumber = 3 elseif muteteam == "Xtreme-Players Admins" then muteteamnumber = 2 elseif muteteam == "Xtreme-Players Moderators" then muteteamnumber = 1 elseif muteteam == "Xtreme-Players Member" then muteteamnumber = 0 end if ( player2 == nil ) then outputChatBox("Invalid username!", player,255,0,0) else if muteteamnumber <= mutedby-1 then if player == player2 then outputChatBox("You dont have the premissions to unmute yourself!", player, 255, 0, 0) return else outputChatBox("You dont have the premissions to unmute "..player2.."!", player, 255, 0, 0) return end elseif muteteamnumber >= mutedby then setPlayerMuted(player2,false) outputChatBox("You unmuted "..getPlayerName(player2).."!",player,0,255,0) outputChatBox("You have been unmuted by"..getPlayerName(player).."!",player2,0,255,0) end end else outputChatBox("You dont have the premissions to use this command!",player,255,0,0) end end)--]] --Blow --[[addCommandHandler("pblow", function( player, cmd, target ) if getTeamName(getPlayerTeam(player)) == "Xtreme-Players Trial Member" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Member" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Moderator" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Admin" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Team Manager" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Server Owner" then player2 = findPlayerByName(target) if ( player2 == nil ) then outputChatBox("Invalid username!", player,255,0,0) else if(player2 == player) then outputChatBox("You can't blow yourself!", player, 255, 0, 0) return end veh = getPedOccupiedVehicle(player2) blowVehicle(veh) outputChatBox("You have been blowed "..getPlayerName(player2).."'s vehicle!",player,255,0,0) if getPlayerName(player) ~= "[XP]yourdeathcomes" or getPlayerName(player) ~= "HeadSh0T~" then outputChatBox("Your vehicle has been blowed by "..getPlayerName(player).."!",player2,255,0,0) end if getTeamName(getPlayerTeam(player)) == "Xtreme-Players Trial-Member" then for i, playerid in pairs (getElementsByType("player")) do if getTeamName(getPlayerTeam(player)) == "Xtreme-Players Moderator" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Admin" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Team Manager" or getTeamName(getPlayerTeam(player)) == "Xtreme-Players Server Owner" then local player22 = string.gsub(getPlayerName(player2),"#%x%x%x%x%x%x", "") outputChatBox("Xtreme-Players Trial-Member "..getPlayerName(player).." has blowed "..player22.."!", playerid, 255, 0, 0) end end end if ( fileExists( "commandlog.txt" ) ) then logfile = fileOpen( "commandlog.txt" ) time = getRealTime() hour = time.hour min = time.minute sec = time.second day = time.monthday month = time.month + 1 year = time.year + 1900 while not fileIsEOF( logfile ) do buffer = fileRead( logfile, 500 ) end fileWrite( logfile, "["..day.."."..month.."."..year.."]["..hour..":"..min..":"..sec.."] command: "..cmd.." source: "..getPlayerName(player).." target: "..getPlayerName(player2).."\n" ) fileClose( logfile ) else logfile = fileCreate( "commandlog.txt" ) time = getRealTime() hour = time.hour min = time.minute sec = time.second day = time.monthday month = time.month + 1 year = time.year + 1900 fileWrite( logfile, "["..day.."."..month.."."..year.."]["..hour..":"..min..":"..sec.."] command: "..cmd.." source: "..getPlayerName(player).." target: "..getPlayerName(player2).."\n" ) fileClose( logfile ) end if fileExists("commandlog.xml") then commandlog = xmlLoadFile("commandlog.xml") newnode = xmlCreateChild(commandlog, "id"..comcounter) xmlNodeSetAttribute ( newnode, "Befehl", cmd ) xmlNodeSetAttribute ( newnode, "Benutzer", getPlayerName(player) ) xmlNodeSetAttribute ( newnode, "Ziel", getPlayerName(player2) ) xmlNodeSetAttribute ( newnode, "Zeit", hour..":"..min..":"..sec ) xmlNodeSetAttribute ( newnode, "Datum", day.."."..month.."."..year ) xmlSaveFile(commandlog) xmlUnloadFile(commandlog) comcounter = comcounter + 1 else commandlog = xmlCreateFile("commandlog.xml", "log") newnode = xmlCreateChild(commandlog,"id"..comcounter) xmlNodeSetAttribute ( newnode, "Befehl", cmd ) xmlNodeSetAttribute ( newnode, "Benutzer", getPlayerName(player) ) xmlNodeSetAttribute ( newnode, "Ziel", getPlayerName(player2) ) xmlNodeSetAttribute ( newnode, "Zeit", hour..":"..min..":"..sec ) xmlNodeSetAttribute ( newnode, "Datum", day.."."..month.."."..year ) xmlSaveFile(commandlog) xmlUnloadFile(commandlog) comcounter = comcounter + 1 end end else outputChatBox("You dont have the premissions to use this command!",player,255,0,0) end end)]] --pkick --[[addCommandHandler("pkick", function( player, cmd, target ) if ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Member" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Moderators" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Admins" ) or ( getTeamName(getPlayerTeam(player)) == "Xtreme-Players Server Owner" ) then local player2 = findPlayerByName( target ) --local player2 = string.gsub(player22,"#%x%x%x%x%x%x", "") --local player2 = findPlayerByName( target ) if ( player2 == nil ) then outputChatBox("Invalid username!", player,255,0,0) else if ( getElementData(player2, "state" ) ~= "not ready" ) then outputChatBox ( "You only can kick Players which state is 'not ready'. For camper use '/pblow'!", player, 255, 0, 0 ) return false end if ( fileExists( "commandlog.txt" ) ) then logfile = fileOpen( "commandlog.txt" ) time = getRealTime() hour = time.hour min = time.minute sec = time.second day = time.monthday month = time.month + 1 year = time.year + 1900 while not fileIsEOF( logfile ) do buffer = fileRead( logfile, 500 ) end fileWrite( logfile, "["..day.."."..month.."."..year.."]["..hour..":"..min..":"..sec.."] command: "..cmd.." source: "..getPlayerName(player).." target: "..getPlayerName(player2).."\n" ) fileClose( logfile ) else logfile = fileCreate( "commandlog.txt" ) time = getRealTime() hour = time.hour min = time.minute sec = time.second day = time.monthday month = time.month + 1 year = time.year + 1900 fileWrite( logfile, "["..day.."."..month.."."..year.."]["..hour..":"..min..":"..sec.."] command: "..cmd.." source: "..getPlayerName(player).." target: "..getPlayerName(player2).."\n" ) fileClose( logfile ) end if fileExists("commandlog.xml") then commandlog = xmlLoadFile("commandlog.xml") newnode = xmlCreateChild(commandlog, "id"..comcounter) xmlNodeSetAttribute ( newnode, "Befehl", cmd ) xmlNodeSetAttribute ( newnode, "Benutzer", getPlayerName(player) ) xmlNodeSetAttribute ( newnode, "Ziel", getPlayerName(player2) ) xmlNodeSetAttribute ( newnode, "Zeit", hour..":"..min..":"..sec ) xmlNodeSetAttribute ( newnode, "Datum", day.."."..month.."."..year ) xmlSaveFile(commandlog) xmlUnloadFile(commandlog) comcounter = comcounter + 1 else commandlog = xmlCreateFile("commandlog.xml", "log") newnode = xmlCreateChild(commandlog,"id"..comcounter) xmlNodeSetAttribute ( newnode, "Befehl", cmd ) xmlNodeSetAttribute ( newnode, "Benutzer", getPlayerName(player) ) xmlNodeSetAttribute ( newnode, "Ziel", getPlayerName(player2) ) xmlNodeSetAttribute ( newnode, "Zeit", hour..":"..min..":"..sec ) xmlNodeSetAttribute ( newnode, "Datum", day.."."..month.."."..year ) xmlSaveFile(commandlog) xmlUnloadFile(commandlog) comcounter = comcounter + 1 end blowVehicle(getPedOccupiedVehicle(player2), true) setTimer ( function() kickPlayer(player2, player) end, 1000, 1) end else outputChatBox("You dont have the premissions to use this command!",player,255,0,0) end end)--]] --Findplayer function findPlayerByName( Part ) local Player = getPlayerFromName( Part ) if isElement( Player ) then return Player else for i, p in ipairs ( getElementsByType( "player" ) ) do if ( string.find( getPlayerName(p), Part ) ) then return p end end end end --Tab4 addEvent("s_GetMaps",true) addEventHandler("s_GetMaps",getRootElement(), function () tableOutput = {} local gamemodes = {} gamemodes = call(getResourceFromName("mapmanager"), "getGamemodes") for id,gamemode in ipairs (gamemodes) do tableOutput[id] = {} tableOutput[id].name = getResourceInfo(gamemode, "name") or getResourceName(gamemode) tableOutput[id].maps = {} local maps = call(getResourceFromName("mapmanager"), "getMapsCompatibleWithGamemode" , gamemode) for _,map in ipairs (maps) do table.insert(tableOutput[id]["maps"] ,{name = getResourceInfo(map, "name") or getResourceName(map), resname = getResourceName(map)}) end table.sort(tableOutput[id]) end local map = call(getResourceFromName("mapmanager"), "getRunningGamemodeMap") local gamemode = call(getResourceFromName("mapmanager"), "getRunningGamemode") gamemode = gamemode and getResourceName(gamemode) or "N/A" map = map and getResourceName(map) or "N/A" triggerClientEvent(source ,"c_GetMaps", source, tableOutput,gamemode,map) end) addEvent("s_GetWhishes",true) addEventHandler("s_GetWhishes",getRootElement(), function (player) local query = "SELECT * FROM whishlist" local result = mysql_query( handler, query ) if ( result and mysql_num_rows( result ) > 0) then row = mysql_fetch_assoc(result) while row do local map = row["map"] local name = row["name"] row = mysql_fetch_assoc(result) triggerClientEvent("c_GiveWishes",player,map,name) end end end) local alreadySeted = false addEvent("onServerConfirmNexmtap",true) addEventHandler("onServerConfirmNexmtap",root, function() alreadySeted = true end ) addEvent("setMap",true) addEventHandler("setMap",getRootElement(), function (player,map,name,delvar) if delvar ~= 1 then if not hasRights(source,4) then return end end if alreadySeted then outputChatBox("One map its already setted!",player,255,0,0) return end if delvar == 1 then local mapname1 = mysql_escape_string(handler, map) local name1 = mysql_escape_string(handler, name) mysql_query( handler, 'DELETE FROM whishlist WHERE map = "'..mapname1..'" AND name = "'..name1..'"') setElementData(player,"isAllowedToSet",true) end executeCommandHandler("nextmap",player,map) end ) addEvent("whishMap",true) addEventHandler("whishMap",getRootElement(), function (player,map) local name = getPlayerName(player) local query = "SELECT * FROM whishlist WHERE name = '"..name.."'" local result = mysql_query( handler, query ) if ( result and mysql_num_rows( result ) > 1) then return end local query = "SELECT * FROM whishlist WHERE map = '"..map.."'" local result = mysql_query( handler, query ) if ( result and mysql_num_rows( result ) == 1) then outputChatBox("This map was already wished!",player,255,0,0) return end outputChatBox("You wished the map "..map,player,0,255,0) local query = 'INSERT INTO whishlist ( map,name ) VALUES ( "'..map..'", "'..name..'" )' local result = mysql_query( handler, query ) --//Tell xp members. for i, playerid in ipairs (getElementsByType("player")) do if tonumber(getElementData(playerid, "pLogin")) == 1 then local team = getPlayerTeam(playerid) local level = getElementData(playerid,"pAdminlevel") if team then if hasRights(admin, 3) then if player ~= playerid then outputChatBox("[Wishmap] "..name:gsub("#%x%x%x%x%x%x","").." wished the Map "..map..".",playerid,0,255,0) end end end end end end ) addEvent("removeWhish",true) addEventHandler("removeWhish",getRootElement(), function (player,map,name) outputChatBox("Map form wishlist removed!",player,255,0,0) mysql_query( handler, 'DELETE FROM whishlist WHERE map = "'..map..'" AND name = "'..name..'"') end) --RandomWish addCommandHandler("randomwish", function (player) if not hasRights(player, 3) then return end if not alreadySeted then local result = mysql_query( handler, 'SELECT COUNT(*) FROM whishlist' ) if result then local row = mysql_fetch_row(result) if row then local count = math.random(0,row[1]-1) local result = mysql_query( handler, 'SELECT map,name FROM whishlist LIMIT '..count..',1' ) row = mysql_fetch_assoc(result) if row then name = row["name"] map = row["map"] alreadySeted = true mysql_query( handler, 'DELETE FROM whishlist WHERE map = "'..map..'" AND name = "'..name..'"') setElementData(player, "randomwhish", 1) executeCommandHandler("nextmap",player,map) else outputChatBox("[Wishlist] Can't get final row!",player,255,0,0) end end else outputChatBox("There's no Map in the Wishlist",player,255,0,0) end else outputChatBox("One map its already setted!",player,255,0,0) end end ) addCommandHandler("nextblock", function(player) local team = getPlayerTeam(player) local name = getPlayerName(player) local level = getElementData(player,"pAdminlevel") if team then if hasRights(player, 3)then alreadySeted = not alreadySeted outputChatBox("[Admin] Nextmap block has changed map block to: "..tostring(alreadySeted)..".",root,0,255,0) end end end ) function getXtremeAdmins() local adminList = {} for k,v in ipairs(getElementsByType("player")) do if hasRights(v, 3) then adminList[#adminList+1] = v end end return adminList end function onFinishedCurrentMap() alreadySeted = false outputDebugString("[Wishlist] Map set block updated! (Changed to: "..tostring(alreadySeted)..")",player,255,0,0) end addEvent("onMapStarting",true) addEventHandler("onMapStarting",root,onFinishedCurrentMap) function onAdminChecker() --outputChatBox("[XP]AdminBot: Attempt to do auto-set if no admin.",root,255,255,255,true) local pAdmins = getXtremeAdmins() if #pAdmins < 1 then if not alreadySeted then local result = mysql_query( handler, 'SELECT COUNT(*) FROM whishlist' ) if result then row = mysql_fetch_row(result) if row then if row[1]-1 >= 0 then local count = math.random(0,row[1]-1) local result = mysql_query( handler, 'SELECT map,name FROM whishlist LIMIT '..count..',1' ) row = mysql_fetch_assoc(result) if row then map = row["map"] name = row["name"] alreadySeted = true outputDebugString("[Wishlist] Next map setted to: "..map) mysql_query( handler, 'DELETE FROM whishlist WHERE map = "'..map..'" AND name = "'..name..'"') --//Make it happen. triggerEvent("onServerWannaSetmap",getResourceRootElement(getThisResource()),map) else outputDebugString("[Wishlist] Can't get final row!") end else outputDebugString("[Wishlist] Wishlist its empty!") end else outputDebugString("[Wishlist] Can't get row!") end else outputDebugString("[Wishlist] Can't get result!") end else outputDebugString("[Wishlist] One map where already setted.") end else outputDebugString("[Wishlist] There's one or more online admin.") end end setTimer(onAdminChecker,120000,0) --//2 Minutes. --Tab5 addEvent("refreshTotalAccounts", true) addEventHandler("refreshTotalAccounts", getRootElement(), function() local query = "SELECT COUNT(*) FROM account;" local result = mysql_query(handler, query) row = mysql_fetch_row(result) if row then setElementData(root, "totalAccounts", row[1]) end end) function getRankColorName(level) if level then if level == 1 then return "#18BC5BMember" elseif level == 2 then return "#FFFF00Moderator" elseif level == 3 then return "#0000CCAdmin" elseif level == 4 then return "#F45F2FTeam-Manager" elseif level == 5 then return "#CC0000Server Owner" else return "" end end end addEvent("setUserData", true) addEventHandler("setUserData", getRootElement(), function (wert, data, player, player2) if not hasRights(source,5) then return end if data == "Adminlevel" then local RankName = getRankColorName(wert) outputDebugString(wert) outputDebugString(RankName) mysql_query(handler,"UPDATE account SET Adminlevel = '"..wert.."' WHERE NAME = '"..player.."'") mysql_query(handler,"UPDATE account SET Title = '"..RankName.."' WHERE NAME = '"..player.."'") elseif data == "Name" then local query = "SELECT * FROM account WHERE Name = '"..wert.."'" local result = mysql_query(handler, query) row = mysql_num_rows(result) if row > 0 then outputChatBox("This Name is already in use!", player2, 255, 0, 0) return end if getPlayerFromName(player) ~= false then outputChatBox("This player is Online, use the Player Managemant to change his Stats", player2, 255, 0, 0) return end mysql_query(handler,"UPDATE account SET Name = '"..wert.."' WHERE NAME = '"..player.."'") outputChatBox("You changed the Name from "..player.." to "..wert..".", player2, 255, 0, 0) elseif data == "Money" then mysql_query(handler,"UPDATE account SET Geld = '"..wert.."' WHERE NAME = '"..player.."'") elseif data == "Points" then mysql_query(handler,"UPDATE account SET Points = '"..wert.."' WHERE NAME = '"..player.."'") elseif data == "Wins" then mysql_query(handler,"UPDATE account SET Wins = '"..wert.."' WHERE NAME = '"..player.."'") end end) addEvent("searchPlayers", true) addEventHandler("searchPlayers", getRootElement(), function(wert, wert2) if not hasRights(source,5) then return end if wert2 == "Name" then local accTable = {} local query = "SELECT * FROM account WHERE Name LIKE \'%"..wert.."%\';" local result = mysql_query(handler, query) if (result and mysql_num_rows(result) > 0) then local testcounter = mysql_num_rows(result) local testcounter2 = 0 while(testcounter > 0) do testcounter2 = testcounter2 + 1 local row = mysql_fetch_assoc(result) local dataTable = {} dataTable[1] = row['Name'] dataTable[2] = row['Geld'] dataTable[3] = row['Points'] dataTable[4] = row['Wins'] dataTable[5] = row['Spielzeit'] dataTable[6] = row['Adminlevel'] accTable[testcounter2] = dataTable testcounter = testcounter - 1 end triggerClientEvent("fillPlayerlist2", source, accTable) end elseif wert2 == "Serial" then local accTable = {} local query = "SELECT * FROM account WHERE LastSerial LIKE \'%"..wert.."%\';" local result = mysql_query(handler, query) if (result and mysql_num_rows(result) > 0) then local testcounter = mysql_num_rows(result) local testcounter2 = 0 while(testcounter > 0) do testcounter2 = testcounter2 + 1 local row = mysql_fetch_assoc(result) local dataTable = {} dataTable[1] = row['Name'] dataTable[2] = row['Geld'] dataTable[3] = row['Points'] dataTable[4] = row['Wins'] dataTable[5] = row['Spielzeit'] dataTable[6] = row['Adminlevel'] accTable[testcounter2] = dataTable testcounter = testcounter - 1 end triggerClientEvent("fillPlayerlist2", source, accTable) end elseif wert2 == "Adminlevel" then local accTable = {} if wert == "" then local query = "SELECT * FROM account WHERE Adminlevel > 0;" local result = mysql_query(handler, query) if (result and mysql_num_rows(result) > 0) then local testcounter = mysql_num_rows(result) local testcounter2 = 0 while(testcounter > 0) do testcounter2 = testcounter2 + 1 local row = mysql_fetch_assoc(result) local dataTable = {} dataTable[1] = row['Name'] dataTable[2] = row['Geld'] dataTable[3] = row['Points'] dataTable[4] = row['Wins'] dataTable[5] = row['Spielzeit'] dataTable[6] = row['Adminlevel'] accTable[testcounter2] = dataTable testcounter = testcounter - 1 end triggerClientEvent("fillPlayerlist2", source, accTable) end elseif tonumber(wert) > 0 then local query = "SELECT * FROM account WHERE Adminlevel = \'"..wert.."\';" local result = mysql_query(handler, query) if (result and mysql_num_rows(result) > 0) then local testcounter = mysql_num_rows(result) local testcounter2 = 0 while(testcounter > 0) do testcounter2 = testcounter2 + 1 local row = mysql_fetch_assoc(result) local dataTable = {} dataTable[1] = row['Name'] dataTable[2] = row['Geld'] dataTable[3] = row['Points'] dataTable[4] = row['Wins'] dataTable[5] = row['Spielzeit'] dataTable[6] = row['Adminlevel'] accTable[testcounter2] = dataTable testcounter = testcounter - 1 end triggerClientEvent("fillPlayerlist2", source, accTable) end end end end) addEvent("searchPlayers2", true) addEventHandler("searchPlayers2", getRootElement(), function() if not hasRights(source,5)then return end local accTable = {} local query = "SELECT * FROM account ORDER BY LastQuit DESC LIMIT 20;" local result = mysql_query(handler, query) if (result and mysql_num_rows(result) > 0) then local testcounter = mysql_num_rows(result) local testcounter2 = 0 while(testcounter > 0) do testcounter2 = testcounter2 + 1 local row = mysql_fetch_assoc(result) local dataTable = {} dataTable[1] = row['Name'] dataTable[2] = row['Geld'] dataTable[3] = row['Points'] dataTable[4] = row['Wins'] dataTable[5] = row['Spielzeit'] dataTable[6] = row['Adminlevel'] accTable[testcounter2] = dataTable testcounter = testcounter - 1 end triggerClientEvent("fillPlayerlist3", source, accTable) end end) function addOfflineBan ( name,player,text) if not hasRights(admin, 4)then return end if client ~= getPlayerFromName(name) then return end local zeit = 0 local query1 = "SELECT LastSerial FROM account WHERE Name = '"..player.."'" local result1 = mysql_query( handler, query1 ) if (result1 and mysql_num_rows(result1) > 0) then local row = mysql_fetch_assoc(result1) local serial = row['LastSerial'] local query = "INSERT INTO ban ( Name, Admin, Grund, Datum, Serial ) VALUES ( '"..player.."', '"..name.."', '"..text.."', '"..tonumber(zeit).."', '"..serial.."' )" local result = mysql_query( handler, query ) outputChatBox(player.." Was permanently banned by " ..name.. ".",getRootElement(),255,0,0,true) outputChatBox("Reason: "..text,getRootElement(),255,255,0,true) end if result2 then mysql_free_result(result1) end if result then mysql_free_result(result) return true else return false end end addEvent("BanOffline",true) addEventHandler("BanOffline",getRootElement(),addOfflineBan) The level 1 i want can do blow not kick , mute/mute and time ban, level 2 can do blow , kick, mute/unmute not time ban 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