-
Posts
142 -
Joined
-
Last visited
-
Days Won
6
Everything posted by FlorinSzasz
-
As a person which uses the GUI windows everytime i need a menu or list and so on if you dont want to bother with design to much go for them but if you want fancy stuff like nice a custom hud or minimap or maybe a menu then goo for Dx functions. There are some libraries which make things fancy and you have built in functions for them and you dont need to make your own. DGS -> https://wiki.multitheftauto.com/wiki/Resource:DGS CustomWidgets -> https://wiki.multitheftauto.com/wiki/Resource:CustomWidgets Modern Dx Library -> https://wiki.multitheftauto.com/wiki/Modern-Library For button clicks on gui you have an Event so is easy to track them -> https://wiki.multitheftauto.com/wiki/OnClientGUIClick For dx you have an Event too https://wiki.multitheftauto.com/wiki/OnClientClick https://forum.multitheftauto.com/topic/100217-clickable-dx-rectangletext/
-
What pc requirements will the server/game have?(to be played)
-
even if they bypass the anti-cheat when it comes to wall hack somehow it wont be usefull at all because if they dont gain any benefit from that only in a dm zone or gamemode and thats all. When they dont have any weapon in hand the wall hack from my point of view wont bring any advantage.
-
if i remember correctly the AC has built in things which can detect some wall hacks if not most of them. If you think someone has xray / wallhack use this for weapons https://wiki.multitheftauto.com/wiki/GetPedWeaponMuzzlePosition and add a 3d line to it to see where they aim.
-
You need a table with all players location and then you loop through all players who are in server and check were they are now and get the distance between points and thats it. There is a limit how far they can go in a certain time like 10s 20s or 30s if they go to far in that time they are out. Also if player dies you should update the location in that moment not after timer resets.
-
Here is the code -> function onBikeEnter(player,seat,jacked) if player then if getElementModel(source) == 448 then setVehicleEngineState(source,true) end end end addEventHandler("onVehicleEnter",getRootElement(),onBikeEnter)
-
Salut tuturor! M-am decis de ceva vreme sa realizez un tutorial legat de mysql mai exact ,,sqlite,, din motivul ca am tot primit intrebari legate de topicul asta. Asa ca voi incerca in mare sa acopar cam ce trebuie sa avem in vedere. Am sa ofer exemple concrete astfel incat sa fie totul clar si limpede si pe intelesul tuturor! --Avem functiile: dbConnect() dbExec() dbQuery() dbFree() dbPoll() 1). dbConnect() --1.Folosim dbConnect() - pentru a crea sau a ne conecta la o baza de date existenta. --Exemplu dbConnect("sqlite","data.db") -- primul parametru sqlite indica tipul bazei de date --iar al doilea indica numele care poate fi orice doriti cat timp este cu extensia / terminatia ".db" 2. dbExec() se foloseste a) cand cream un tabel in baza de date! b) cand facem update la datele care sunt deja prezente in baza de date! c) cand inseram ceva in baza de date! Exemple: --- !!! se are in vedere in primul camp al functiei dbExec avem mereu variabila ce are legatura cu conexiunea la baza de date adica variabila connection! dbExec(connection,"CREATE TABLE IF NOT EXISTS PlayerData (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,name TEXT,hp INTEGER,money INTEGER,armour INTEGER,skin INTEGER,location TEXT)") -->a) cream tabelul PlayerData daca acesta nu exista deja, asta indica expresia pana la inceperea parantezei! -->b) primul camp este id numar intreg si nenul adica trebuie sa aiba o valoare, mai mult decat atat este cheie primara ceea -- ce inseama ca acest numar sau valoare nu poate fi dublata este unica, -- autoincrement inseamna ca valoarea acestui camp creste cu fiecare inserare -->c) campul nume este de tip Text deoarece numele contului pe care jucatorul joaca este un string -->d) hp este de tip numar intreg deoarece reprezinta viata jucatorului -->e) armour este de tip numar intreg deoarece reprezinta armura jucatorului -->f) skin este de tip numar intreg deoarece reprezinta modelul jucatorului -->g) money este de tip numar intreg deoarece reprezinta valoarea banilor pe care jucatorul ai detine -->h) location este de tip text deoarece vom folosi functia toJSON pentru pune toate valorile intr-un string. --Fara a mai crea 3 campuri in tabelul PlayerData -- >> dupa denumirea campului in expresia prin care creeam tabelul trecem si tipul acestuia de exemplu name este un camp text --pentru ca numele jucatorului este un text si nu un numar intreg --------------------------------------------------------------------------------------------- dbExec(connection,"INSERT INTO PlayerData (name,hp,money,armour,skin,location) VALUES (?,?,?,?,?,?)",name,hp,money,armour,skin,location) -- inseram in tabelul PlayerData -- in functie de campurile in care inseram le trecem intre paranteze -- daca vreau sa inserez doar in campul name trec doar name intre paranteze si la VALUES (?) un singur semn de intrebare in paranteze -- cate campuri avem intre paranteze atatea semne de intrebare punem la VALUES intre paranteze -- dupa adaugam valorile aferente campurilor pe care le avem in paranteze -- numarul valorilor trebuie sa fie egale cu cel al campurilor si al semnelor de intrebare din paranteze. --------------------------------- dbExec(connection,"UPDATE PlayerData set hp=?,money=?,armour=?,skin=?,location=? WHERE name=?",hp,money,armour,skin,location,name) -- aici facem update la tabelul PlayerData -- in functie de numarul campurilor la care facem update atatea valori adaugam dupa expresia ce este intre ghilimele -- la aceste valori se adauga ultima valoarea/variabila ce cuprinde numele contului de pe care jucatorul se joaca pe server -- daca doar la hp vrem sa facem update avem -> dbExec(connection,"UPDATE PlayerData set hp=? WHERE name=?",hp,name) 3.) dbQuery() --> Folosim functia -> cand interogam baza de date pentru anumite informatii care sunt / sau pot fi prezente in aceasta! --> selectam date din baza de date dbQuery(connection,"SELECT * FROM PlayerData") -- selectam tot din tabela PlayerData, la primul argument avem --> ca si la dbExec() variabila aferenta conexiunii dbQuery(connection,"SELECT * FROM PlayerData WHERE name=?",name) -- selectam tot din tabel unde avem numele jucatorului selectat. dbQuery(connection,"SELECT hp FROM PlayerData WHERE name=?",name) -- selectam doar datele legate de hp unde avem numele jucatorului selectat. 4. dbFree() - il folosim doar pentru a elibera baza de date de interogarea care nu ofera un rezultat sau care ofera un rezultat dar nu este colectat sau folosit! 5. Folosim dbPoll() - pentru a verifica daca baza de date a pregatit / returnat un rezultat in urma unei interogari! dbPoll(query,-1) -- aceasta functie va returna un tabel cu rezultatele cerute de la baza de date daca datele cautate sunt in baza de date. --query reprezinta interogarea la care face referire. 6.Exemplu Practic in script: local connection = dbConnect("sqlite","data.db") -- cream / ne conectam la baza de date if connection then -- verificam daca conectarea reuseste outputDebugString("[DB] avem conexiune la baza de date [data]") -- acest mesaj apare in consola serverului daca conectarea are loc else outputDebugString("[DB] nu avem conexiune la baza de date [data]") -- acest mesaj apare in consola serverului daca conectarea nu are loc end function createTable() -- cream tabelul bazei de date dbExec(connection,"CREATE TABLE IF NOT EXISTS PlayerData (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,name TEXT,hp INTEGER,money INTEGER,armour INTEGER,skin INTEGER,location TEXT)") end addEventHandler("onResourceStart",getRootElement(),createTable) function loginData(_,contPrezent) -- contPrezent este contul cu care jucatorul se conecteaza local NumeCont = getAccountName(contPrezent) -- obtinem numele contului pe care jucatorul il foloseste acesta poate sa fie asemanator cu numele din joc al jucatorului sa nu if NumeCont then -- daca avem numele contului mergem mai departe local query = dbQuery(connection,"SELECT * FROM PlayerData WHERE name=? LIMIT 1",NumeCont) -- interogam baza de date cu numele primit -- limit 1 limiteaza numarul de rezultate la 1 daca avem mai multe! local rezultat = dbPoll(query,-1) -- colectam rezultatul din tabelul PlayerData if #rezultat > 0 then -- daca avem rezultat continuam for k,v in ipairs(rezultat) do -- trecem prin sir si setam jucatorului datele salvate setElementHealth(source,v.hp) setPedArmor(source,v.armour) setPlayerMoney(source,v.money) setElementModel(source,v.skin) local location = fromJSON(v.location) -- folosim fromJSON() pentru ca datele au fost salvate sub forma de de string si vrem sa le aducem sub forma de sir setElementPosition(source,location[1],location[2],location[3]) end elseif #rezultat == 0 then -- daca rezultatul este zero inseram jucatorul in baza de date pe baza numelui de cont al acestuia dbExec(connection,"INSERT INTO PlayerData (name) VALUES (?)",NumeCont) end end end addEventHandler("onPlayerLogin",getRootElement(),loginData) function leaveData() local location = {} -- sirul gol in care punem locatia jucatorului local Nume = getAccountName(getPlayerAccount(source)) -- cautam numele de cont al jucatorului care iese de pe server local hp = getElementHealth(source) -- aflam Hp-ul acestuia local money = getPlayerMoney(source) -- aflam banii location[1],location[2],location[3] = getElementPosition(source) -- aflam locatia si o punem intr-un sir local skin = getElementModel(source) -- aflam modelul skin-ului folosit local armour = getPedArmor(source) -- aflam armura jucatorului -- facem update la baza de date si mai exact la ce am aflat adica hp, banii, skin,armura, si locatie, dupa care avem Nume deoarece specificam bazei de date la ce jucator sa faca update dbExec(connection,"UPDATE PlayerData SET hp=?,money=?,armour=?,skin=?,location=? WHERE name=?",hp,money,armour,skin,toJSON(location),Nume) -- am folosit toJSON() pentru a stoca sirul cu coordonatele jucatorului ca si string pentru ca acesta sa fie salvat in campul location din baza de date sub forma de text end addEventHandler("onPlayerQuit",getRootElement(),leaveData)
-
I made an example maybe you can get an idea from it how it will work. If you go for toJson/fromJson if you dont have many achievements. local dbConn = dbConnect("sqlite","users.db") local users = {} achievements = {"NewOne","Top1%","TheKiller","OldOne","Nobody","NooB"} function CreateTableAchievements() dbExec(dbConn,"CREATE TABLE IF NOT EXISTS achievements (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,user TEXT,achievements TEXT)") end addEventHandler("onResourceStart",root,CreateTableAchievements) function onLogin(_,currentAcc) if currentAcc then local acc_name = getAccountName(currentAcc) if acc_name then local query = dbQuery(dbConn,"SELECT * FROM achievements WHERE user=? LIMIT 1",acc_name) local rez = dbPoll(query,-1) local data = fromJSON(rez[1]["achievements"]) if #rez == 0 then dbExec(dbConn,"INSERT INTO achievements (user) VALUES (?)",acc_name) elseif #data > 0 then users[source] = data end end end end addEventHandler("onPlayerLogin", root,onLogin) --- a coomand to give me some achievements addCommandHandler("newacv",function(player,CommandName,acv) if player then if acv ~= nil then if users[player] == nil then users[player] = {} table.insert(users[player],tonumber(acv),achievements[tonumber(acv)]) end if users[player][tonumber(acv)] == achievements[tonumber(acv)] then outputChatBox("[Achievements] You have this achievement!",player,100,250,100) else table.insert(users[player],tonumber(acv),achievements[tonumber(acv)]) outputChatBox("[Achievements] New achievement unlocked!",player,100,250,100) end end end end,false,false) addCommandHandler("saveacv",function(player,CommandName) if player then if users[player] ~= nil then local acc_name = getAccountName(getPlayerAccount(player)) dbExec(dbConn,"UPDATE achievements SET achievements=? WHERE user=?",toJSON(users[player]),acc_name) end end end,false,false)
-
If you dont update the data you can store it in a script in a table serverside also if you rly want then you can use sql / xml which way you know to use better. weapon_data = { [1] = {--data1....} [2] = {--data2...} } --- so on.... Also if you use a table dont use ,,local`` only the table variable like i wrote before.
-
well first you should add this code to the server side (i have a copy of the code i gave you long time ago for skinInventory) addSkinFromBox = function(player,model) -- after model add coins / money the player used to buy the box if he used if model ~= nil then local acc_name = getAccountName(getPlayerAccount(player)) local query = dbQuery(connection,"SELECT username,skin FROM skins WHERE username=? AND skin=? LIMIT 1",tostring(acc_name),tonumber(model)) local rez = dbPoll(query,-1) if #rez > 0 then outputChatBox("[SKIN_SYSTEM] You have this skin already!",player) -- if he pays with something give the player money back or coins or something else if you should give him. elseif #rez == 0 then -- if he doesnt have the skin update db and insert it to db! dbExec(connection,"INSERT INTO skins (username,skin) VALUES (?,?)",tostring(acc_name),tonumber(model)) outputChatBox("[SKIN_SYSTEM] You got a new Skin!",player,104,255,104) end end end Also If your inventory system script is in another folder you have to add this in the meta.xml where your skininventory resource is (not the inventory resource) <export function="addSkinFromBox" type="server"/> And in the inventory resource where is your openBox event or function use this call. exports["test"]:addSkinFromBox(player,model) -- between -> " " you put your resource name folder where your skinInventory scripts are for example my skin inventory resource is in test folder -- player -> you put the player variable or thePlayer or client it depends what variable you have in you inventory script. -- model -> the model variable or how it is named in your resource. AND if your inventory script is in the same folder with skinInventory script then you only add this in your openBox event or function! -> addSkinFromBox(player,model)
-
Yes you can add skins from another script with a command but how your command is looking or in which way you want to use that command to add skins?
-
well even if you fly with hydra u wont be much faster than an infernus with max speed + nos in flat line in 30 seconds time so yeah. I tested the distances in best case the player will have on my server but they wont have that case 99.9% of time. The anti-cheat has to be 100% server side. You have to get creative when you make it, also you have to make it to work on your gamemode, for e.g my anti-cheat wont work on your gm. Well you disable them short term. For long term you have to think when most of the explosions take place so you make the code work right.
-
This is very simple check for distances how far he should travel by foot/car/ plane in a certain time and check with timers and if something is not right bang. Well if u have teleports you have to check if the player used a command or not.
-
Thx is somehow close to what i meant.
-
I dont allow players to spam the db or something with anything in any script i wrote! I just want to know if i should use a timer and loop through all players when i check some things like money and xp and other or use a timer for every player, i dont want to tank the server performance. Even if this are the only timers /timer which will run. As an example you login, i get the data for now only money from db and have it stored in a table. I want to see your money every 20 - 30 seconds and from 1000$ you go to 999999999$ something is wrong.
-
Hi everyone! I am working on an anti-cheat resource for my server. I wonder what method should i use ? - make a timer and loop through all players for money,xp, x,y,z, and check with db data and so on... (i call the db once for data and i will use a formula for checks )! - or make a timer for every player on the server and the apply the same things! *Note: my server is not up (hosted), at first i plan to have at least 50 slots. Maybe later if i will have players i will go to 100 / 150 / 200 and so on if i need to. Which method will be better for long term if there will be more players.
-
Well did u attach some data or conditions onPlayerWasted to the player or when he types the /pvp command?
-
Wow man that is a lot of work! I mean is beyond my imagination as a scripter.
-
remove type client from there maybe that could be the problem (from client i mean) -> u only need this -> <file src="beep.mp3"/>
-
Marker = createMarker( 1508.814453125 , -1144.19921875 , 140.93536376953, "cylinder", 1, 255, 0, 0) function openwindow(thePlayer) local elementType = getElementType(thePlayer) if elementType == "player" then triggerClientEvent(thePlayer,"opengui1window", thePlayer) end end addEventHandler("onMarkerHit", Marker, openwindow)
-
I am not good at this like(dxdraw functions), i didnt do math like geometry in a while but this should work! dxDrawCircle(200, 400, 100,0,((health/100) * 360), tocolor(0, 255, 0))
-
Bine ai revenit, :)) mai merge mta la noi cât se creează servere ce apar și dispar peste noapte, roleplay-ul merge aparent dar doar la noi din ce vad asa in mare parte.
-
Well remove player argument from the function on the Event ,,onClientRender' just function() and on getElementData replace player with localPlayer Also onClientRender will output something/ refresh every second if i remember, so until the data is not true then it wont output only false.
-
Remove local word who is in front of marker first like this -> If u put local in front of variable and the variable is in a function the variable can be used in that function only. With ,,local`` you limit the scope of the variable! marker = createMarker(x, y, z, "cylinder", 3.0) -- <<<<<< like this! And again do this here too