Jump to content

Linux_Shines

Members
  • Posts

    35
  • Joined

  • Last visited

Everything posted by Linux_Shines

  1. Hello. So, I'm using [this script right here]. I've edited it just a little bit to actually show the vehicle's RPM and amount of gears, yet I'd like to make one more change and... I'm stuck a little, because I've no idea what kind of "if condition" should I use. Below is an example of a single condition where I'm comparing the amount of gears to the maximum amount of gears and if it's the same, then the dxDrawText color changes from black to red, works. if RESKINNED_DEBUG and vehicle == myVehicle then if(tostring(data.gear) == tostring(#gearRatios)) then -- maximum amount of gears dxDrawText(tostring(#gearRatios), (screenW * 0.8562) - 1, (screenH * 0.8148) - 1, (screenW * 0.9031) - 1, (screenH * 0.8380) - 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText(tostring(#gearRatios), (screenW * 0.8562) + 1, (screenH * 0.8148) - 1, (screenW * 0.9031) + 1, (screenH * 0.8380) - 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText(tostring(#gearRatios), (screenW * 0.8562) - 1, (screenH * 0.8148) + 1, (screenW * 0.9031) - 1, (screenH * 0.8380) + 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText(tostring(#gearRatios), (screenW * 0.8562) + 1, (screenH * 0.8148) + 1, (screenW * 0.9031) + 1, (screenH * 0.8380) + 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) -- gears dxDrawText(tostring(data.gear), screenW * 0.8562, screenH * 0.8148, screenW * 0.9031, screenH * 0.8380, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) else dxDrawText(tostring(data.gear), (screenW * 0.8562) - 1, (screenH * 0.8148) - 1, (screenW * 0.9031) - 1, (screenH * 0.8380) - 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText(tostring(data.gear), (screenW * 0.8562) + 1, (screenH * 0.8148) - 1, (screenW * 0.9031) + 1, (screenH * 0.8380) - 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText(tostring(data.gear), (screenW * 0.8562) - 1, (screenH * 0.8148) + 1, (screenW * 0.9031) - 1, (screenH * 0.8380) + 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText(tostring(data.gear), (screenW * 0.8562) + 1, (screenH * 0.8148) + 1, (screenW * 0.9031) + 1, (screenH * 0.8380) + 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText(tostring(data.gear), screenW * 0.8562, screenH * 0.8148, screenW * 0.9031, screenH * 0.8380, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) end end And here's the code I'm using to show the vehicle's RPM: dxDrawText(string.format("%4d", tostring(rpm)), (screenW * 0.8562) - 1, (screenH * 0.6759) - 1, (screenW * 0.9031) - 1, (screenH * 0.6991) - 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText(string.format("%4d", tostring(rpm)), (screenW * 0.8562) + 1, (screenH * 0.6759) - 1, (screenW * 0.9031) + 1, (screenH * 0.6991) - 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText(string.format("%4d", tostring(rpm)), (screenW * 0.8562) - 1, (screenH * 0.6759) + 1, (screenW * 0.9031) - 1, (screenH * 0.6991) + 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText(string.format("%4d", tostring(rpm)), (screenW * 0.8562) + 1, (screenH * 0.6759) + 1, (screenW * 0.9031) + 1, (screenH * 0.6991) + 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText(string.format("%4d", tostring(rpm)), screenW * 0.8562, screenH * 0.6759, screenW * 0.9031, screenH * 0.6991, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) It was literally added after the condition I pasted above. Unfortunately the further, the worse. I've been trying to make completely random conditions such like if(string.format("%4d", tostring(rpm)) < string.format("%4d", tostring(rpm))-500) then dxDrawText(string.format("%4d", tostring(rpm)), (screenW * 0.8562) - 1, (screenH * 0.6759) - 1, (screenW * 0.9031) - 1, (screenH * 0.6991) - 1, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) ... else dxDrawText(string.format("%4d", tostring(rpm)), (screenW * 0.8562) - 1, (screenH * 0.6759) - 1, (screenW * 0.9031) - 1, (screenH * 0.6991) - 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false) ... end but... nah, they don't seem to work. What should I do and... is it even possible to compare one string to another and just check whether the value of this string is less than, for example 500, or not?
  2. Hello. I want to change speedometer colour by speed (for testing), but... I don't know, how to do this. I did it in the following way (I have this lines in function UpdateDisplay()): speedx, speedy, speedz = getElementVelocity(localPlayer) g_GuiLabel.Speed:color(255 - math.ceil(speedx * speedy), math.ceil(speedx * speedy), 255) But... from what I see, displayed color is ... pink. How can I dynamically change colour, from white (or something else, like green) to red, when white (or green) is 0 km/h and red is more than 200 km/h? @edit: Oh, I just solved this, but I want to share my code with other peoples, who will also have this problem function UpdateDisplay() if not getPedOccupiedVehicle(localPlayer) then hideSpeedometer() end g_GuiLabel.Speed:postGUI(true) g_GuiLabel.Speed:text(tostring(GetVehicleSpeed())) local x, y, z = getElementVelocity(getPedOccupiedVehicle(localPlayer)) local speed = math.floor(math.sqrt(x ^ 2 + y ^ 2 + z ^ 2) * kph_multiplayer) if speed < 254 then g_GuiLabel.Speed:color(255, 255 - speed, 255 - speed) else g_GuiLabel.Speed:color(255, 0, 0) end end
  3. Holy fu... I mean - oh man... I mean... oh, nevermind. It's just awesome. In any case - did I good think that the "PlaySFX" function will now be able to play the sounds of vehicles? Because I read on the wiki about this feature and it;s not written there anything that has to do with the vehicles...
  4. Did you plan to publish this? Or is it possible to get it from you somehow?
  5. Hi. Today I discovered an unusual issue/bug(?) - while browsing users list, I saw such a thing: I just click on Members, and after loading the page I clicked again on random letter. Link for url, which show that message: memberlist.php&first_char=a#memberlist
  6. Hi, I have an little, short, question, like in title of thread - is it possible to ADD completely new cars to the game? And please - don't write to me 'bout replacing of a car - I know how to do. AFAIK, it's possible to do this in a... "clean" GTA SA, so I think that maybe it is possible in MTA SA too?
  7. I know, that I can use Audacity and I'm using it ( ), but I don't know rate of sound and even if I change it to 44100 Hertz (like in your sounds), I've same issue like I wrote before.
  8. It's sad that you don't want to release source... But I've found new source of sounds - NFS High Stakes™© (and other Trademarks). With NFS Wizard I'm extracted all sounds from files CARENG.BNK, OCARENG.BNK and SCARENG.BNK. Actually I'm testing the sounds of cars at home and... they sound strange, because at maximum RPM the sound is "unreliable" (or rather "break"), but still very good. If you want, I can upload all the extracted sounds, maybe you'll know how to fix these sounds, because with your script, they may be really very, very good. (I love to repeat the words)
  9. Topo1st, when you update the resource to new version? And... are you plan to release a source code?
  10. Hm... I'm think that I've found something weird... or maybe it must be, I dunno. But I'm think it's something like issue - every car have 11000 RPM. Maybe (I'm only suggest) you can do, that every car have other RPM in XML file?
  11. Very good and nice script, but it's possible to made other version (second?), with automatic transmission?
  12. Wychodzi na to, że jednak powinienem jeszcze raz przejrzeć dokładniej wiki. I to dużo dokładniej. Tylko że San Andreas mi się ciągle psoci, jeżeli chodzi o te biegi... W każdym razie póki co to mam takie coś (głównie zmiana handlingu, nie zajmuję się jeszcze modulacją): -- Modyfikowanie prowadzenia się Infernusa: function InfernusTuning() infernus = 411 for _, veh in pairs(getElementsByType("vehicle")) do if getElementModel(veh) == infernus then setVehicleHandling(veh, "mass", 1000) setVehicleHandling(veh, "turnMass", 2000) setVehicleHandling(veh, "dragCoeff", 4) setVehicleHandling(veh, "centerOfMass", { 0, -0.1, -0.1 } ) setVehicleHandling(veh, "percentSubmerged", 80) setVehicleHandling(veh, "tractionMultiplier", 0.95) setVehicleHandling(veh, "tractionLoss", 0.9) setVehicleHandling(veh, "tractionBias", 0.42) setVehicleHandling(veh, "numberOfGears", 1)-- do testu, było 5) setVehicleHandling(veh, "maxVelocity", 420) setVehicleHandling(veh, "engineAcceleration", 22) setVehicleHandling(veh, "engineInertia", -0.1) setVehicleHandling(veh, "driveType", "awd") setVehicleHandling(veh, "engineType", "petrol") setVehicleHandling(veh, "brakeDeceleration", 6) setVehicleHandling(veh, "brakeBias", 0.5) setVehicleHandling(veh, "ABS", false) setVehicleHandling(veh, "steeringLock", 30) setVehicleHandling(veh, "suspensionForceLevel", 0.95) setVehicleHandling(veh, "suspensionDamping", 0.25) setVehicleHandling(veh, "suspensionHighSpeedDamping", 1.25) setVehicleHandling(veh, "suspensionUpperLimit", 0.2) setVehicleHandling(veh, "suspensionLowerLimit", -0.1) setVehicleHandling(veh, "suspensionFrontRearBias", 0.45) setVehicleHandling(veh, "suspensionAntiDiveMultiplier", 1) setVehicleHandling(veh, "seatOffsetDistance", 0.38) setVehicleHandling(veh, "collisionDamageMultiplier", 0.5) setVehicleHandling(veh, "monetary", 2000000) setVehicleHandling(veh, "modelFlags", 0x0) setVehicleHandling(veh, "handlingFlags", 0x1708803) setVehicleHandling(veh, "headLight", 1) setVehicleHandling(veh, "tailLight", 1) setVehicleHandling(veh, "animGroup", 1) end end end addEventHandler("onPlayerVehicleEnter", getRootElement(), InfernusTuning) Szkoda, że funkcje wymienione przez Ciebie nie są jakoś dokładniej opisane (w przykładach jest tylko "-- TODO"), bo gdy próbuję ich używać, interpreter w trakcie gry wypluwa a gdy używam kodu powyżej isetVehicleHandling(veh, "numberOfGears", 1) to auto ciągle przyspiesza do maksymalnej prędkości, tylko że zmienia jeden raz bieg i po prostu rozpędza się do tych 420 km/h...
  13. Co do pobierania biegów - zauważyłem, że MTA stara się poprawnie interpretować biegi, wskutek czego nawet przy zmodyfikowanym handlingu wyświetla prawie dobrze odpowiednie biegi. A propos handlingu - w jaki sposób można zmieniać biegi? Bo w hedit nie widzę opcji zmiany długości jakiegoś biegu, tylko ogólna prędkość, etc. A co do edita - czy mógłbym Cię poprosić o jakiś pseudokod, ewentualnie przerobienie w odpowiedni sposób na pseudokod tego, co umieściłem w pierwszym poście? Bo właśnie ciężko mi ogarnąć przyklejanie dźwięków z tego powodu, że się na siebie nakładają (pewnie wina onClientRender).
  14. Ta funkcja działa... ale dosyć dziwnie i nie sprawdza dźwięku, jaki jest odtwarzany podczas jazdy, tylko losowo wyświetla zmianę biegów... Lecz - czy można byłoby zrobić takie coś, że dźwięki auta są modulowane, ewentualnie odtwarzane jeden po drugim? Już pal licho z biegami.
  15. Heloł, ledwo zamknąłem poprzedni temat, a już tworzę kolejny. No ale... Mniejsza z tym... W każdym razie - czy jest możliwe pobranie długości dźwięku pojazdu i stworzenie na podstawie tej długości dźwięku obrotomierza? Dokładniej - chodzi mi o to, że w San Andreas odgłosów auta jest zaledwie 5, a mi chodzi o pobranie tych: Następnie pobrane dźwięki chciałbym w jakiś "magiczny sposób" przypisać do prędkościomierza, dzięki czemu uzyskałbym ilość obrotów silnika dla każdego auta. Tak więc - czy jest to w ogóle możliwe? @edit: Z tego co widzę, to jest to jak najbardziej możliwe, tylko teraz jak to oskryptować? @edit 2: Udało mi się zrobić takie coś, niestety - dźwięki nakładają się do siebie: -- Hotring: engineImportTXD(engineLoadTXD("hotring.txd"), 494) engineReplaceModel(engineLoadDFF("hotring.dff", 494), 494) -- Infernus: engineImportTXD(engineLoadTXD("infernus.txd"), 411) engineReplaceModel(engineLoadDFF("infernus.dff", 411), 411) -- Infernus - podmiana dźwięku: local FilePath = "Bank_001/sound_002.wav" local FilePath_2 = "Bank_002/sound_001.wav" local FilePath_3 = "Bank_002/sound_002.wav" function getElementSpeed(element, unit) if(unit == nil) then unit = 0 end if(isElement(element)) then local x, y, z = getElementVelocity(element) if(unit=="kph" or unit == 1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 100 end else outputDebugString("Nie mogę pobrać prędkości pojazdu.") return false end end addEventHandler("onClientRender", root, function(keyState) local vehicle = getPedOccupiedVehicle(localPlayer) if(vehicle) then if(keyState == "down") then local sound = playSound("Bank_002/sound_003.wav", false) setSoundVolume(sound, 0.05) setSoundMaxDistance(sound, 40) end if getElementSpeed(vehicle, "kmh") == 0 then StartNeutralEngineSound() elseif getElementSpeed(vehicle, "kmh") > 0 or getElementSpeed(vehicle, "kmh") < 400 then StartDriveSound() elseif getElementSpeed(vehicle, "kmh") > 0 then StartMaximumSound() else DestroySound() end end end) function StartNeutralEngineSound() -- if isElement(sound) then return false end sound = playSound(FilePath, false) setSoundVolume(sound, 0.05) setSoundMaxDistance(sound, 40) end function StartDriveSound() -- if isElement(sound2) then return false end if isElement(FilePath_2) then destroyElement(FilePath) end sound2 = playSound(FilePath_2, false) setSoundVolume(sound2, 0.05) setSoundMaxDistance(sound2, 40) end function StartMaximumSound() -- if isElement(sound3) then return false end if isElement(FilePath_3) then destroyElement(FilePath_2) end sound3 = playSound(FilePath_3, false) setSoundVolume(sound3, 0.05) setSoundMaxDistance(sound3, 40) end function DestroySound() if isElement(FilePath_3) or isElement(sound3) then destroyElement(FilePath_3) destroyElement(sound3) end end
  16. Czy mógłbym poprosić o zamknięcie tego tematu, bo zacząłem korzystać z wbudowanego systemu plików MTA, które są proste i działają pewnie?
  17. No to zrobiłem tak jak twierdzisz, że powinno być i... dalej mam ten sam błąd ("Ta nazwa użytkownika jest już zajęta"). Podam kod, bo może robię coś źle, ale staram się zrobić wszystko tak, jak mi piszesz: function registerHandler(player, username, password) local sQuery = "SELECT COUNT(*) AS cnt FROM `" ..tablename.. "` WHERE `" ..nick.. "` = '"..mysql_escape_string(handler, user).."' LIMIT 1"; -- LIMIT spowoduje, ze zapytanie bedzie delikatnie szybsze w przypadku kiedy znajdziemy odpowiednik (nie trzeba bedzie przeszukiwac reszty wierszow). NIE SPRAWDZAJ TU PODANEGO HASLA! bo jak bedzie bledne, to skrypt uzna ze user nie istnieje i doda drugiego o tym samym loginie local oResult = mysql_query(handler, sQuery); if(oResult) then local row = mysql_fetch_assoc(oResult) if(row['cnt'] == 0) then mysql_query(handler, "INSERT INTO " ..tablename.. " (`" ..nick.. "`, `" ..pass.. "`) VALUES ('" ..username.. "', '" ..sha256(password).. "')") outputDebugString(handler) triggerClientEvent(player, "hideLoginWindow", getRootElement()) outputChatBox("Pomyślnie logujesz się na swoje konto.", player, 255, 255, 255) outputChatBox("Jeżeli chcesz zmienić swoje hasło, użyj /changepw", player) mysql_free_result(handler) else outputDebugString("Ta nazwa użytkownika jest już zajęta. Rezultat: ") outputDebugString(oResult) triggerClientEvent(player, "registerTaken", getRootElement()) end else outputDebugString("Nieznany błąd. Rezultat: ") outputDebugString(oResult) triggerClientEvent(player, "unknownError", getRootElement()) end end Zapomniałbym - serwer drukuje różne wyniki rezultatów przy próbie zarejestrowania i zalogowania: [09:58:19] INFO: Ta nazwa użytkownika jest już zajęta. Rezultat: [09:58:19] INFO: MySQL result (#18) [09:58:34] INFO: Ta nazwa użytkownika jest już zajęta. Rezultat: [09:58:34] INFO: MySQL result (#20) [09:58:34] INFO: Ta nazwa użytkownika jest już zajęta. Rezultat: [09:58:34] INFO: MySQL result (#21) [09:58:35] INFO: Ta nazwa użytkownika jest już zajęta. Rezultat: [09:58:35] INFO: MySQL result (#25) [09:58:35] INFO: Ta nazwa użytkownika jest już zajęta. Rezultat: [09:58:35] INFO: MySQL result (#26) Dodam też, że po kilku minutach (zazwyczaj 5) widzę napis "connection trouble", serwer się zawiesza i dopiero gdy wyjdę z serwera drukuje takie coś: [10:04:56] INFO: Nieznany błąd. Rezultat: [10:04:56] INFO: nil [10:04:56] INFO: Nieznany błąd. Rezultat: [10:04:56] INFO: nil [10:04:56] QUIT: Shiny left the game [Quit]
  18. Nie wiem jakim cudem działała, ale już jest okej - przestała. Co do "skad tez u Ciebie ta mania robienia falszywego warunku jako pierwszego?" - tak jakoś, zawsze zaczynam od negacji, potem sprawdzam resztę. Ale, ale, teraz mam błąd, że "Ta nazwa użytkownika jest już zajęta". Nie wiem, co jest grane, bo to jest porąbane - mówiąc szczerze. W bazie nie jestem zarejestrowany, dodatkowo podstawiłem kod wedle zaleceń z Twojego "pseudo-pseudokodu" (przy okazji, musiałem zamienić "local oResult = mysql_query(sQuery);" na "local oResult = mysql_query(handler, sQuery);", bo inaczej w konsoli miałem błąd "ERROR: script.lua:59: bad argument #1 to 'mysql_query' (mysqlHandler expected, got string)") - dalej nic, no może poza zamieszczaniem w konsoli i niczego innego więcej. Poniżej sprawca zamieszania, zrobiony wedle zaleceń: function registerHandler(player, username, password) local sQuery = "SELECT * FROM `" ..tablename.. "` WHERE `" ..nick.. "` = '"..mysql_escape_string(handler, user).."' LIMIT 1"; -- LIMIT spowoduje, ze zapytanie bedzie delikatnie szybsze w przypadku kiedy znajdziemy odpowiednik (nie trzeba bedzie przeszukiwac reszty wierszow). NIE SPRAWDZAJ TU PODANEGO HASLA! bo jak bedzie bledne, to skrypt uzna ze user nie istnieje i doda drugiego o tym samym loginie outputDebugString(sQuery) local oResult = mysql_query(handler, sQuery); if(oResult) then -- skad tez u Ciebie ta mania robienia falszywego warunku jako pierwszego? -- zapytanie powiodlo sie, praktycznie nie ma szans zeby nie mialo (samo zapytanie musialoby miec blad skladniowy, albo brak zabezpieczenia przed sql injection) if(not mysql_num_rows(oResult)) then -- jezeli 0/false/nil (w naszym przypadku zero) -- rejestrujemy nowe konto mysql_query(handler, "INSERT INTO " ..tablename.. " (`" ..nick.. "`, `" ..pass.. "`) VALUES ('" ..username.. "', '" ..sha256(password).. "')") outputDebugString(handler) -- to się nie wykonuje, bo w konsoli brak czegokolwiek triggerClientEvent(player, "hideLoginWindow", getRootElement()) outputChatBox("Pomyślnie logujesz się na swoje konto.", player, 255, 255, 255) outputChatBox("Jeżeli chcesz zmienić swoje hasło, użyj /changepw", player) mysql_free_result(oResult) else -- wywalamy blad, ze konto istnieje triggerClientEvent(player, "registerTaken", getRootElement()) end else -- wywolanie "nieznanego bledu" triggerClientEvent (player, "unknownError", getRootElement()) end end
  19. No okej, zrobiłem tak jak piszesz (tak mi się wydaje, bo zrozumiałem tylko część z tego co napisałeś, gdyż jestem jeszcze początkujący i miałem dość długą przerwę w LUA, którego wcześniej też się uczyłem) i rejestracja już działa poprawnie. Niestety - tylko rejestracja. Zalogować się dalej nie mogę, bo mam komunikat, że "wystąpił nieznany błąd". Aktualnie rejestracja wygląda tak: function registerHandler(player, username, password) local register = mysql_query(handler, "SELECT 1 FROM " ..tablename.. " WHERE " ..nick.. " = '"..mysql_escape_string(handler, user).."' AND " ..pass.. " = '"..mysql_escape_string(handler, sha256(pass)).."';") if(not register) then triggerClientEvent(player, "registerTaken", getRootElement()) else if mysql_num_rows(register) == 0 then mysql_query(handler, "INSERT INTO " ..tablename.. " (`" ..nick.. "`, `" ..pass.. "`) VALUES ('" ..username.. "', '" ..sha256(password).. "')") triggerClientEvent(player, "hideLoginWindow", getRootElement()) outputChatBox("Pomyślnie logujesz się na swoje konto.", player, 255, 255, 255) outputChatBox("Jeżeli chcesz zmienić swoje hasło, użyj /changepw", player) mysql_free_result(register) else triggerClientEvent (player, "unknownError", getRootElement()) end end end a logowanie tak: function loginHandler(player, username, password) local login = mysql_query(handler,"SELECT 1 FROM " ..tablename.. " WHERE " ..nick.. " = '"..mysql_escape_string(handler, user).."' AND " ..pass.. " = '"..mysql_escape_string(handler, sha256(pass)).."';") if(not login) then triggerClientEvent (player, "loginWrong", getRootElement()) else if mysql_num_rows(login) == 1 then triggerClientEvent(player, "hideLoginWindow", getRootElement()) outputChatBox("Pomyślnie logujesz się na swoje konto.", player, 255, 255, 255) outputChatBox("Jeżeli chcesz zmienić swoje hasło, użyj /changepw", player) spawnPlayer(player, 0,0,3) fadeCamera(player, true) setCameraTarget(player, player) mysql_free_result(login) else triggerClientEvent (player, "unknownError", getRootElement()) end end end
  20. Heloł. Przepraszam za spam i za to, że piszę problem również w polskim dziale, lecz pisząc w ogólnym nie otrzymałem odpowiedzi, a potrzebuję załatwić sprawę szybko, zwłaszcza, że niżej napisany kod jest całym moim "skryptem". No i tak - nie znam się aż nadto na MySQL i LUA, ale ciągle próbuję opanować te języki. Dlatego też zdecydowałem się stworzyć prosty panel logowania na mój serwer. Niefortunnie - gdy skrypt zostaje załadowany a baza stworzona, nie mogę się zarejestrować (pokazuje się "Wystąpił nieznany błąd."). Dodam też, że po wpisaniu /debugscript 3 nie widzę nic złego. No i wpis w acl.xml też popełniłem. -- Strona serwera: local host = 'localhost' local user = 'Shiny' local password = 'test123' local db = 'baza' local tablename = 'konta' local nick = 'Pseudonim' local pass = 'Haslo' handler = mysql_connect(host, user, password, db) function CreateTableInDatabase(res) local create_database = mysql_query(handler, "CREATE TABLE IF NOT EXISTS `" ..tablename.. "` (`" ..nick.. "` varchar(255) DEFAULT NULL, `" ..pass.. "` varchar(255) DEFAULT NULL) ENGINE = MyISAM DEFAULT CHARSET = utf8;") outputDebugString("CREATE TABLE IF NOT EXISTS `" ..tablename.. "` (`" ..nick.. "` varchar(255) DEFAULT NULL, `" ..pass.. "` varchar(255) DEFAULT NULL) ENGINE = MyISAM DEFAULT CHARSET = utf8;") outputDebugString("Połączenie z bazą MySQL zostało pomyślnie zainicjowane."); end addEventHandler("onResourceStart", getRootElement(), CreateTableInDatabase) function passwordHandler(player, oldpassword, newpassword) local account = getPlayerAccount(player) if (account) then if (isGuestAccount(account)) then outputChatBox("Musisz się zalogować, aby zmienić hasło.", player) return end local playerName = getPlayerName(player) local password_check = getAccount(playerName, oldpassword) if (password_check ~= false) then if (string.len(newpassword) >= 3) then setAccountPassword(account, newpassword) triggerClientEvent(player, "hidePasswordWindow", getRootElement()) else outputChatBox("Twoje nowe hasło musi mieć długość co najmniej " ..string.len(newpassword).. " znaków!", player) end else outputChatBox("Stare hasło podane przez Ciebie jest nieprawidłowe.", player) end end end function loginHandler(player, username, password) local login = mysql_query(handler,"SELECT * FROM " ..tablename.. " WHERE " ..nick.. " = '"..mysql_escape_string(handler, user).."' AND " ..pass.. " = '"..mysql_escape_string(handler, sha256(pass)).."';") if(login ~= false) then local rows = mysql_num_rows(login) if rows == 1 then triggerClientEvent(player, "hideLoginWindow", getRootElement()) outputChatBox("Pomyślnie logujesz się na swoje konto.", player, 255, 255, 255) outputChatBox("Jeżeli chcesz zmienić swoje hasło, użyj /changepw", player) spawnPlayer(player, 0,0,3) fadeCamera(player, true) setCameraTarget(player, player) mysql_free_result(login) else triggerClientEvent (player, "unknownError", getRootElement()) end else triggerClientEvent (player, "loginWrong", getRootElement()) end end -- I think that this function isn't working, but... I've message at client trigger about "nickname was taken". function registerHandler(player, username, password) local login = mysql_query(handler,"SELECT * FROM " ..tablename.. " WHERE " ..nick.. " = '"..mysql_escape_string(handler, user).."' AND " ..pass.. " = '"..mysql_escape_string(handler, sha256(pass)).."';") if(login ~= false) then triggerClientEvent(player, "registerTaken", getRootElement()) else local rows = mysql_num_rows(login) if rows == 0 then mysql_query(handler, "INSERT INTO " ..tablename.. " (`" ..nick.. "`, `" ..pass.. "`) VALUES ('" ..username.. "', '" ..sha256(password).. "')") triggerClientEvent(player, "hideLoginWindow", getRootElement()) outputChatBox("Pomyślnie logujesz się na swoje konto.", player, 255, 255, 255) outputChatBox("Jeżeli chcesz zmienić swoje hasło, użyj /changepw", player) mysql_free_result(login) else triggerClientEvent (player, "unknownError", getRootElement()) end end end addEvent("submitChangepw", true) addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitChangepw", root, passwordHandler) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, registerHandler) -- Strona klienta: local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function createPasswordWindow() windowChangepw = guiCreateWindow(0.3859,0.349,0.2219,0.1628,"Zmień hasło",true) guiSetSize(windowChangepw, 165, 21) guiSetAlpha(windowChangepw,0.80000001192093) editOldpw = guiCreateEdit(110,29,165,21,"",false,windowChangepw) guiSetAlpha(editOldpw,1) guiEditSetMasked(editOldpw,true) labelOldpw = guiCreateLabel(10,29,90,21,"Stare hasło:",false,windowChangepw) guiSetAlpha(labelOldpw,1) guiLabelSetColor(labelOldpw,255,255,255) guiLabelSetVerticalAlign(labelOldpw,"center") guiLabelSetHorizontalAlign(labelOldpw,"left",false) editNewpw = guiCreateEdit(110,60,165,21,"",false,windowChangepw) guiSetAlpha(editNewpw,1) guiEditSetMasked(editNewpw,true) guiEditSetMaxLength(editNewpw,50) labelNewpw = guiCreateLabel(10,60,90,21,"Nowe hasło:",false,windowChangepw) guiSetAlpha(labelNewpw,1) guiLabelSetColor(labelNewpw,255,255,255) guiLabelSetVerticalAlign(labelNewpw,"center") guiLabelSetHorizontalAlign(labelNewpw,"left",false) buttonChangepw = guiCreateButton(10,91,265,23,"Zmień hasło",false,windowChangepw) guiSetAlpha(buttonChangepw,1) guiSetVisible(windowChangepw, false) addEventHandler("onClientGUIClick", buttonChangepw, clientSubmitChangepw, false) end function createLoginWindow() windowLogin = guiCreateWindow(0.3945,0.3646,0.2109,0.2018,"PSD",true) guiSetSize(windowLogin, 270, 155, false) guiSetAlpha(windowLogin,1) labelUsername = guiCreateLabel(10,52,59,24,"Pseudonim:",false,windowLogin) guiSetAlpha(labelUsername,1) guiLabelSetColor(labelUsername,255,255,255) guiLabelSetVerticalAlign(labelUsername,"center") guiLabelSetHorizontalAlign(labelUsername,"left",false) labelPassword = guiCreateLabel(10,86,59,24,"Hasło:",false,windowLogin) guiSetAlpha(labelPassword,1) guiLabelSetColor(labelPassword,255,255,255) guiLabelSetVerticalAlign(labelPassword,"center") guiLabelSetHorizontalAlign(labelPassword,"left",false) labelInfo = guiCreateLabel(10,26,250,17,"Proszę się zalogować, bądź zarejestrować.",false,windowLogin) guiSetAlpha(labelInfo,1) guiLabelSetColor(labelInfo,255,255,255) guiLabelSetVerticalAlign(labelInfo,"top") guiLabelSetHorizontalAlign(labelInfo,"center",false) guiSetFont(labelInfo,"default-bold-small") editUsername = guiCreateEdit(79,52,181,25,playerName,false,windowLogin) guiSetAlpha(editUsername,1) guiEditSetMaxLength(editUsername, 50) editPassword = guiCreateEdit(79,86,181,25,"",false,windowLogin) guiSetAlpha(editPassword,1) guiEditSetMasked(editPassword, true) guiEditSetMaxLength(editPassword, 50) buttonLogin = guiCreateButton(10,121,120,21,"Zaloguj się",false,windowLogin) guiSetAlpha(buttonLogin,1) buttonRegister = guiCreateButton(143,121,117,21,"Zarejestruj się",false,windowLogin) guiSetAlpha(buttonRegister,1) guiSetVisible(windowLogin, false) addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false) addEventHandler("onClientGUIClick", buttonRegister, clientSubmitRegister, false) end function resourceStart() createLoginWindow() if (windowLogin ~= nil) then guiSetVisible(windowLogin, true) else outputChatBox("Wystąpił nieznany błąd.") end showCursor(true) guiSetInputEnabled(true) end function changePw() createPasswordWindow() guiSetVisible(windowChangepw, true) showCursor(true) guiSetInputEnabled(true) end function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(editUsername) local password = guiGetText(editPassword) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Wpisz nazwę użytkownika i hasło.") end end end function clientSubmitRegister(button, state) if button == "left" and state == "up" then local username = guiGetText(editUsername) local password = guiGetText(editPassword) if username and password then triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Wpisz nazwę użytkownika i hasło.") end end end function clientSubmitChangepw(button, state) if button == "left" and state == "up" then local oldpassword = guiGetText(editOldpw) local newpassword = guiGetText(editNewpw) if oldpassword and newpassword then triggerServerEvent("submitChangepw", getRootElement(), localPlayer, oldpassword, newpassword) else outputChatBox("Wpisz stare i nowe hasło.") end end end function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(windowLogin, false) showCursor(false) end function hidePasswordWindow() guiSetInputEnabled(false) guiSetVisible(windowChangepw, false) showCursor(false) end function unknownError() guiSetText(labelInfo, "Wystąpił nieznany błąd.") end function loginWrong() guiSetText(labelInfo, "Błędna nazwa użytkownika bądź hasło.") end function registerTaken() guiSetText(labelInfo, "Ta nazwa użytkownika jest już zajęta.") end addEvent("hidePasswordWindow", true) addEvent("hideLoginWindow", true) addEvent("unknownError", true) addEvent("loginWrong", true) addEvent("registerTaken", true) addEventHandler("hidePasswordWindow", getRootElement(), hidePasswordWindow) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) addEventHandler("unknownError", getRootElement(), unknownError) addEventHandler("loginWrong", getRootElement(), loginWrong) addEventHandler("registerTaken", getRootElement(), registerTaken) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), resourceStart) addCommandHandler("changepw", changePw) Mógłbym prosić o pomoc?
  21. I'm very sorry for long not respond, but in any never version MTA (I thinking about RC) this issue does not repeat, only with 4887. But I thank you very much for your interest and support.
  22. Hello. Today, when I turned on the MTA, showed up information saying that is the next version of "nightly" version available for download. After confirming the request to update, the MTA switch off, then try run again and since then shows me this message. Best of all, I check this thread, do it all from it, and the problem still exists: Link for MTADiag: http://pastebin.com/JHWeexUU What I must install to play?
  23. Hello again, today I've wrinkle - how to "install" or rather "script"/"put" shader from other game (example below is from Tom Clancy's H.A.W.x® and alot of shaders) and put there in script? Example 2 shaders from Tom Clancy's H.A.W.x®, whose manipulate an sky: -- This is pixel shader: // Author: amo float4 HDRScale : register(c14); // x = rgb multiplyer, y = 1/x; z = luminance multiplyer, w = 1/z float4 HDRParam : register(c15); // r = SpecMul, g = rgb multiplyer, b = 1/g static const float3 LUMINANCE = float3(0.3086f, 0.6094f, 0.082f); float ComputeLUM(float3 color) { return dot(color, LUMINANCE); } float ComputeBRIGHT(float3 color) { return max(color.r, max(color.g, color.b)); } float3 EncodeRGB10(float3 color) { //return saturate(color * 0.25f); return saturate(color * HDRScale.y); } float3 DecodeRGB10(float3 color) { //return color * 4.0f; return color * HDRScale.x; } float EncodeL10(float lum) { //return saturate(lum * 0.25f); return saturate(lum * HDRScale.w); } float DecodeL10(float lum) { //return lum * 4.0f; return lum * HDRScale.z; } //float4 SunDir : register(c0); //float4 SunColor : register(c1); //float4 ParamsAngle : register(c2); //float4 FogColor : register(c3); sampler2D skyTex : register(s0); struct v2f { float4 Position : POSITION; float2 texCrd : TEXCOORD0; }; float4 main(v2f IN) : COLOR0 { float4 Out = tex2D(skyTex, IN.texCrd); /* float3 norm = normalize(IN.Pos); float d = dot(norm, SunDir.xyz); d = saturate((d-ParamsAngle.x)*ParamsAngle.y); d = d*d; Out.rgb += SunColor.rgb*d*SunColor.w; */ Out.rgb = EncodeRGB10(Out.rgb); return Out; } /* float4 Out = float4(0, 0, 0, 1); float3 GeneralColor = float3(0.45f, 0.55f, 1); float3 DarkestColor = float3(0.20f, 0.30f, 0.9); float3 HorizontalColor = float3(0.8f, 0.77f, 1); float3 SunColor = float3(0.6f, 0.6f, 0.45f); float3 norm = normalize(IN.Pos); float dotNS = dot(norm, SunDir.xyz); float d = saturate((dotNS-ParamsAngle.x)*ParamsAngle.y); d = d*d; Out.rgb = GeneralColor; Out.rgb = lerp(Out.rgb, SunColor, d); float darkFactor = 1 - abs((dotNS)); Out.rgb = lerp(Out.rgb, DarkestColor, sqrt(darkFactor)); float Height = norm.y + FogColor.w/ParamsAngle.w; float HorHeightStart = 1.0f; float HorHeightEnd = 0.0f; float horizFactor = saturate((Height - HorHeightStart)/(HorHeightEnd - HorHeightStart)); Out.rgb = lerp(Out.rgb, HorizontalColor, horizFactor); float FogHeightStart = 0.1f; float FogHeightEnd = 0.0f; float FogFactor = saturate((Height - FogHeightStart)/(FogHeightEnd - FogHeightStart)); Out.rgb = lerp(Out.rgb, FogColor.rgb, FogFactor); Out.rgb = EncodeRGB10(Out.rgb); return Out; */ and this is Vertex Shader: #pragma pack_matrix(row_major) float4x4 wvpMatrix : register(c0); float4 Params : register(c4); struct a2v { float4 Position : POSITION; }; struct v2f { float4 Position : POSITION; float3 Normal : NORMAL; }; v2f main(a2v IN) { v2f OUT; float4 position = 1; position.xyz = normalize(IN.Position.xyz) * Params.w; OUT.Position = mul(wvpMatrix, position); OUT.Normal = normalize(IN.Position.xyz); return OUT; } I'm seriously dunno anything about shaders and copying from other games will be not good idea, because every game is other (probably visit on Microsoft site will be help for learn about High Level Shader Language), but the question is - how to convert or something these shaders to MTA format/type, and it's possible?
  24. Yeah, it resolved my issue for which I thank you, but now when I write "/v_inv", I've got an message "Sorry, but you can't use this command!", even thought I'm admin. I must add this script to acl.xml or what?
×
×
  • Create New...