Jump to content

Lpsd

Administrators
  • Posts

    317
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Lpsd

  1. Okay. But why are you using httpdownloadurl?
  2. Why you are using downloadFile? Also if the files/resources are on the same server as the MTA server, you don't need httpdownloadurl.
  3. You'd have to contact your host and find out. You could also ask them for your server usage stats on bandwidth, RAM and CPU. Also, you can try using the in-game performance browser to see how much CPU and RAM each resource is using on your server. You can start this with 'start ipb' edit: Are you using any custom script to handle downloading resources?
  4. Lpsd

    Indicator system

    Line 35,36 and 62,63: killTimer(IdicatiorTimer) setVehicleOverrideLights(car, 1) You're killing the timer straight after it's been created. Maybe it'd be better to make the indicators toggle, so you press them once to turn it on, and press again to turn off. Didn't test but it should work. You'll have to fix indentation as the code editor here isn't the best. addEventHandler("onPlayerJoin", root, function() bindKey(source,"[", "down", leftIndicator) bindKey(source, "]", "down", rightIndicator) end) addEventHandler("onResourceStart", resourceRoot, function() leftIndicatorStatus = {} rightIndicatorStatus = {} for i, v in ipairs(getElementsByType("player")) do local playerName = getPlayerName(v) bindKey(v, "[", "down", leftIndicator) bindKey(v, "]", "down", rightIndicator) leftIndicatorStatus[playerName] = false rightIndicatorStatus[playerName] = false end end) function leftIndicator(thePlayer) local playerName = getPlayerName(thePlayer) if leftIndicatorStatus[playerName] == false then if isPedInVehicle(thePlayer) then car = getPedOccupiedVehicle(thePlayer) if getPedOccupiedVehicleSeat(thePlayer) == 0 then leftIndicatorStatus[playerName] = true IdicatiorTimerLeft = setTimer( function() setVehicleOverrideLights(car, 2) if getVehicleLightState(car, 0) == 0 then setVehicleLightState(car, 0, 1) setVehicleLightState(car, 1, 1) setVehicleLightState(car, 2, 1) setVehicleLightState(car, 3, 1) else setVehicleLightState(car, 0, 0) setVehicleLightState(car, 1, 1) setVehicleLightState(car, 2, 1) setVehicleLightState(car, 3, 0) end end, 50, 0) end end else if isTimer(IdicatiorTimerLeft) then killTimer(IdicatiorTimerLeft) setVehicleOverrideLights(car, 1) leftIndicatorStatus[playerName] = false end end end function rightIndicator(thePlayer) local playerName = getPlayerName(thePlayer) if rightIndicatorStatus[playerName] == false then if isPedInVehicle(thePlayer) then car = getPedOccupiedVehicle(thePlayer) if getPedOccupiedVehicleSeat(thePlayer) == 0 then rightIndicatorStatus[playerName] = true IdicatiorTimerRight = setTimer( function() setVehicleOverrideLights(car, 2) if getVehicleLightState(car, 1) == 0 then setVehicleLightState(car, 0, 1) setVehicleLightState(car, 1, 1) setVehicleLightState(car, 2, 1) setVehicleLightState(car, 3, 1) else setVehicleLightState(car, 0, 1) setVehicleLightState(car, 1, 0) setVehicleLightState(car, 2, 0) setVehicleLightState(car, 3, 1) end end, 50, 0) end end else if isTimer(IdicatiorTimerRight) then killTimer(IdicatiorTimerRight) setVehicleOverrideLights(car, 1) rightIndicatorStatus[playerName] = false end end end
  5. Who hosts your server? What bandwidth does the server have? Do other players experience this issue? Some extra information would be nice, we aren't magic
  6. local WeaponNames = { [16] = "Nade", [24] = "One Deag" } function getWeaponRealName(weapon) if weapon then if WeaponNames[weapon] then return WeaponNames[weapon] else return getWeaponNameFromID(weapon) end end end
  7. Take time to carefully look through what you wrote, you messed up all the syntax. Here's how it should be: if (getElementData (getLocalPlayer (), "zombie") ~= true) and ( isPedDead ( getLocalPlayer () ) == false ) and (getElementModel(getLocalPlayer()) ~= 293) and (getElementModel(getLocalPlayer()) ~= 294 ) then Also don't use 'or', use 'and' When you want to add a new skin, add this onto the end of the 'if' statement: and (getElementModel(getLocalPlayer()) ~= 294 ) change '294' for the skin id
  8. The closest I can find on the community page is this: https://community.multitheftauto.com/index.php?p=gallery&s=show&pic=7023 You should be able to find out how he got the players to sit in the wheelchair by looking at the code. Otherwise to create your own system, you're going to need the following: setPedAnimation, (set the player animation, to be sitting down) getElementPoisiton (find out the position of the chair object) setElementPosition (set the player position, to the same position as the chair, you might need to offset player position slightly to make it look better) setElementFrozen (when the player is sitting, set them frozen, when not, unfreeze them)
  9. Any errors when using `debugscript 3`?
  10. A simple Google search for 'kick player mtasa' brings up the official wiki as the first result, kickPlayer There's even an example code right on the same page. function kickPlayerHandler ( sourcePlayer, commandname, kickedname, reason ) -- Get player element from the name local kicked = getPlayerFromName ( kickedname ) -- If the client who sent the command has a higher level if ( hasObjectPermissionTo ( sourcePlayer, "function.kickPlayer" ) ) then -- Kick the player kickPlayer ( kicked, sourcePlayer, reason ) end end -- Add the "kick" command handler addCommandHandler ( "kick", kickPlayerHandler ) Usage: /kick player reason
  11. Lpsd

    help with tables

    Let me suggest an easier way to insert into the table in the first place. -- table invitations = {} local playerName = getPlayerName(player) -- get the player's name invitations[playerName] = { player, team } --store info about player and team, key = playerName Now later on in your code, you can remove entries from the table like so: table.remove(invitations, playerName) --table.remove(table, key) Better than looping through all entries imo.
  12. Didn't work, however I solved it myself using the original code I posted. Stopped destroying the colSphere element, onColShapeHit Set 'pickup' variable to nil after destroying it with destroyElement Added a check to see if "pickup" exists onColShapeHit destroyElement doesn't "destroy" the variable, just the element in the game, so you have to reset it. local x = 3985.1799316406 local y = -1973.4870605469 local z = 27.812973022461 pickup = createPickup(x, y, z, 3, 1242) -- create custom pickup pickupCol = createColSphere ( x, y, z, 1) -- create colSphere for pickup function removePickup() if (pickup) then destroyElement(pickup) -- destroy pickup pickup = nil setTimer(function() pickup = createPickup(x, y, z, 3, 1242) end, 5000, 1) -- spawn new pickup and colsphere after 5 seconds end end addEventHandler ( "onColShapeHit", pickupCol, removePickup )
  13. I'm trying to create a custom pickup which gets destroyed when a player touches it, and respawns after 5 seconds I've created the custom pickup using "createPickup", and also placed a colSphere (using "createColSphere") at the same position. When the player hits the pickup for the first time, it disappears and respawns successfully 5 seconds later. However, after it has respawned once, it won't destroy again when you touch it. My code is below. local x = 3985.1799316406 local y = -1973.4870605469 local z = 27.812973022461 pickup = createPickup(x, y, z, 3, 1242) -- create custom pickup pickupCol = createColSphere ( x, y, z, 1) -- create colSphere for pickup function removePickup() destroyElement(pickup) -- destroy pickup destroyElement(pickupCol) -- destroy pickup colsphere setTimer(function() pickup = createPickup(x, y, z, 3, 1242) pickupCol = createColSphere ( x, y, z, 1) end, 5000, 1) -- spawn new pickup and colsphere after 5 seconds end addEventHandler ( "onColShapeHit", pickupCol, removePickup ) Any thoughts? edit: I did try using the respawnTime argument on createPickup, for 5 seconds, but it didn't have any effect, which is why I'm trying to do it this way. No errors returning either.
  14. Really nice resource been using it as a starting point for something I'm working on. Nice work
  15. Yeah that works perfectly now, I'd missed changing the "." to ":" by mistake
  16. Weird, nothing changed with that either. Maybe it's the way I'm calling it, by doing "getMain.checkStars(source)" Edit: Yep, it was. server.lua: theFunctions = {} function theFunctions:checkStars(thePlayer) local wantedLevel = getPlayerWantedLevel ( thePlayer ) -- get the wanted level of the player return wantedLevel end return theFunctions other .lua file in same directory: require("server") -- no need to put in variable local gotStar = theFunctions:checkStars(source) -- use table name with function in
  17. Literal facepalm. I don't know why I'd put it like that. I tried this however and still no luck: theFunctions = {} function theFunctions.checkStars(thePlayer) local wantedLevel = getPlayerWantedLevel ( thePlayer ) -- get the wanted level of the player return wantedLevel end return theFunctions
  18. Worked by changing to "dataresult[1]['skin']" etc instead of just "dataresult['skin']" Thanks
  19. I've got this simple require code, and in my console it's returning as a boolean, instead of returning with the function ready to use server.lua: function checkStars(thePlayer) local wantedLevel = getPlayerWantedLevel ( thePlayer ) -- get the wanted level of the player return wantedLevel end theFunctions = { "checkStars" } -- list of functions available for other files, returned when using "require" return theFunctions Another .lua file, in the same directory: getMain = require("server") function getStars(quitType) local gotStar = getMain.checkStars(source) end addEventHandler ( "onPlayerQuit", getRootElement(), getStars ) And the error from console: ERROR: xml2\serverLogin.lua:4: attempt to index global 'getMain' (a boolean value) I know this means the file either isn't being loaded (false), or for some reason "theFunctions" isn't being returned. Any thoughts?
  20. I have the following, which just gets "skin", "cash" and "wasWanted" from the DB function spawnOnLogin () playerName = getPlayerName(source) local findPlayer = dbQuery(db, "SELECT `skin`, `cash`, `wasWanted` FROM player_stuff WHERE name=?", playerName ) local dataresult = dbPoll ( findPlayer, -1 ) if dataresult[1] then local skin = dataresult["skin"] local cash = dataresult["cash"] local wasWanted = dataresult["wasWanted"] end end addEventHandler("onPlayerJoin", getRootElement(), spawnOnLogin) the variables "skin", "cash" and "wasWanted" all come back nil, since I can't work out the right way to get the result. Been looking for ages but can't find the right way to do it, can someone explain to me how I retrieve these values from the query result properly? Thanks
  21. @Citizen my bad. I also just read the author's post again and realized I hadn't understood he wanted
  22. Put your dbExec inside the for loop
  23. local tentItensTable = { {"Assault Rifle"}, {"Motorcycle"}, } for i, data in ipairs(tentItensTable) do itens = getElementData(thecol,data[i]) end --[[ saving line --]] dbExec(thedatabase, "INSERT INTO bau_obj (col1, col2, col3, col4, col5, col6, col7, col8, col9) VALUES (?,?,?,?,?,?,?,?,?)", numeros, modelo, x, y, z, rx, ry, rz, itens) --[[ saving line --]] Looks like I'm gonna have to doublepost since I can't edit my original reply. This might work, but I'm not entirely sure how Lua handles for loops. Also note the SQL query change, first you tell it which rows the VALUES are going into. So change 'col1', 'col2' etc with the corresponding rows in your database table.
  24. This might work, but I'm not entirely sure how Lua handles for loops. Also note the SQL syntax change m, you'll need to feed it the right values where you've got (?,?,?,?,?) Edit: sorry the code quote messed up. I'm on mobile with 1% battery ?
  25. Can't edit my post, oops, doublepost! Here's an updated version which is more efficient, instead of creating a star object for wanted players every 5 seconds, we'll check if the star exists first. Also, the other one didn't delete the star once you weren't wanted anymore, so that's fixed. starSpawned = 0 function wanted() local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do -- use a generic for loop to step through each player local wantedLevel = getPlayerWantedLevel ( thePlayer ) -- get the wanted level of the player if starSpawned == 0 then wantedpickup = createObject( 1247, 0, 0, 0, i, d ) starSpawned = 1 end if ( wantedLevel > 0 ) then x, y, z = getElementPosition(thePlayer) i = getElementInterior(thePlayer) d = getElementDimension(thePlayer) setObjectScale(wantedpickup, 0.5) attachElements( wantedpickup , thePlayer, 0, 0, 1.5 ) -- we can use the z offset here to put it above the player else -- get the elements attached to the vehicle local attachedElements = getAttachedElements ( thePlayer ) -- loop through the table of elements for i,v in ipairs ( attachedElements ) do -- detach the element from the vehicle detachElements ( v, thePlayer ) destroyElement(v) starSpawned = 0 end end end end addEventHandler("onResourceStart",getRootElement(),function() setTimer(wanted, 1000, 0) -- when the resource starts, run every 5 seconds end) -- assume that there exists a collision shape named 'policeStation' function addWantedLevel ( player, command, level ) setPlayerWantedLevel ( player, level ) -- set the player's wanted level to 6 stars outputChatBox ( getPlayerName ( player ) .. " entered the police station!" ) end addCommandHandler("cops", addWantedLevel) -- command to give yourself a wanted level, /cops <1-6>
×
×
  • Create New...