Jump to content

DRW

Members
  • Posts

    364
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by DRW

  1. Thank you all for that. Have another doubt here and I don't want to spam the scripting section. Let's say I want a ped to move/jump, so I'll have to send some type of data to all the players. What is more performance-friendly: setElementData so everyone can get the info when the data is changed for the client or just triggerClientEvent for each player? It's only an example, this is in no way what I'm doing. So... This? -- SERVERSIDE function setBotWalking (bot) triggerClientEvent (root,"setBotWalking",bot) botlist[bot] = {"walking"} end -- CLIENTSIDE addEvent ("setBotWalking",true) addEventHandler ("setBotWalking",root,function() setPedControlState (source,"forwards",true) end) ...or this? -- SERVERSIDE function setBotWalking (bot) setElementData (bot,"state","walking") end -- CLIENTSIDE addEventHandler ("onClientElementDataChange",root,function(dataname,oldvalue) if getElementType (source)=="ped" and dataname == "state" and getElementData (source,dataname)=="walking" then setPedControlState (source,"forwards",true) end end)
  2. DRW

    MTA PUBG

    You can copy ideas. Why couldn't you? As far as they don't steal my code, they can copy the entirety of my server ideas if they want to. What owners should do is to make their server as complicated and special as possible so yours stands out. There's two specific servers who want to copy my server, but they fail miserably because they're not competent enough, they always try to steal my clientsided files instead of getting to work. People who are original and know enough about scripting won't waste their time in copying a server's ideas, they will make something better, and as far as I know, that's just fine. The rest will probably try to steal ideas so they can create a server, which will die after a month without donations and <10 average players at most. So yeah, power to everyone who wants to make a Battle Royale, RPG or whatever they want, as long as they understand how this thing works.
  3. guiCreateWindow() guiCreateGridList() guiCreateButton() triggerServerEvent() triggerClientEvent() addEvent() addEventHandler() -- "onClientGUIClick" for example. getPlayerName() These functions would make it work.
  4. I think it is not possible, but you can always use imgur.
  5. Always use dbFree() after every dbQuery() function. local query = dbQUery() dbFree (query)
  6. DRW

    Memory problems

    Alright, I'll contact you when I get the results.
  7. DRW

    Memory problems

    Oh, sorry for not specifying. The entire VPS.
  8. Thank you so much! Totally forgot about those events.
  9. Alright, don't know if this has exactly got to do with MTA itself, but there I go: I'm using my web server to stream ambient music to the players who want to listen to it. The script works fine aside of lag issues, I use playSound, paste an URL like "www.server.com:22010/"..math.random(1,40)..".mp3" and check every X seconds if the sound is still playing; if it's not, then play another ambient song. Pretty easy, but the problem is that the server starts getting a crap load of RAM usage, it goes up to 95% from 30-50%, which is the average usage rate of my server. Is it MTA's problem? I'm using nginx.
  10. Puedes manejar scripts de nametag que haya por los resources de la comunidad y modificarlos para que funcionen con slothbot. Es algo de trabajo, pero nada del otro mundo.
  11. You've done a really good job there. I support people that create projects so anyone else can use them. Hope more people consider donating.
  12. I need the peds to jump when a lineOfSight is created and obstructed by an obstacle, so I can use setPedControlState. I'm using a timer every 2 seconds. The table's structure is this. table = { {botPed}, {botPed}, {botPed}, {botPed}, {botPed}, {botPed}, {botPed}, } You mean that I should distribute the bots in various tables? I have thought about that but I didn't think it would make sense because I'd have to loop through two tables anyway.
  13. You can go to luac.multitheftauto.com and obfuscate the actual script files. People can only steal the client files, though. It's the only thing they download. If someone downloads your server files, then you should focus on securing your server or computer, because they've just hacked you. Just add cache="false" after the client file entry of the meta.xml file: <script src="clientfile.lua" type="client" cache="false"/> That will load the file directly to the RAM, so script stealers can't just go and snatch the client file from the hard drive like every other dumbass does. Also, this disables the addDebugHook function: addDebugHook( "preFunction", onPreFunction, {"addDebugHook"} ) function onPreFunction( sourceResource, functionName, isAllowedByACL, luaFilename, luaLineNumber, ... ) return "skip" end
  14. You mean the life bar and the weapons are not showing? First of all, is it the original GTA: SA HUD? Is it your server? If it is, check if there's a script hiding some HUD item, if it is not, then probably the server did it intentionally. Does it happen to every server you join, or just some specific servers? PD: And by the way, this is not a section dedicated to these kinds of problems, just suggestions.
  15. Hi, So I'm having a pretty big problem related to performance. I have some AI, and the client sometimes loops through all of them so it can handle operations like jumping, for example. At first, I used to loop through all peds, and filtered them for their elementdata, and that was obviously really performance-hungry and not very effective. Now, the script is a little bit more optimized, it does no longer loop through every single ped. The server sends the player a table with all bots, and the client does everything else by just using that table, so instead of looping through almost 500 peds, it just loops trough 170 or so. I've checked it up, and I've seen that, ~140 bots in the table won't cause performance problems, but ~200 will make everyone have minimal lag spikes every 2-4 seconds. What should I do? I absolutely need to loop through all bots and I need ways to optimize this. Thank you for your help.
  16. Just imagine playing with a friend, killing raiders and bandits, looting, leveling up, helping each other out, just like a real on-line RPG. If the bots and the pickup system were enhanced and there was bigger playerbase overall, this would be my go-to server. For the rest, it is a living, breathing world to explore, and damn, it does really look like a mod straight out of those CLEO conversions. Good job, very good job.
  17. DRW

    SQL Query error

    I believe it's either a version mismatch or the database is damaged or encrypted, try using a newly installed database so you can at least check if it's a problem of the script, server or database.
  18. I don't understand a lot but I can figure out you mean that you want to save a paintjob on a database, so you can load it later. You should really learn SQL functions on the wiki: executeSQLQuery() You should trigger a client event for all players, so the shader is applied for everyone, preferably on the Cortina1() function. for i,players in ipairs (getElementsByType ("player")) do triggerClientEvent (players,"setShader",players,cortina) end then on the "setShader" event, use engineApplyShaderToWorldTexture() on the first parameter of the function called by "setShader" on the client side.
  19. A primary security measure anyone with common sense would take: log everything. Absolutely everything. If you're a server owner, you know what you're dealing with; lots of players, lots of possible bugs and bad intentions. Yeah, they don't mix well. So, some time ago I have made this small and easy but really useful script which stores logs of whatever you want by just using an exported function. You won't have to worry about anything at all but the contents of the log , it creates a log if it does not exist, and if it exists the entry will appear at the next line. Each entry stores the time and date so you know when it all happened. You can choose to keep or to remove the color-codes, which is useful for chat logs or player names, for example. [SYNTAX] exports.easylogger:addLogEntry (text,logname[,removecolorcode]) - text: The text. - logname: The name of the log. - removecolorcode: Whether to remove colorcodes or not. Set to true to remove, false otherwise. [EXAMPLE] exports.easylogger:addLogEntry("Hello world!","logfile1") This would store the "Hello world!" text into a logfile called "logfile1.log". This has been very useful to me, I've catched plenty of people doing shady things like abusing a money system by tracking the transactions, the teamchat and localchat of my server. So, really hope it helps you too. Community download: https://community.multitheftauto.com/index.php?p=resources&s=details&id=15153
  20. local jugadores = {} local lplayer = getLocalPlayer() local info = {} local sx,sy = guiGetScreenSize() function crearArma(jug,arma) local model = obtenerObjeto(arma) local slot = getSlotFromWeapon(arma) jugadores[jug][slot] = createObject(model,0,0,0) setElementCollisionsEnabled(jugadores[jug][slot],false) end function destruirArma(jug,slot) destroyElement(jugadores[jug][slot]) jugadores[jug][slot] = nil end addEventHandler("onClientResourceStart",getResourceRootElement(),function() for k,v in ipairs(getElementsByType("player",root,true)) do jugadores[v] = {} info[v] = {true,isPedInVehicle(v)} end end,false) addEventHandler("onClientPlayerQuit",root,function() if jugadores[source] and source ~= lplayer then for k,v in pairs(jugadores[source]) do destroyElement(v) end jugadores[source] = nil info[source] = nil end end) addEventHandler("onClientElementStreamIn",root,function() if getElementType(source) == "player" and source ~= lplayer then jugadores[source] = {} info[source] = {true,isPedInVehicle(source)} end end) addEventHandler("onClientElementStreamOut",root,function() if jugadores[source] and source ~= lplayer then for k,v in pairs(jugadores[source]) do destroyElement(v) end jugadores[source] = nil info[source] = nil end end) addEventHandler("onClientPlayerSpawn",root,function() if jugadores[source] then info[source][1] = true end end) addEventHandler("onClientPlayerWasted",root,function() if jugadores[source] then for k,v in pairs(jugadores[source]) do destruirArma(source,k) end info[source][1] = false end end) addEventHandler("onClientPlayerVehicleEnter",root,function() if jugadores[source] then for k,v in pairs(jugadores[source]) do destruirArma(source,k) end info[source][2] = true end end) addEventHandler("onClientPlayerVehicleExit",root,function() if jugadores[source] then info[source][2] = false end end) addEventHandler("onClientPreRender",root,function() for k,v in pairs(jugadores) do local x,y,z = getPedBonePosition(k,3) local rot = math.rad(90-getPedRotation(k)) local i = 15 local wep = getPedWeaponSlot(k) local ox,oy = math.cos(rot)*0.21,-math.sin(rot)*0.21 local alpha = getElementAlpha(k) for q,w in pairs(v) do if q == wep then destruirArma(k,q) else setElementRotation(w,0,70,getPedRotation(k)+90) setElementAlpha(w,alpha) -- SETTING EACH WEAPON'S DIMENSION AND INTERIOR TO THE PLAYERS' setElementDimension (w,getElementDimension(k)) setElementInterior (w,getElementInterior(k)) ------------------------------------------ if q==2 then local px,py,pz = getPedBonePosition(k,51) local qx,qy = math.sin(rot)*0.11,math.cos(rot)*0.11 setElementPosition(w,px+qx,py+qy,pz) elseif q==4 then local px,py,pz = getPedBonePosition(k,41) local qx,qy = math.sin(rot)*0.06,math.cos(rot)*0.06 setElementPosition(w,px-qx,py-qy,pz) else setElementPosition(w,x+ox,y+oy,z-0.2) setElementRotation(w,-17,-(50+i),getPedRotation(k)) i=i+15 end end end if info[k][1] and not info[k][2] then for i=1,7 do local arma = getPedWeapon(k,i) if arma~=wep and arma>0 and not jugadores[k] then crearArma(k,arma) end end end end end) function obtenerObjeto(arma) local m if arma > 1 and arma < 9 then m = 331 + arma elseif arma == 9 then m = 341 elseif arma == 15 then m = 326 elseif (arma > 21 and arma < 30) or (arma > 32 and arma < 39) or (arma > 40 and arma < 44) then m = 324 + arma elseif arma > 29 and arma < 32 then m = 325 + arma elseif arma == 32 then m = 372 end return m end Try this. Check the line where "setElementInterior" is used so you can learn from it.
  21. Please, post a part of the script that's having the error so we can troubleshoot it, we have to take a look at how the database is being used so we can identify mistakes and the problem of the .luac file. Hope you've got an uncompiled version.
  22. I suggest you to find the resource that you think that could have been responsible of spawning these vehicles and restart it.
  23. Use setElementInterior() for the object you've created, select the interior where you want it to appear. You haven't specified what you want to do, so I can only say that.
  24. Yeah, looping through all accounts and all the vehicle data would not be as efficient but whatever, it works, the performance would not be considerably affected anyway. I do recommend a MySQL database, though.
  25. local table = {} table.insert (table,{model,{upg1,upg2,upg3,upg4}}) setAccountData (account,"Vehicles",toJSON (table)) local table = fromJSON (getAccountData(account,"Vehicles")) Not complicated at all and far easier.
×
×
  • Create New...