Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by Gtagasje

  1. I think he means when 1 player spawns a new vehicle, all the old vehicles get deleted, instead of just the one of the player who spawned a second vehicle. If this is the case, you should make a table which keeps track of all the vehicles that have been spawned and link the player ID (thePlayer) with the vehicle in the table. This way you can later destroy only the vehicle of the player it was linked to.
  2. As far as I know there is no way to play videos of any sort ingame.
  3. On the wiki there is an example which should do what you want. https://wiki.multitheftauto.com/wiki/GetPlayerPing function kickPing() -- Creates a function called kickPing for i, player in ipairs(getElementsByType("player")) do -- Loop every player if (getPlayerPing(player) >= 500) then -- If their ping is over 500 kickPlayer(player, "Ping over 500!") -- Kick them end end end setTimer(kickPing, 5000, 0) -- Every 5 seconds, the kickPing function is called.
  4. I meant, what you are doing is when the player hits the marker, you check the "vehicles" data and the "Occupation" data of that marker, and if they're equal, you continue the function. But when you create the marker, you only set the "vehicles" data to the corresponding role (v.role) and you don't set the "Occupation" data anywhere(as far as I can see.) This would mean that when you try and get their data's, "vehicles" would return the correct role, and "Occupation" would return nill thus the function discontinues. So what I did was checking the "vehicles" data of the marker, and the "Occupation" data from the player, so if the player has the job the marker spawns vehicles for, the function continues, and otherwise it doesn't. Your script doesn't check the job of the player anywhere.
  5. You need the "onClientGUIClick" event
  6. local Marker = createMarker(v.mx, v.my, v.mz, "cylinder", 1.5, v.mr, v.mg, v.mb) setElementData(Marker, "vehicles",v.role) Are you even setting the marker "Occupation" data to the correct job? Because it seems like you mean to check the occupation of the player, and not the marker. In that case you should use this local Marker = createMarker(v.mx, v.my, v.mz, "cylinder", 1.5, v.mr, v.mg, v.mb) setElementData(Marker, "vehicles",v.role) addEventHandler("onClientMarkerHit", Marker, vehicleMarkerHit) function vehicleMarkerHit(hitElement) if hitElement == localPlayer then if getElementData(source, "vehicles") == getElementData(localPlayer, "Occupation") then guiSetVisible(window[1],true) showCursor(guiGetVisible(window[1])) end end end
  7. Gtagasje


    You should use the following functions if you want to do that (serversided script) getPlayerAccount() -- Retrieve the player's account setAccountData() -- Set an account data key to a value to check if the player has joined before or not getAccountData() -- When the player logs in, check his account data to see if he has joined earlier or not (the key you set with setAccountData "onPlayerLogin" -- The event to trigger the checking if the player has joined before or not and if not set his account data to a value that he has joined and is not new.
  8. If I read it right on the wiki, getVehicleController will check forwards in the 'towing chain' if the vehicle you're checking does not have a driver. So it should still return true because you're driving the towtuck which is forwards in the chain. (If that makes sense.) So you could use this local myshape = createColCircle(1049.6279296875, -1029.674804687, 4) function ColHit(hitElement) if getElementType(hitElement) == "vehicle" then if not getVehicleOccupant(hitElement) then destroyElement(hitElement) end end end addEventHandler("onColShapeHit", myshape, ColHit)
  9. If you want to disable damage in interiors you can just use these: "onClientPlayerDamage" -- Triggers when a player is damaged getElementInterior() -- Check if the player is in an interior or outside(interior 0) cancelEvent() -- If yes, cancel the damage Make sure this script is clientside.
  10. function raceConsider(thePlayer, cmd) if thePlayer and cmd and cmd == "gorace" then -- It was activated by command else -- It was not activated by command if getPlayerCount() >= 1 and raceActive["aktivs"] == false then raceActive["aktivs"] = true setTimer ( needRaceGUI, 5000, 1) outputChatBox("DEBUG:[1]", root, 255, 255, 0) end end end addEventHandler ( "onPlayerJoin", getRootElement(), raceConsider ) addCommandHandler("gorace", raceConsider)
  11. You could check the tick count when the player starts driving, and then while his speed is lower than 101 you check if his speed is 100, incase that's true, you break the loop and check the tickcount again. Something like this function getElementSpeed(element,unit) -- From the wiki, [url=https://wiki.multitheftauto.com/wiki/GetElementSpeed]https://wiki.multitheftauto.com/wiki/GetElementSpeed[/url] if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.8 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end --Start these when the player starts driving while getElementSpeed(player) < 2 do if getElementSpeed(player) == 1 then curCount = getTickCount() end end while getElementSpeed(player) < 101 do if getElementSpeed(player) == 100 then newCount = getTickCount() break end end speedupTime = (newCount - curCount)/1000 (I've never used while loops though, so I'm not 100% sure whether or not it works.)
  12. Regarding the trains, you could attach a colshape to the train which sticks out a little on the train (longer, not wider) and when the player hits that colshape you could kill it. createColRectangle() -- Create the colshape attachElements() -- Attach it to your train "onColShapeHit" -- Serversided event, triggered when a player hits a colshape killPed() -- Kill the player
  13. I've never done anything with the race gamemode nor looked at it, but I think you can just remove the countdown and instantly trigger the function that starts the next map. So you would have to select a random map yourself (instead of letting the people select one by triggering the select function) and then start that one.
  14. I'm not sure if this would work (don't have time to test it) but you could atleast try it. local charTable = {["\\"] = true, ["|"] = true, ["/"] = true, ["@"] = true, ["#"] = true, ["~"] = true, ["!"] = true, ["\""] = true, ["$"] = true, ["%"] = true, ["&"] = true, ["("] = true, [")"] = true, ["["] = true, ["]"] = true, ["="] = true, ["?"] = true, ["+"] = true, ["-"] = true, ["*"] = true, ["."] = true, ["'"] = true} if newNick:find("%W") and not charTable[newNick:find("%W")] then Basically you add all the allowed characters in a table, and then check that if a non-alphanumerical character is found and it's not in the table then you cancel it.
  15. If you mean you want to do that for every sql insert you do, you could use this perhaps. Keep in mind that the old value can't be a player element for example, if you want it to be a player's name you should send the name of the player with the function, and not the player element. function setSQLData(column, oldvalue, newvalue) local dbname = "YOUR DATABASE NAME HERE" -- Fill in the database name local column, oldvalue, newvalue if type(column) == "string" then if type(oldvalue) ~= "string" then -- Make sure everything is a string oldvalue = tostring(oldvalue) end if type(newvalue) ~= "string" then -- Idem newvalue = tostring(newvalue) end local sh = executeSQLQuery("SELECT * FROM ?? WHERE ? = ?", dbname, column, oldvalue) -- Check if the entry already exists if #sh == 0 or not sh then local ih = executeSQLQuery("INSERT INTO ??(?) VALUES(?)", dbname, column, newvalue) -- Nope, insert it return ih else local uh = executeSQLQuery("UPDATE ?? SET ? = ? WHERE ?", dbname, column, newvalue, oldvalue) -- Yes, update it return uh end else return false -- Woops, the column name you provided is not a string end return false end
  16. Regarding the memo, "onClientGUIChanged"
  17. You could just retrieve all the players again, it'll clear the table and then send you all the players which are still in the lobby.
  18. function getLobbyPlayers() local lobbyPlayers = {} for i,v in ipairs(getElementsByType("player")) do if getElementData(v, "YOUR ELEMENTDATA HERE") == YOUR VALUE HERE then table.insert(lobbyPlayers, v) end end return lobbyPlayers end local numberOfPlayers = #getLobbyPlayers() -- This is the amount of players in the lobby local playersInLobby = getLobbyPlayers() -- This is a table with all the players in the lobby
  19. Wops, totally overlooked that, never used that function, ignore my script. ._.
  20. function commitSuicide(thePlayer, cmd) if not getElementData(thePlayer, "suicide") then setElementData(thePlayer, "suicide", true) seconds = 10 suicideTimer = setTimer(function(thePlayer) if seconds > 1 then seconds = seconds-1 else killPed(thePlayer) killTimer(suicideTimer) setElementData(thePlayer, "suicide", false) end end, 1000, 0, thePlayer) else outputChatBox("#FFFF00[ADMIN BOT]You are already attempting to suicide! Please wait!", thePlayer, 255, 0, 0, true) end end addCommandHandler("suicide", commitSuicide) setTimer(function() for i,v in ipairs(getElementsByType("player")) do if getElementData(v, "suicide") then if getPedMoveState(thePlayer) ~= "stand" and getPedMoveState(thePlayer) ~= "crouch" then if isTimer(suicideTimer) then killTimer(suicideTimer) setElementData(v, "suicide", false) outputChatBox("#FF0000[ADMIN BOT]You attempted to move! Suicide cancelled!", v, 255, 0, 0, true) end end end end end, 50, 0) Try that
  21. If you want a quicker version, you could use this(it's up to you though, maybe you prefer the easier to understand one) mine_pos = { {271.94140625, 1350.1923828125, 10.5859375}, {275.94140625, 1350.1923828125, 10.5859375}, } mineplace = createMarker(unpack(minepos[math.random(#mine_pos)])) This will only work if you keep the arrays x, y, z coordinates only though.
  22. You could make a little script using these functions: setTimer() setTime()
  23. killSecondTimer = setTimer(function() if killSeconds = 1 then killTimer(killSecondTimer) return end killSeconds = tonumber(killSeconds)-1 exports["TopBarChat"]:sendClientMessage("#FF0000You will die in #00FF00"..killSeconds.."#FF0000 seconds", 255, 255, 255, true) end, 1000, 0) Try that, didn't test it though.
  24. guiSetEnabled ( element guiElement, bool enabled )
  25. You could use a virtual machine I think. I don't know where to get one though.
  • Create New...