Jump to content

Lpsd

MTA Team
  • Posts

    339
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by Lpsd

  1. 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
  2. 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
  3. 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
  4. 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)
  5. Any errors when using `debugscript 3`?
  6. 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
  7. 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.
  8. 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 )
  9. 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.
  10. Really nice resource been using it as a starting point for something I'm working on. Nice work
  11. Yeah that works perfectly now, I'd missed changing the "." to ":" by mistake
  12. 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
  13. 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
  14. Worked by changing to "dataresult[1]['skin']" etc instead of just "dataresult['skin']" Thanks
  15. 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?
  16. 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
  17. @Citizen my bad. I also just read the author's post again and realized I hadn't understood he wanted
  18. Put your dbExec inside the for loop
  19. 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.
  20. 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 ?
  21. 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>
  22. 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 ( wantedLevel > 0 ) then x, y, z = getElementPosition(thePlayer) i = getElementInterior(thePlayer) d = getElementDimension(thePlayer) wantedpickup = createObject( 1247, x, y, z, i, d ) attachElements( wantedpickup , thePlayer, 0, 0, 1.5 ) -- we can use the z offset here to put it above the player end end end addEventHandler("onResourceStart",getRootElement(),function() setTimer(wanted, 5000, 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> Here you go. See if you can make sense of this, it's pretty simple.
  23. Just spent some time testing everything, got it to work but as you said, "tesztTable2" is overwriting "tesztTable", not appendind to it. I'd just suggest using a library like http://viremo.eludi.net/LuaXML/ - it comes with append functions, so you can just read in data, add to it, and save it again, much easier than what you're using at the moment.
  24. Check my updated reply also. This resource should require general.ModifyOtherObjects, because it is editing files outside of its own, in another resource. I'm not sure why you aren't receiving errors about it, I loaded this up and had lots of errors, especially about the ACL
  25. Don't know if you've already crossed this bridge, but have you given ACL rights for "ModifyOtherObjects" on this resource? Also check line 3, 4, 5 in your original reply (shown below) outputDebugString(rootNode, 1) -- rootNode doesn't exist yet rootNode = xmlLoadFile(path) outputDebugString(rootNode, 1)
×
×
  • Create New...