Jump to content

myjobisgop

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by myjobisgop

  1. Нет, файл открвыется только во время события onPlayerQuit, затем в него записываются данные игрока, файл сохраняетя и закрываетя.
  2. Написал небольшой скрипт, который сохраняет данные игрока. Реализовано это так: при выходе игрока с сервера, его данные (координаты, уровень жизни, брони,..) сохраняются в XML файл, которые содержит сохраненные данные всех игроков. Заметил, что при падениях сервера (сбои на моем хостинге бывают часто) удаляются все данные из XML файла. Не подскажете, почему это может происходить и как можно избежать подобные вещи?
  3. При большом онлайне у игроков очень медленно скачиваются файлы (Доходит до того, что 800 мегабайт могут скачивать час или 3 кб загружаются 20 минут). Я сначало думал, что ддосят порт на загрузку, но команда openports показывала - все порты открыты. В чем может быть дело, в мта или сервере? У меня VDS, система CentOs 6.5.
  4. Сколько раз ставил мта сервер на линуксе, всегда автоматически заполнялись IP и порт в конфиге.
  5. Тут же все просто: ServerIP = getServerConfigSetting("serverip") ServerPort = getServerConfigSetting("serverport") Разве нет?
  6. Spajk, Look carefuly at my code please. I put array in account data there previously a string value, made by toJSON.
  7. DbHost: triniti.ru-hoster.com OS: Linux
  8. I want to connect to MySQL in my script. To do this, I write the following code: local dbConnectHost = "dbname="..DBName..";host="..DBHost..";port="..DBPort DB = dbConnect("mysql", dbConnectHost, DBUsername, DBPassword) Variables DBName, DBHost, DBPort, DBUsername, DBPassword have already defined in my code. But when the script is run, the server crashes. What could be wrong?
  9. If you look carefully at my code, you will see that SaveBigArray and lastBigArray have a string type.
  10. Hi! I found a bag of function setAccountData Let i have an array with a large number of keys (over 10 for example): BigArray = { Key1 = "Value 1", Key2 = "Value 2", Key3 = "Value 3", Key4 = {"A", "ABC", "124"}, Key5 = {{"C", "D", "1244"}, "F"}, Key6 = {"value 6"} ..... } And next I want to save that array on a player account if a player leaves the game: Note: I save that array only for registered players (not for guest) addEventHandler ("onPlayerQuit", getRootElement(), function(quitType, reason, responsibleElement) local playerAccount = getPlayerAccount(source) local BigArrayForSave = toJSON(BigArray) if (isGuestAccount(playerAccount) == false) then setAccountData(playerAccount, "SaveBigArray", BigArrayForSave) end playerAccount = nil end ) And when a player enters in a game I want to get that array from his account: addEventHandler("onPlayerLogin", getRootElement(), function(thePreviousAccount, theCurrentAccount, autoLogin) if (isGuestAccount(getPlayerAccount(source)) == false) then local lastBigArray = getAccountData(theCurrentAccount, "SaveBigArray") end end ) But now lastBigArray is shorter than the line length of BigArrayForSave: string.len(BigArrayForSave) > string.len(lastBigArray) Am I doing something wrong or is that a bug of MTA?
  11. In resource "Handling Editor" I saw this GUI element: How do I do that? I tried to create it using guiCreateWindow , but it's not working (Title has a central vertical align constantly)
  12. Thanks. If I understand you correctly, the commented part of the code responsible for the display of the player message in the chat.
  13. Here is the code: g_Root = getRootElement() g_ResRoot = getResourceRootElement(getThisResource()) g_PlayerData = {} g_VehicleData = {} local chatTime = {} local lastChatMessage = {} g_ArmedVehicles = { [425] = true, [447] = true, [520] = true, [430] = true, [464] = true, [432] = true } g_Trailers = { [606] = true, [607] = true, [610] = true, [590] = true, [569] = true, [611] = true, [584] = true, [608] = true, [435] = true, [450] = true, [591] = true } g_RPCFunctions = { addPedClothes = { option = 'clothes', descr = 'Modifying clothes' }, addVehicleUpgrade = { option = 'upgrades', descr = 'Adding/removing upgrades' }, fadeVehiclePassengersCamera = true, fixVehicle = { option = 'repair', descr = 'Repairing vehicles' }, giveMeVehicles = { option = 'createvehicle', descr = 'Creating vehicles' }, giveMeWeapon = { option = 'weapons.enabled', descr = 'Getting weapons' }, givePedJetPack = { option = 'jetpack', descr = 'Getting a jetpack' }, killPed = { option = 'kill', descr = 'Killing yourself' }, removePedClothes = { option = 'clothes', descr = 'Modifying clothes' }, removePedFromVehicle = true, removePedJetPack = { option = 'jetpack', descr = 'Removing a jetpack' }, removeVehicleUpgrade = { option = 'upgrades', descr = 'Adding/removing upgrades' }, setElementAlpha = { option = 'alpha', descr = 'Changing your alpha' }, setElementPosition = true, setElementInterior = true, setMyGameSpeed = { option = 'gamespeed.enabled', descr = 'Setting game speed' }, setMySkin = { option = 'setskin', descr = 'Setting skin' }, setPedAnimation = { option = 'anim', descr = 'Setting an animation' }, setPedFightingStyle = { option = 'setstyle', descr = 'Setting fighting style' }, setPedGravity = { option = 'gravity.enabled', descr = 'Setting gravity' }, setPedStat = { option = 'stats', descr = 'Changing stats' }, setTime = { option = 'time.set', descr = 'Changing time' }, setTimeFrozen = { option = 'time.freeze', descr = 'Freezing time' }, setVehicleColor = true, setVehicleHeadLightColor = true, setVehicleOverrideLights = { option = 'lights', descr = 'Forcing lights' }, setVehiclePaintjob = { option = 'paintjob', descr = 'Applying paintjobs' }, setVehicleRotation = true, setWeather = { option = 'weather', descr = 'Setting weather' }, spawnMe = true, warpMe = { option = 'warp', descr = 'Warping' } } g_OptionDefaults = { alpha = true, anim = true, clothes = true, createvehicle = true, gamespeed = { enabled = true, min = 0.0, max = 3 }, gravity = { enabled = true, min = 0, max = 0.1 }, jetpack = true, kill = true, lights = true, paintjob = true, repair = true, setskin = true, setstyle = true, spawnmaponstart = true, spawnmapondeath = true, stats = true, time = { set = true, freeze = true }, upgrades = true, warp = true, weapons = { enabled = true, vehiclesenabled = true, disallowed = {} }, weather = true, welcometextonstart = true, vehicles = { maxidletime = 60000, idleexplode = true, maxperplayer = 2, disallowed = {} } } function getOption(optionName) local option = get(optionName:gsub('%.', '/')) if option then if option == 'true' then option = true elseif option == 'false' then option = false end return option end option = g_OptionDefaults for i,part in ipairs(optionName:split('.')) do option = option[part] end return option end addEventHandler('onResourceStart', g_ResRoot, function() table.each(getElementsByType('player'), joinHandler) end ) function joinHandler(player) if not player then player = source end local r, g, b = math.random(50, 255), math.random(50, 255), math.random(50, 255) setPlayerNametagColor(player, r, g, b) g_PlayerData[player] = { vehicles = {} } g_PlayerData[player].blip = createBlipAttachedTo(player, 0, 2, r, g, b) if g_FrozenTime then clientCall(player, 'setTimeFrozen', true, g_FrozenTime[1], g_FrozenTime[2], g_FrozenWeather) end if getOption('welcometextonstart') then outputChatBox('Welcome to Freeroam', player, 0, 255, 0) outputChatBox('Press F1 to show/hide controls', player, 0, 255, 0) end end addEventHandler('onPlayerJoin', g_Root, joinHandler) addEvent('onLoadedAtClient', true) addEventHandler('onLoadedAtClient', g_ResRoot, function(player) if getOption('spawnmaponstart') and isPedDead(player) then clientCall(player, 'showWelcomeMap') end end, false ) addEventHandler('onPlayerWasted', g_Root, function() if not getOption('spawnmapondeath') then return end local player = source setTimer( function() if isPedDead(player) then clientCall(player, 'showMap') end end, 2000, 1 ) end ) addEvent('onClothesInit', true) addEventHandler('onClothesInit', g_Root, function() local result = {} local texture, model -- get all clothes result.allClothes = {} local typeGroup, index for type=0,17 do typeGroup = {'group', type = type, name = getClothesTypeName(type), children = {}} table.insert(result.allClothes, typeGroup) index = 0 texture, model = getClothesByTypeIndex(type, index) while texture do table.insert(typeGroup.children, {id = index, texture = texture, model = model}) index = index + 1 texture, model = getClothesByTypeIndex(type, index) end end -- get current player clothes { type = {texture=texture, model=model} } result.playerClothes = {} for type=0,17 do texture, model = getPedClothes(source, type) if texture then result.playerClothes[type] = {texture = texture, model = model} end end triggerClientEvent(source, 'onClientClothesInit', source, result) end ) addEvent('onPlayerGravInit', true) addEventHandler('onPlayerGravInit', g_Root, function() triggerClientEvent('onClientPlayerGravInit', source, getPedGravity(source)) end ) function setMySkin(skinid) if isPedDead(source) then local x, y, z = getElementPosition(source) if isPedTerminated(source) then x = 0 y = 0 z = 3 end local r = getPedRotation(source) local interior = getElementInterior(source) spawnPlayer(source, x, y, z, r, skinid) setElementInterior(source, interior) setCameraInterior(source, interior) else setElementModel(source, skinid) setElementHealth(source, 100) end setCameraTarget(source, source) setCameraInterior(source, getElementInterior(source)) end function spawnMe(x, y, z) if not x then x, y, z = getElementPosition(source) end if isPedTerminated(source) then repeat until spawnPlayer(source, x, y, z, 0, math.random(9, 288)) else spawnPlayer(source, x, y, z, 0, getPedSkin(source)) end setCameraTarget(source, source) setCameraInterior(source, getElementInterior(source)) end
  14. Solidsnake14 That is not good running scripts(When player write and send a message on server ther are 2 messages.)
  15. I want that when player writes message in a chat, that to next to his nickname was shown his ACL group(Admin, SuperModerator, Player, Guest..). And so over the player nickname in the game (not in chat), too, was shown to his group. What name does have the scripts that show nick over a player and in chat?
  16. Renkon, How to check that there was no response from the client?
  17. For example, I trigger client event in server by triggerClientEvent. In client that event cancels. How can I know on the server about that this event has been cancelled on the client?
  18. Can i remove element data in client sire or only server side?
  19. myonlake, i changed my code and now it has the next view: Server-side function setTrackInMP(source, command, trackNumber) local playerVehicle = getPedOccupiedVehicle(source); local MPMaxTracks = tonumber(get("MPMaxTracks")) --This setting is in meta.xml if ((playerVehicle ~= false) and (source == getVehicleOccupant(playerVehicle))) then if (trackNumber ~= '') then local TN = tonumber(trackNumber) if (TN >= 1 and TN < MPMaxTracks) then local pvX, pvY, pvZ = getElementPosition(playerVehicle) triggerClientEvent(getRootElement(), "MPChange", source, playerVehicle, TN, pvX, pvY, pvZ) playerVehicle, MPMaxTracks = nil else outputChatBox("Track number enters incorrect!", source, 255, 0, 0, true) end else outputChatBox("You didn't enter a track number!", source, 255, 0, 0, true) end else outputChatBox("You don't turn a music player if you are not drive the vehicle!", source, 255, 0, 0, true) end end addCommandHandler("sm", setTrackInMP) addEvent("MPErrorOutput", true) function MPErrorOutputHandler(functionName, ErrorCode) local logFilenName = get("MPLogFileName") local LogFile = io.open(logFilenName) if LogFile then LogFile:write("["..os.date("%Y-%m-%d %H:%M:%S").."] PLAYER: "..getPlayerName(source).." , Error in function '"..functionName.."' , ErrorCode: "..ErrorCode.."\n") LogFile:close() end logFilenName = nil restartResource(getThisResource()) end addEventHandler("MPErrorOutput", getRootElement(), MPErrorOutputHandler) Client-side addEvent("MPChange", true) function MPChangeHandler(playerVehicle, trackNumber, pvX, pvY, pvZ) local ErrorCode = 0 if (playerVehicle ~= false) then if(getElementData(playerVehicle, "MPTurnOn") == 1) then if (MPStopTrack(playerVehicle) ~= 0) then ErrorCode = 2 end else if not(setElementData (playerVehicle, "MPTurnOn", 1)) then ErrorCode = 3 end end if (ErrorCode == 0) then local Sound = playSound3D('music_tracks/'..trackNumber..'.mp3', pvX, pvY, pvZ, true) if (Sound ~= false) then if setElementData (Sound, "MPSoundElement", 1) then setSoundMaxDistance(Sound, 20) setSoundVolume(Sound, 0.5) if not(MPStartTrack(Sound, playerVehicle)) then destroyElement(Sound) ErrorCode = 6 triggerServerEvent("MPErrorOutput", "MPChangeHandler", source, ErrorCode) else outputChatBox("Track #"..trackNumber.." is now playing in a music player.", source, 0, 196, 58, true) end else ErrorCode = 5 triggerServerEvent("MPErrorOutput", "MPChangeHandler", source, ErrorCode) end else ErrorCode = 4 triggerServerEvent("MPErrorOutput", "MPChangeHandler", source, ErrorCode) end else triggerServerEvent("MPErrorOutput", "MPChangeHandler", source, ErrorCode) end else ErrorCode = 1 triggerServerEvent("MPErrorOutput", source, "MPChangeHandler", ErrorCode) end end function MPStartTrack(MPSoundElement, playerVehicle) local ErrorCode = 0 if setElementData (MPSoundElement, "MPSoundElement", 1) then setSoundMaxDistance(MPSoundElement, 20) setSoundVolume(MPSoundElement, 0.5) if setElementData (playerVehicle, "MPSoundElement", MPSoundElement) then ErrorCode = 2 else if not(attachElements(MPSoundElement, playerVehicle, 0, 0, 0)) then ErrorCode = 3 end end else ErrorCode = 1 end return ErrorCode end function MPStopTrack(playerVehicle) local ErrorCode = 0 local playerVehicleAttachedElements = getAttachedElements(playerVehicle) if not(playerVehicleAttachedElements) then ErrorCode = -1 else for pvaeKey, pvaeValue in ipairs (playerVehicleAttachedElements) do if (getElementData(pvaeValue, "MPSoundElement") == 1) then destroyElement(pvaeValue) break end end playerVehicleAttachedElements, pvaeKey, pvaeValue = nil if not(removeElementData(playerVehicle, "MPSoundElement")) then ErrorCode = -2 end end return ErrorCode end But it plays sound only in fixed coordinates again.What did I do wrong?
  20. Solidsnake, with attachElements it turns out the same.
  21. Solidsnake14, for example i show my code: In server side function ResourceStart() local playerVehicle = getPedOccupiedVehicle(source); triggerClientEvent(getRootElement(), "ClientEvent", source, playerVehicle) end In client side function ClientEventHandler(playerVehicle) local Sound = playSound3D('track.mp3', 1, 2, 3, true) StartMusic(Sound, playerVehicle) end function StartMusic(Sound, playerVehicle) attachElement(Sound, playerVehicle, ) end Sound creates, but it plays only in fixed coordinates (1,2,3). Is it mean that Sound not exist in StartMusic function?
  22. Hi. I have a some questions 1)For example I get the element(player, vehicle, Sound) in server side script and transfer in client function with triggerClientEvent. Can i change that element in client side(attachElement, setElementData, deleteElement, etc..)?? 2)For example I get the element (player, vehicle, Sound) in function1 on server or client side and transfer their in function1. Can i change that element in function1(attachElement, setElementData, deleteElement, etc..)??
×
×
  • Create New...