Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 23/08/19 in all areas

  1. To check if JSON is valid itself, all you need to do is check whether the result of fromJSON is not a nil. If you want to make sure the actual values within that JSON are correct and within bounds, you'll simply need to make your own function which tests every part of the JSON, makes sure the required keys are present or assign default values to them, make sure the values are within the bounds, etc. function checkJson(text) local theTable = fromJSON(text) if not theTable then return false end -- it's not valid JSON if not theTable.some_required_key then return false end -- doesn't have the required key-value pair if theTable.some_required_key > maximum_allowed_value then return false end -- actual value exceeds allowed value if theTable.some_other_key and theTable.some_other_key > maximum_allowed_value then theTable.some_optional_key = maximum_allowed_value end -- update the value to be within the bounds if it would otherwise be outside it -- etc return theTable -- return the updated table if changes were made end function loadMyJson() local f = fileOpen("settings.json") local json = fileRead(f, fileGetSize(f)) fileClose(f) local settings = checkJson(json) if not settings then outputChatBox("Could not load settings.json. Loading defaults...") settings = g_DefaultSettings end -- etc end If you simply don't want people to change the file manually at all, you could encodeString with TEA, or encodeString with TEA a SHA256 hash of it and store it alongside, and check if the hashes match. The person won't be able to generate a valid hash if they don't know how the TEA secret. This is in effect similar to what a HMAC does but I don't think MTA has HMAC functions built in. Naturally, if you choose the latter, the safest bet would be to have the server send the tea secret via an event rather than having that secret hardcoded in the script file. It would still be possible to lift it out of memory either way, but at least if it's on the server it can't be somehow extracted out of the file offline, through decrypting, decompiling or whatever.
    2 points
  2. Tem como sim é só fazer pra quando o usuário realizar a compra do carro gerar letras/nums aleatorios e salvar em uma tabela. Depois é só fazer pra sempre q spawnar o carro setar a placa que foi gerada utilizando SetVehiclePlateText. Sobre o /placa você pode fazer a mesma ideia da placa, só que você pode fazer pra quando a pessoa comprar o carro salvar o usuário em uma tabela (coisa q todos os scripts já fazem), depois você pode fazer pra sempre q spawnar o carro setar uma elementData com o dono do carro e outras informações. Depois é só fazer o básico de elementData, fazer um comando de /placa q puxe os elementDate (no caso o q informa o dono ou outro q vc preferir) do veiculo ou você faz um /placa [codigo] q procura veiculos spawnados q tem uma elementData com o código q vc digitou. É meio complicado se você não tem noção de programação.
    1 point
  3. setElementData يقوم بحفظ داتا للاعب getElementData يقوم بجلب الداتا المحفوظه للاعب اما بالنسبه الكود اللي يجيب لاعب عشوائي getRandomPlayer
    1 point
  4. It worked! How did I not realize that ?! hahaha Thank you so much!
    1 point
  5. 1 point
  6. That is not why I recommend using the browser. Sure a linter can tell you if it is broken or not. But it doesn't tell you anything about the object types. Breaking your JSON is annoying, but that doesn't happen as often as having your format being ruined by accidentally creating a mixed table. Your browser will tell you for each object if you are dealing with an array or an object. When it is ruined, you are not being able access your arrays formats as easy any more. Those must be strictly maintained. _________________________ About your main issue. How about you write a validator? validator = { { key = "money", func = function (value) return type(value) == "number" end }, { key = "name", func = function (value) return type(value) == "string" end }, }
    1 point
  7. @slapz0r local serial = getAccountSerial ( account ) if serial then addBan (nil, nil, serial) end
    1 point
  8. 1. Open your browser. 2. Right-mouse button > inspector 3. Go to the console tab. 4. Copy the JSON.parse method. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse 5. Place your json string as an argument. JSON.parse("the string") 6. Copy and past the code in to the console and run it. You have now loaded your JSON to it's origin. Or rather live version of it. Now you can inspect.
    1 point
  9. Se você está setando a animação com um script client-side, dai só vc vai ver mesmo. Pros outros verem vc tem que fazer server-side.
    1 point
  10. HOPETIZENS: SS-RP | MTA:SA Hello! This time, we will introduce a new type of gameplay into MTA:SA named "Social simulation role play" (SS-RP), what it is? Basically unlike most of the RP servers, you don't have to simulate every action you are doing. You only have to simulate the character you are playing, example, if you are a mafia boss, a police, etc. We have a system implemented with animations and shouts whose can be used easily in order to reproduce a role or action. Server in general: SS-RP, for example, its the gameplay of a very popular game named "The Sims". We have many things in common with that videogame: Needs (thirst, hunger, energy, bladder, hygiene) which means that owning a house, its a MUST! And also a system of skills whose can be learnt at the University, Gym, etc. You can role a group, you can role a mobster, you can do many actions in our server, we are not limited! Map: We have a custom city! Made with Map editor, since we know that most of you are bored of the current San Andreas! Since having house its very needed you can stay in any hotel till you have enough money to afford any house. Houses have new interiors, not the default ones. Also those can be furnitured as you wish! A new city full of drama and new missions is awaiting! About jobs: You have many ways to get money. Every job needs certain qualities or skills, as mentioned above, skills are needed in some job and you have to learn them. Theres also jobs that don't need abilities/skills. Basically you have to start from 0% with a common job such as an cashier and then by studying or making certain actions as medic or cop. There are +10 new jobs (Some never made in MTA) but we will try to implement new jobs or new ways to make money daily. About combats: Our system is trying to be apart of most of the RPG/RP servers thats why we introduce a new way of DM; Tactical shooting. Since our server is RP, we try to keep the realism at every way. With this system, tactics and skills are very needed, you gotta use cover and also find the correct moment to rush or shoot. 3 shots or 1 headshot = Dead. Also we implemented a system of hemorraghe whose makes the combats more harder. We also introduce a lot of animations when it's time to fight such as move crouched easily, easy weapon switch and hit the dirt! Law/Criminal system: We implemented "Karma". You get negative karma by doing bad actions such as not working, fighting, etc. As low karma player you can play as criminal. You can role the criminal you want! A narco, a robber, a biker, a psycho, etc! As a good karma player you can play as civilian or as cop. We have a law system very unique and original. You will be also able to be the law chief or a simple police man. Also a corrupt cop, as I said before this is unlimited! For the moment our server is on development but we are looking for future members! Server will be available in spanish but soon in more languages! Join our Discord: https://discord.gg/jKBhvxZ Thanks!
    1 point
×
×
  • Create New...