Jump to content

Memory

Members
  • Posts

    383
  • Joined

  • Last visited

Everything posted by Memory

  1. Здравствуйте, помогите, пожалуйста, сделать отсортировку для gui, чтобы отображалось имя аккаунта и поинты. Код отсортировки и отображения в чате. function sortAccounts( ) local rowdata = { } for _, account in pairs( getAccounts( ) ) do rowdata[ #rowdata + 1 ] = { account = getAccountName( account ), points = getAccountData( account,"Points" ) } end table.sort( rowdata, function ( a, b ) return ( tonumber( a.points ) or 0 ) > ( tonumber( b.points ) or 0 ) end ) return rowdata end function tables( ) outputChatBox( "Top 10 points:", root, 255,255,255 ) for index, data in ipairs( sortAccounts( ) ) do outputChatBox(tostring( index )..": ".. tostring( data.account ) .." - ".. tostring( data.points ), root, 255, 255, 255 ) if index == 10 then break end end triggerClientEvent( 'onAccountsSend',root,sortAccounts( ) ) end addCommandHandler( "top", tables ) Gui local ME = getLocalPlayer() local ROOT = getRootElement() local ROOTRES = getResourceRootElement(getThisResource()) local TOPTEN = {} local GUI = {} addEvent("onReceiveTopTen", true) addEventHandler("onReceiveTopTen", ROOT, function(t) TOPTEN = t end) addCommandHandler("topten", function() toggleGUI() end) addEventHandler("onClientResourceStart", ROOTRES, function() triggerServerEvent("onClientRequestTopTen", ME) toptenGUI() bindKey("F1", "down", toggleGUI) end) function toggleGUI() if guiGetVisible(GUI.wdw) then guiSetVisible(GUI.wdw, false) showCursor(false) else triggerServerEvent("onClientRequestTopTen", ME) guiGridListClear(GUI.list) for _, rank in ipairs(TOPTEN) do local row = guiGridListAddRow(GUI.list) guiGridListSetItemText(GUI.list, row, 1, data.account, false, false) guiGridListSetItemText(GUI.list, row, 2, data.points, false, false) end showCursor(true) guiSetVisible(GUI.wdw, true) end end function toptenGUI() GUI.wdw = guiCreateWindow(0.300, 0.330, 0.400, 0.400, "Top ten", true) guiWindowSetSizable(GUI.wdw, false) guiWindowSetMovable(GUI.wdw, false) GUI.list = guiCreateGridList(0, 0.11, 1, 0.750, true, GUI.wdw) guiGridListAddColumn(GUI.list, "name", 0.6) guiGridListAddColumn(GUI.list, "points", 0.3) GUI.close = guiCreateButton(0, 0.890, 1, 0.060, "exit", true, GUI.wdw) addEventHandler("onClientGUIClick", GUI.close, toggleGUI, false) guiSetAlpha(GUI.wdw, 0.6) guiSetFont(GUI.list, "default-small") guiSetFont(GUI.close, "default-small") guiSetVisible(GUI.wdw, false) end
  2. Что-то не перебрасывает, уже столько перепробовал addEventHandler ('onPlayerJoin', root, function () redirectPlayer (source, 'здесь ip', порт) end ) function redirect() redirectPlayer(source, "ip", tonumber(port)) end addEventHandler("onPlayerJoin", root, redirect) local ip = "ip" local port = "port" local root = getRootElement() addEventHandler("onPlayerJoin", root, function() redirectPlayer(source, ip, port) end)
  3. Как сделать переадресацию, чтобы при заходе на один сервер перебрасывало на другой. Заранее спасибо.
  4. Memory

    Team Saving

    Download https://community.multitheftauto.com/ind ... ls&id=3396
  5. О, спасибо, я дествительно этого не знал. Так насчёт скрипта, может надо использовать triggerClientEvent, я опять попробовал, но не работает. local root = getRootElement() function vip(player) acc = getAccountName(getPlayerAccount(player)) if(isObjectInACLGroup("user."..acc,aclGetGroup("Admin"))) then triggerClientEvent ( "oninfernus", getRootElement()) end end addEventHandler("onPlayerLogin", root, vip) function infernus() txd = engineLoadTXD ( "infernus.txd" ) engineImportTXD ( txd, 411 ) dff = engineLoadDFF ( "infernus.dff", 411 ) engineReplaceModel ( dff, 411 ) end addEvent( "oninfernus", true ) addEventHandler( "oninfernus", getRootElement(), infernus )
  6. Thank you very much. It works
  7. Помогите исправить код, заранее спасибо function vipinfernus(player) acc = getAccountName(getPlayerAccount(player)) if(isObjectInACLGroup("user."..acc,aclGetGroup("Admin"))) then txd = engineLoadTXD ( "infernus.txd" ) engineImportTXD ( txd, 411 ) dff = engineLoadDFF ( "infernus.dff", 411 ) engineReplaceModel ( dff, 411 ) end
  8. Memory

    Some questions

    up
  9. Please, can you to show example?
  10. I think I need to use"triggerServerEvent", but doesn't work. local screenWidth, screenHeight = guiGetScreenSize() function gmonimg() triggerServerEvent("gmon",getRootElement()) guiCreateStaticImage(screenWidth/2-65, 0, 165, 65, "gm.png", false, nil) end
  11. Memory

    Some questions

    I make "send map name" script, but text incorrectly displayed "User Player thinks that better remove map reportmap" function send(player,mapName) map=mapName text="User "..tostring(getPlayerName(player)).." thinks that better remove map "..map report_id = math.random(111111111,999999999) filename = "maps/"..tostring(getPlayerName(player)).." - "..tostring(report_id)..".xml" RootNode = xmlCreateFile(tostring(filename),"Maps") NewNode = xmlCreateChild(RootNode, "Text" ) xmlNodeSetValue(NewNode,text) xmlSaveFile(RootNode) outputChatBox("The map was succesful reported!",player,255,255,255) end addEvent("send",true) addEventHandler("send",getRootElement(),send) addCommandHandler("reportmap", send)
  12. Hi, Can you help me to create some functions. What use for send map name to map.xml on command /reportmap? And how to deny supermoderators to ban or kick other moderators?
  13. Anyway doesn't work
  14. Hello, I have the code addEvent("onMapStarting") addEventHandler("onMapStarting", getRootElement(), function(mapInfo) if string.find(mapInfo.name, "[DM]", 1, true) or mapInfo.modename == "Sprint" then gmon() else gmoff() end end) function gmon(player) for theKey,thePlayer in ipairs(getElementsByType("player")) do setElementData( thePlayer, "overrideCollide.uniqueblah", 0, false ) outputChatBox("GM enabled",thePlayer,186,212,71,true) end end function gmoff(player) for theKey,thePlayer in ipairs(getElementsByType("player")) do setElementData(thePlayer, "overrideCollide.uniqueblah", nil, false ) outputChatBox("GM disabled",thePlayer,255,255,255,true) end end I want add image if gm enabled and if disabled. I tryed create client, but code doesn't work. What could be the problem? local screenWidth, screenHeight = guiGetScreenSize() function gmimgs(mapInfo) if string.find(mapInfo.name, "[DM]", 1, true) or mapInfo.modename == "Sprint" then gmonimg() else gmoffimg() end end addEvent("onMapStarting") addEventHandler("onMapStarting", getRootElement(), gmimgs) function gmonimg() guiCreateStaticImage ( screenWidth/2-65, 0, 165, 65, "gm_on.png", false, nil) end end function gmoffimg() guiCreateStaticImage(screenWidth/2-65, 0, 165, 65, "gm_off.png", false, nil) end end
  15. Memory

    Save team

    Thanks, work
  16. Здравствуйте, можете помочь сделать скрипт, чтобы при команде, например, /setmap, в файл maps.xml посылалось название карты, в которой играет игрок.
  17. Memory

    Save team

    Hi, I have this code function setTeam() local account = getPlayerAccount(source) -- gets players account local team = getAccountData (account, "team") -- gets players team if (team) and getTeamFromName(team) then setPlayerTeam(source, getTeamFromName(team)) -- sets players team end end addEventHandler("onPlayerLogin",root,setTeam) -- sets players team on login function save() local team = getPlayerTeam(source) -- Gets the players team local account = getPlayerAccount(source) if (team) and not isGuestAccount(account) then -- Checks to see if the player is a guest or not setAccountData(account, "team", getTeamName(team)) --saves team end end addEventHandler("onPlayerQuit", getRootElement(), save) But if remove player, he after reconnect again in team, problem with the save. Function for to removed players. function unassignTeam ( source, commandName ) local account = getPlayerAccount(source) local team = getAccountData (account, "team") -- Check if the player is on a team if team then -- this player is on a team, so we can remove them from it setPlayerTeam ( source, nil ) -- remove the player from the current team end end addCommandHandler ( "takeawaymyteam", unassignTeam ) I try use this, but doesn't work. function delete( source, commandName ) local team = getPlayerTeam(source) local account = getPlayerAccount(source) if (team) and not isGuestAccount(account) then setAccountData(account, "team", nil) end end addCommandHandler ( "remove", delete )
  18. Memory

    Transparency

    Hi, Please, help with code, he doesn't work. function transparency( ) local fX, fY, fZ = getElementPosition ( source ) for _, pVehicle in ipairs ( getElementsByType 'vehicle' ) do local fVehicleX, fVehicleY, fVehicleZ = getElementPosition ( pVehicle ) local fDistance = getDistanceBetweenPoints3D ( fVehicleX, fVehicleY, fVehicleZ, fX, fY, fZ ) if ( fDistance < 10 ) then setElementAlpha(getPedOccupiedVehicle(source),150) setElementAlpha(source,150) setPlayerNametagShowing(source, false) else setElementAlpha(getPedOccupiedVehicle(source),255) setElementAlpha(source,255) setPlayerNametagShowing(source, true) end end setTimer (transparency,1000,1) end
  19. Thank you
  20. Hello, How can, from this code, make command - /rank and outputChatBox("Your position "..position, root, 255, 255, 255 ) Sort code function sortAccounts( ) local rowdata = { } for _, account in pairs( getAccounts( ) ) do rowdata[ #rowdata + 1 ] = { account = getAccountName( account ), points = getAccountData( account,"Points" ) } end table.sort( rowdata, function ( a, b ) return ( tonumber( a.points ) or 0 ) > ( tonumber( b.points ) or 0 ) end ) return rowdata end
  21. Memory

    Set timeleft

    Hi, How can create function "set timeleft", example, if get hunter, time set to 2 minutes?
  22. Hi, Can you are help, make this function for all players, who finished, get points? function raceWin( rank ) local acc = getPlayerAccount( source ) local ptzData = getAccountData( acc, "Points" ) if rank < 4 then if ptzData then setAccountData( acc, "Points", ptzData + pointswin ) else setAccountData( acc, "Points", pointswin ) end outputChatBox("[Points]#FFFFFF " .. getPlayerName(source).. " #00FF00 receive 1 point", getRootElement(), 255, 255, 255, true ) end end addEventHandler("onPlayerFinish", getRootElement(), raceWin) How can make points for 2 and 3 places? function check() local alive = getAlivePlayers() local player = alive[1] local acc = getPlayerAccount( player ) local ptzData = getAccountData( acc, "Points" ) if (#alive == 1) then if ptzData then setAccountData( acc, "Points", ptzData + pointsToWin ) else setAccountData( acc, "Points", pointsToWin ) end outputChatBox("[Points]#FFFFFF " .. getPlayerName(player).. " #00FF00 receive 10 points", getRootElement(), 255, 255, 255, true ) end end addEventHandler("onPlayerWasted",getRootElement(),check)
  23. Full code client function GMStart() addEventHandler("onClientRender",getRootElement(),GmDefaultText) end addEvent("onGMStart",true) addEventHandler("onGMStart",getRootElement(),GMStart) function GMStop() removeEventHandler("onClientRender",getRootElement(),GmDefaultText) removeEventHandler("onClientRender",getRootElement(),VoteNumber) if votecount >= reqPlayers then triggerServerEvent("onVoteSuccess",getRootElement()) else triggerServerEvent("onVoteFail",getRootElement()) end end addEvent("onGMStop",true) addEventHandler("onGMStop",getRootElement(),GMStop) local width, height = guiGetScreenSize() function GmDefaultText() dxDrawText("Press G to vote for Ghostmode",(3/1440)*width,(570/850)*width,(1439/1440)*width,(672/850)*width, tocolor(255,255,255,255), 0.9,"bankgothic","center", "center", false, false, true) end function GMStart2(pcount,vcount) addEventHandler("onClientRender",getRootElement(),VoteNumber) votecount = vcount if pcount == 1 then reqPlayers = 1 elseif pcount > 1 and pcount < 4 then reqPlayers = 2 elseif pcount > 3 and pcount < 7 then reqPlayers = 3 elseif pcount > 6 and pcount < 10 then reqPlayers = 5 elseif pcount > 9 and pcount < 15 then reqPlayers = 7 elseif pcount > 14 and pcount < 21 then reqPlayers = 12 elseif pcount > 20 and pcount < 26 then reqPlayers = 17 elseif pcount > 25 then reqPlayers = 21 end end addEvent("onGMStart2",true) addEventHandler("onGMStart2",getRootElement(),GMStart2) function GMUpdate(vocount) removeEventHandler("onClientRender",getRootElement(),VoteNumber) votecount = votecount + 1 addEventHandler("onClientRender",getRootElement(),VoteNumber) end addEvent("onGMUpdate",true) addEventHandler("onGMUpdate",getRootElement(),GMUpdate) function VoteNumber() dxDrawText(votecount.."/"..reqPlayers.." votes recieved",0,(645/890)*width,(1439/1440)*width,(701/890)*width,tocolor(0,255,0,255),0.7,"bankgothic","center","center",false,false,false) end function resWarning() if (width < 1280) and (height < 720) then outputChatBox("You are running on low resolutions, some elements will not appear correctly![Minimum: 1280 x 720]",255,0,0) end end addEventHandler("onClientPlayerJoin",getRootElement(),resWarning) server *Created By MAR 2010 addEvent("onMapStarting") function onResourceStart() executeSQLCreateTable("GmBlockList", "serial STRING") end function KeyBind(pcount,vcount) -- bind the key for all players. local resourceName = getMapName() if string.find(resourceName, "[DD]", 1, true) or string.find(resourceName, "DD", 1, true) then elseif string.find(resourceName, "[FUN]", 1, true) or string.find(resourceName, "Fun", 1, true) then else local players = getElementsByType("player") local pcount = getPlayerCount() executeSQLQuery("DELETE FROM GmBlockList") vcount = 0 for k,v in ipairs (players) do bindKey(v,"g","down",addVote) setElementData( v, "overrideCollide.uniqueblah", nil, false ) end triggerClientEvent(getRootElement(),"onGMStart", getRootElement()) triggerClientEvent(getRootElement(),"onGMStart2", getRootElement(),pcount,vcount) end end addEventHandler("onMapStarting",getRootElement(),KeyBind) function KeyUnBind(newStateName,oldStateName) -- unbind the key for all players when the countdown finishes. if newStateName == "Running" then local players = getElementsByType("player") triggerClientEvent(getRootElement(),"onGMStop", getRootElement()) for k,v in ipairs (players) do unbindKey(v,"g","down",addVote) end executeSQLQuery("DELETE FROM GmBlockList") end end addEvent("onRaceStateChanging") addEventHandler("onRaceStateChanging",getRootElement(),KeyUnBind) function addVote(keyPresser) local serial = getPlayerSerial(keyPresser) local serialcheck = executeSQLSelect ( "GmBlockList", "serial","serial = '" .. serial .. "'") if ( type( serialcheck ) == "table" and #serialcheck == 0 ) or not serialcheck then executeSQLInsert ( "GmBlockList", "'"..serial.."'") triggerClientEvent("onGMUpdate",getRootElement()) else outputChatBox("You have already voted for Ghostmode.",keyPresser,255,0,0) end end function success() local players = getElementsByType("player") for theKey,thePlayer in ipairs(players) do setElementData( thePlayer, "overrideCollide.uniqueblah", 0, false ) outputChatBox("#B05555[Vote]#98FB98Ghostmode activated",thePlayer,255,255,255, true) end end addEvent("onVoteSuccess",true) addEventHandler("onVoteSuccess",getRootElement(),success) function failed() for k,v in ipairs(getElementsByType("player")) do outputChatBox("#B05555[Vote]#FF6A6AGhostmode deactivated",v,255,255,255, true) end end addEvent("onVoteFail",true) addEventHandler("onVoteFail",getRootElement(),failed)
  24. Thanks, but code doesn't work, message repeat
×
×
  • Create New...