Jump to content

Gallardo9944

Members
  • Posts

    442
  • Joined

  • Last visited

Everything posted by Gallardo9944

  1. At first, never create a table called "table" because this will erase all your functions like table.insert from your current Lua VM (serverside scripts, in your case). Outputting 1st argument depending on the 2nd is pretty easy. Or, do you want to specify the id of the message instead of its argument? First example (reading argument from the table) local tbl = { {"Hello World", "id1", "path2"}, {"Hello", "id2", "path2"}, } function infocmd(me, _,info) local info = tostring(info) for i,v in ipairs(tbl) do -- yep, only looping to find it if v[2] == info then -- check if there is such value2 in the table outputChatBox(v[1]) -- output "Hello World" of command had"id1", "Hello" if command had "id2" return -- ending the function when we found it, who needs to loop through useless data anyway end end end addCommandHandler("command", infocmd) But if you want to use the id itself (/command 5), you can make it like this: local tbl = { {"Hello World","path2"}, -- you don't need ids here anyway {"Hello","path2"}, } function infocmd(me, _,info) local info = tonumber(info) if not info then return end -- if it's not a number, then end the function local val = tbl[info] -- get table value with your specified index if val and val[1] then -- if the table number exists and there is a message in it outputChatBox(val[1]) -- output "Hello World" of command had "1", output "Hello" if it had 2 end end addCommandHandler("command", infocmd)
  2. Bandwidth of 50k means download speed will be about 45kbps. This is extremely slow. Try something like 1024*1024 (1mbps)
  3. Images are the only good choice for now. You can use rectangles if you don't need gradients and rounding though. But drawing 1 big thing is always better than 10 smaller ones.
  4. You have to be clearer so we can help you. A "ladder" can be pretty much anything you can think of.
  5. Untested, but should somewhat show you how it works function reward(player) --gets the player's serial and searches the mysql table for it local serial = getPlayerSerial(player) local query = dbQuery(handler,"SELECT serial FROM rewardtable WHERE serial=?",serial) -- handler is your mysql connection with dbConnect. Might be a bit different with your table local data = dbPoll(query,-1) -- query the results to get the actual serial dbFree(query) local info = data[1] -- get the first result if info and info["serial"] then -- if there is at least 1 result with this serial -- will outputchatbox something outputChatBox("Yo man! You already got the gift!",player,255,255,255,true) else --if the serial doesn't exists in mysql table will do something like GivePlayerMoney + adds the serial in the mysql table dbExec(handler,"INSERT INTO rewardtable (serial,playerName) VALUES (?,?)",serial,getPlayerName(player)) -- execute to insert into the table. The query can be a bit different depending on your database. Added playerName example in case you need it givePlayerMoney(player,10000) -- give the cash outputChatBox("Shut up and take my money!",player,255,255,255,true) end end addCommandHandler("gift",reward)
  6. What's the point of all those checks? local veh = getPedOccupiedVehicle(localPlayer) if isElement(veh) and getVehicleType(veh) == "Helicopter" then -- you don't need isPedInVehicle because getPedOccupiedVehicle already returns required things. Simply check if it's an element and you should be fine -- else -- end
  7. Funny thing is that according to the code, the images are outside of the render target.
  8. replace dxSetRenderTarget( myRenderTarget ) with dxSetRenderTarget( myRenderTarget, true ) -- 2nd argument set to true means "clean the render target"
  9. That happens because your dxDrawImage of render target has postGUI argument set to true
  10. If you want to put the rectangle in the render target, put it before line 21 in your code (2nd message). If you want it ontop: 1. If it's inside the target: draw it after all other drawing parts 2. If it's outside of the target: draw it after you draw the render target
  11. That's easy to find anyway. Better try to fake somthing like .luac file so stealers think it's a compiled script and not a file you can use as models
  12. Doesn't matter. Client always has the key. You can send the key to the client from the server instead of keeping it in the client.
  13. triggerClientEvent is not recommended for huge files. Use triggerLatentClientEvent instead.
  14. Scrolling can be achieved by creating a global variable. You should change it every time you need to scroll. Set this variable as Y position offset in your render function. local offset = 0 -- change this up or down to change dxDrawText's position dxDrawText("Hello world",px,py+offset,x,y) -- the variables are made up, the important part is "+offset"
  15. You can make your files download via the script itself, e.g. triggerLatentClientEvent. This way, you can use teaEncode serverside to encrypt the file, then send it to the client, save it as it is, and use teaDecode when you need to use it in your script. But I think you'll have to create a temporary file which is decoded, so catching and stealing it would still be kinda possible.
  16. Gallardo9944

    CPU usage

    No, i'm not using them. Speaking of custom blips, you can simply create them clientside to save server resources.
  17. Gallardo9944

    CPU usage

    My normal CPU usage is around 15%. That's with approx. 50 players online. If a map is loading and it's being sent to all players, it could jump to 70-80 for a sec.
  18. I'm pretty sure you're not using race resource from original MTA pack. If not, there is a high chance that the resource is actually stolen or something else. Post the debug output so we can actually help.
  19. Other servers' tags in the name:
  20. spawnpoints = { [1] = {-1344.4324,609.234,13}, -- it has to be a table to contain multiple values [2] = {0,0,2}, } -- later on local x,y,z = unpack(spawnpoints[math.random(1,#spawnpoints)]) -- gets all values from the inner table setElementPosition(playerElement,x,y,z)
  21. Details should work. But if it's a VPS, you have to follow the instructions i gave you above.
  22. This is one of possibilities , When car is created or bought. You take owner name + random integer and set is as car_id. Or you can just make the same thing with out owner and you random integer but you need to check if that random integer is not is use already. setElementData(vehicle,"car_id",car_id) than just retriev element by car_id and add new values, create column in sql with car_id + other data attached to it, and select data and vehicle by it's car_id Any MYSQL table can have an integer value with AUTOINCREMENT, means it automatically assigns IDs. Getting random number is not necessary.
  23. I think you should make a sync serverside and just interpolate for others clientside. Half a second should be enough. You can even trigger events with that instead of element data, it will reduce bandwidth usage with many players.
  24. Xml will become slow after a lot of nodes. If you do so, split it into files or better use a SQL database.
×
×
  • Create New...