Jump to content

pa3ck

Members
  • Posts

    1,141
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by pa3ck

  1. Are you 100% sure, that the ports are opened on the correct IP? Your router (if not set up) will assign different IP to you every time you restart it, you might have opened the port for an old IP.
  2. pa3ck

    Discord & MTA

    Look at this topic, might be something you're looking for:
  3. Yes, that pretty much does what you said, but as far as I understand your code, whatever this code does, the if opponentStreak and opponentName then part might still be true on rare occasions. It would be better to put them in an else block, if the one with the loop found someone, do not run this code as well, it's just one of those things that might never happen, but when it does, you have no idea what caused it. I know right? I still have a couple of years old code as well, when I just started pretty much everything (LUA was my first language), it's soo awkward to look at..
  4. pa3ck

    MySQL and local server

    Well if your only problem with XAMPP is the port, you can easily change that. You can either change the ports XAMPP uses or the ports Skype uses. To change Skype: https://www.drupal.org/docs/develop/local-server-setup/windows/skype-interferes-with-xampp-and-wamp-on-port-80 To change XAMPP: https://www.geckoandfly.com/7491/xampp-apache-wont-start-change-port-to-listen-85/
  5. Yes, that should work, but make sure you only use the opponentStreak and opponentName when the player is no longer online, because it will only update those values when the last winner leaves, not when there's a new (different) winner. I'm just looking at this part of the code: if wins == 2 then knightc = wins pointsc = wins * wins elseif wins == 3 then knightc = wins pointsc = wins * wins elseif wins == 4 then knightc = wins pointsc = wins * wins elseif wins == 5 then knightc = wins pointsc = wins * wins elseif wins == 6 then knightc = wins pointsc = wins * wins elseif wins == 7 then knightc = wins pointsc = wins * wins elseif wins == 8 then knightc = wins pointsc = wins * wins elseif wins == 9 then knightc = wins pointsc = wins * wins elseif wins > 9 then knightc = wins pointsc = wins * wins end Why do you repeat the same thing over and over again? Aren't all the elseif's the same?
  6. Might not be the answer you are looking for, but I just hate Putty, it just feels old, like if I was using Windows XP again. I suggest using Bitvise, it's free and easy to use. You can open multiple file / command terminals, it saves your encrypted password etc, in my opinion, it's much better than any SSH client other there.
  7. Literally every single command you need is already on the wiki page, I have setup MTA servers on Linux many times using it, if you do everything as outlined, you should have no problem setting up the server. Link: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux
  8. I never understood why people think that using element data is worse than triggering many server events? I mean aren't they doing the same thing? Communicating between the client and server? Or is it because of the RAM? Why do people think element data is performance killer? If you're really concerned about performance (honestly, it doesn't really matter unless you're building a server that has an avg. of 300+ players), you can send everything to the client once, when they log in and whenever a new data is created on the run, let the client know about it.
  9. Oh, so you want to display all the non-specs and then when the player hovers over a button/text display the spectators only? I see, try this: local players = getPlayersInTeam(getTeamFromName ( "Spectators" )) or 0 for i = 1, #players do spectators[i].name = getPlayerName(players[i]) spectators[i].fps = getElementData(players[i],"fps") spectators[i].ping = getPlayerPing(players[i]) dxDrawRectangle(screenW * 0.2977, screenH * 0.3583+33*i, screenW * 0.4055, screenH * 0.0431, tocolor(40, 40, 40, 114), false) dxDrawText(spectators[i].name, screenW * 0.3063, screenH * 0.3694+33*i, screenW * 0.3633, screenH * 0.3917, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false) dxDrawText(spectators[i].fps or 0, screenW * 0.6281, screenH * 0.3681+33*i, screenW * 0.6453, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) dxDrawText(spectators[i].ping, screenW * 0.6672, screenH * 0.3681+33*i, screenW * 0.6844, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) end I changed the for k, v in ipairs loop.
  10. pa3ck

    spawn system

    I don't get it, onPlayerJoin gets called as soon as the player joins and you spawn them right away, there should be no window between joining and spawning?
  11. The best option with a script like this, where you will need to access the same data so many times, maybe even in renders (ie. displaying [ADMIN] in the player's name) you are better of using setElementData when the user logs in.
  12. This code editor is so messed up, I can barely see where an if, function or a loop starts, the old one used to be way better. Anyway, I see you added this part screenH * 0.3583+33*ids Where you multiply by the ids, but do you update the ids at every iteration of the loop? I still don't understand what you're trying to do exactly, do you want to list out all the non spectators first then the spectators?
  13. That's because you multiply the index of the current row by 33. But the calculation is the same in both tables, they are both multiplied by 33.What you should do is add some more calculation to the spectator rows. Try something like this: dxDrawText(spectators[i].name, screenW * 0.3063, screenH * 0.3694+33*id + #players * 33, screenW * 0.3633, screenH * 0.3917, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)
  14. Doesn't have to be server side, it's fine on client side with something like getTickCount() so you only update the element data every couple of seconds, like 5-8-10 secs or so, depending if you need to display it on HUD, that would be a bit choppy. Regarding the timer tick, 50 would be the most accurate, yea, but I don't think it's that important to get as accurate result as you can. See when you drive 150m forward, then 50m backward between 2 ticks, it will only update 100, not 200 (as a real car would), but you can't really change much on the outcome under 1-2 second time span.
  15. Do you also get the outputChatBox("event is cancelled") before the iprint(wasEventCancelled()) in the chat?
  16. local totalDis local lastX, lastY, lastZ function startJourney() if not lastX then -- if there is no previous position save the current lastX, lastY, lastZ = getElementPosition(vehElement) end setTimer(function() local currX, currY, currZ = getElementPosition(vehElement) -- get the current position of the vehicle totalDis = getDistanceBetweenPoints3D(currX, currY, currZ, lastX, lastY, lastZ ) -- calculate the distance between the current and the last and add it to the totalDistance lastX, lastY, lastZ = currX, currY, currZ -- update the last position with the current end, 2000, 0) -- 2 sec infinite timer, could be increased/decreased, the smaller it is the more accurate results you get end I used something like that in one of my projects, not saying it's the best solution, but it was working fine for me.
  17. It is, yes. This is how you start your MTA server with screen: SCREEN -S myserver ./mta-server -> myserver is the name of your screen (like a variable, it can be anything), you can go back to it any time with this command: SCREEN -R myserver -> this command will open up the same screen again, to detach the screen press CTRL + A then CTRL + D (this will exit from the screen, but it will keep running in the background) To completely stop the server, you can press CTRL + C to shutdown the server when in SCREEN mode
  18. You probably have something like this (if it's a client-only script, as it should be): local marker = createMaker(...) addEventHandler("onClientMarkerHit", marker, function() guiSetVisible(....) createVehicle(....) end) Change it to this: local marker = createMaker(...) addEventHandler("onClientMarkerHit", marker, function(player, dim) if player == localPlayer and dim then guiSetVisible(....) createVehicle(....) end end) If it doesn't look like that and you trigger an event from the server-side, show us your code.
  19. pa3ck

    Device Selection Dialog

    I would have never spotted that option, it no longer asks me to select the device. Thank you!
  20. The scope of the variable "weapon" is in the function hydraFunction as it's set to be a local variable, so hydraFiring and hydraStopping is outside the scope. You're are already saving the weapon element to an elementData, why not use that instead of the "weapon" variable? Try this: function hydraFunctions() local vehicle = getPedOccupiedVehicle(localPlayer) if(vehicle)then if getElementModel(vehicle) == 520 then outputChatBox ("Hydra guns installed") toggleControl ( "accelerate", true ) toggleControl ( "brake_reverse", true ) toggleControl ( "vehicle_secondary_fire", false ) toggleControl ( "vehicle_fire", false ) setControlState ( "special_control_up", true) toggleControl ( "special_control_down", false) local x, y, z = getElementPosition(vehicle) local weapon = createWeapon("uzi", x, y, z) local weaponHydraR = setElementData(vehicle, "weaponHydraR", weapon, true) attachElements ( weapon, vehicle, 0, 4, 1, 0, 0, 90) setWeaponClipAmmo(weapon, 500) setWeaponFiringRate(weapon, 90) end end end addEventHandler ( "onClientPlayerVehicleEnter", getLocalPlayer(), hydraFunctions ) function hydraFiring() local vehicle = getPedOccupiedVehicle(localPlayer) if(vehicle)then if getElementModel(vehicle) == 520 then if getElementData(vehicle, "weaponHydraR", true ) then setWeaponState(getElementData(vehicle, "weaponHydraR"), "firing") -- Can't seem to find the weapon outputChatBox ("guns activated") end end end end function hydraStopping() local vehicle = getPedOccupiedVehicle(localPlayer) if(vehicle)then if getElementModel(vehicle) == 520 then if getElementData(vehicle, "weaponHydraR", true ) then setWeaponState(getElementData(vehicle, "weaponHydraR"), "ready") -- Can't seem to find the weapon outputChatBox ("guns deactivated") end end end end bindKey("mouse1", "down", hydraFiring) bindKey("mouse1", "up", hydraStopping) bindKey("lctrl", "down", hydraFiring) bindKey("lctrl", "up", hydraStopping)
  21. Hey, I just came back to MTA not that long ago and since I updated my client, the "Device Selection" dialog pops up every single time I open MTA. I'm using 2 monitors with the "extend displays" option. If you look at the image, the dropdown lists my graphics card twice, even though I only have a single GTX 950, not an SLI. I wouldn't actually mind clicking "OK" every time I start my client, but the fact that I always have to change the resolution as the default one in the dropdown is not the right one and the fact that sometimes it doesn't get into focus and it's behind every other window I have open, makes it a bit annoying. TL;DR is there a way to select my default device, rather than selecting it every time I start the client?
  22. Yes, it doesn't check if it's the same index or not. What you can do is check if the button is visible in the if statement with the selRow ~= -1 and only run it when it is not visible. Or you can also save the selInd into another variable (which is outside the onClientGUIClick handler) called something like lastIndex and compare the two indexes and only run the code when they are not the same.
×
×
  • Create New...