Jump to content

LoPollo

Members
  • Posts

    353
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by LoPollo

  1. ok, sorry i didn't understand. I think you should keep track of the group as a separate element, instead of setting a player data. I'm not sure, i never used it, but createElement can be used to create an element right? create an element in which you store all the necessary data, if you really need an element. Another solution is to make a table that stores all the informations, it will be easier to manage also. local groups = { --["yourGroupName"] = { members = {somePlayer1, somePlayer2}, color = {255,255,255}, whatever = someValue }, } --member count of "yourGroupName" = #groups.yourGroupName.members
  2. Strange... but note, just in case there are other elements than spawnpoints that are considered "objects", it's better to check if the element is an object instead if it's a spawnpoint. I'm worried about a possible cause of this: maybe even getElementType returns object when processing spawnpoints? Since you are pratically already doing this with the names... maybe an idea could be using the data assigned? local curObj = getElementsByType ( "object" ) for i,objData in ipairs(curObj) do if string.find(getElementData( objData, "id"),"object") == 1 then --if the word "object" is the first word i.e. starts at first character local obj_name = getElementData( objData, "id") local row = guiGridListAddRow( objList ) guiGridListSetItemText( objList, row, objColumn, i .. ": " .. obj_name, false, true ) else --nope end end
  3. LoPollo

    counter

    If marty is right then you must assign the timer to a variable, and reset the counter variable to the default value (10 or 15, dunno) when the map start. Resetting the timer does nothing since it is build on the variable and not the timer itself, but it will "sync" the start time with the map start, so if you want reset the timer on new map start
  4. createTeam Why not use it? and what do you want to do with if (groupName) then outputChatBox(groupName.." is already an existing group", client, 255, 0, 0) return end ? Answer to you question: it's a data bound to the player, you are not passing the player in the first post. You are passing "group", is it a string or what?
  5. Mmmm they should be elements, which are NOT objects... also your code IS correct. Still it's easy to workaround i guess, get element type and check if it's actually an object: getElementType
  6. where do you set the member count of a group? post that block/function(s)
  7. I'm not sure if i understand correctly... but spawnpoints aren't physical objects that can be clicked >.> That's why it works with objects but not with spawnpoints, which are also custom elements.
  8. Events are really nice: they are so much helpful in most situation. Better performance, easier to script and understand. Also tables are a powerful tool. Also remember that using local with a variable gives a performance boost in lua. Try to use it every time it is possible. Also functions can be local... but i'm not used to write it in the scripts so i omit this, damn. Nobody is perfect Still have fun with scripting, good luck and if you have any doubt the wiki and internet are your best friend, followed by us that will help you at any specific question or problem PS: Reading too much is annoying (at least for me). It is much funnier trying already done script, and reading their codes trying to figure out how they work
  9. local objects = { {1337,23.15625,-5.677734375,3}, {1338,19.15625,-5.677734375,3}, {1339,15.15625,-5.677734375,3} } local parameters = { [1337] = {"data","data"}, [1338] = {"data1","data1"}, [1339] = {"data2",100} } function spawnLoot() for k,v in pairs(objects) do --this can also be reworked local id = v[1] v.obj = createObject(v[1],v[2],v[3],v[4]) v.col = createColCuboid(v[2],v[3],v[4],1.6,1.6,1.6) if v.obj then attachElements( v.col, v.obj, -0.7, -0.7, -0.5 ) setElementCollisionsEnabled( v.obj,false ) end setElementData( v.obj, tostring(parameters[id][1]), parameters[id][2] ) addEventHandler( "onColShapeHit", v.col, onColEnter ) addEventHandler( "onColShapeLeave", v.col, onColEnter ) end end addEventHandler ( "onResourceStart", resourceRoot, spawnLoot) function onColEnter( thePlayer, matchingDimension ) if matchingDimension then setElementData( thePlayer, "inLoot", true ) -- i don't get why not a single key outputChatBox("Data["..parameters[getElementModel( getElementAttachedTo( source ) )][1].."]: "..tostring(getElementData(getElementAttachedTo( source ), parameters[getElementModel( getElementAttachedTo( source ) )][1] ))) end end function onColLeave( thePlayer, matchingDimension ) if matchingDimension then setElementData( thePlayer, "inLoot", false ) end end I rewrote the whole parameter part, using tables. Knowing the index, also the object table and logic can be improved. I would like to know if one key wouldn't be easier... I also suggest to read the wiki about events bound to objects, since you are binding ALL to root. This is untested but it should work. NOTE: DO NOT SIMPLY COPY PASTE AND SAY BYE BYE: LEARN FROM EACH SCRIPT!!! have fun scripting
  10. LoPollo

    help

    Still you don't expalin what the problem is. Also the declarement and assignment of turfCol and hill is useless. And with the following instruction you retrieve ALL the radarareas/colshapes, not only what you created with this script. local allturfs = getElementsByType("radararea") local allcols = getElementsByType("colshape") Explain more what your problem is
  11. LoPollo

    help

    10 hours old... no replies. So i ask: can you explain better? i did not understand what's the problem. Also indent the code to make it more readable: it's annoying reading an end followed by a instruction that is more at right, like if it was an if or a loop
  12. Sure, i copied pasted it EDIT: nope i had in the clipboard the token of another app i tried to use for this, SO THE TOKEN WAS WRONG. But even after copying the correct token the problem is still here
  13. After updating to node.js 7.2.1 this error disappeared. The bot connects to MTA server, which shows: [2016-12-07 16:00:49] INFO: [Discord] Connected to localhost on port 8100 [2016-12-07 16:00:49] INFO: [Discord] Authentication successful [2016-12-07 16:00:49] INFO: [Discord] Bot isn't ready that bot isn't ready is due to this error that shows in CMD (launched the bot with node app.js), i guess: Bot false error: Error: Authentication failed Error: Authentication failed at WebSocket.websocket.onclose (C:\Program Files (x86)\MTA San Andreas 1.5\m ta-discord-bot-master\src\node_modules\discord.js\lib\Client\InternalClient.js:9 4:1122) at WebSocket.onClose (C:\Program Files (x86)\MTA San Andreas 1.5\mta-discord -bot-master\src\node_modules\discord.js\node_modules\ws\lib\WebSocket.js:446:14) at emitTwo (events.js:106:13) at WebSocket.emit (events.js:191:7) at WebSocket.cleanupWebsocketResources (C:\Program Files (x86)\MTA San Andre as 1.5\mta-discord-bot-master\src\node_modules\discord.js\node_modules\ws\lib\We bSocket.js:950:8) at emitNone (events.js:91:20) at TLSSocket.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9) Do i have configured something in the discord part wrong? Since the connection to MTA is done i think that i'm doing something wrong with the part of discord, but the Discord server id is correct (copy-paste from the app), also the channel name is correct. The token is correct for sure since it's copied-pasted too. No extra spaces inserted (actually none at all). The port is NOT forwarded since i thought (and i still guess) that's the port to connect to MTA server, since it's in localhost it doesn't need to be forwarded. Googling - discord.js auth failed - brings me nothing intresting
  14. LoPollo

    Help!

    I'm only a random viewer, but i can't understand what you are talking about. Can you post a screenshot of the message the game provides you? Or tell us the step you do to get the message? Otherwise explain what "free base" means. If it mean hosting as @CJcrew suggested, then maybe this page is what you were looking for (keep in mind that these are not the only ones)? PS: if you were searching for hosting, then also wrong section Since we're in map maybe you are searching a specific map? but the game won't redirect to forum for this... Explain pls
  15. I don't understand this error. Isn't the syntax correct??? PS: i'm running Win7, just so you know
  16. well the error says all: markers[source][1] is not a table. markers[source] is a table, maybe you want that? i don't know exaclty what it contains so it's just a guess
  17. I only tested if the function works with a windows elements, before i thought that it would only work with text in the "body" of a gui, like buttons. I don't have much time and so usually i can't test the a whole script.
  18. My PC freezed so i wasted a lot of time, but the error occurred when i replaced the constant strings ("logVal" and "passVal") with the js: document.getElementById("login").value (added also the divs) EDIT: so you solved the issue double id... didn't noticed but i was near so i had no fun resolving this. i hate you. lol
  19. I (over)simplified your code @iPrestege, and this is working: <html> <head> <meta charset="UTF-8"> <title>MTA Arabs Login</title> <script> function aCall(command){ var login = "logVal"; var password = "passVal"; mta.triggerEvent("aOnCallMtaEvent", login, password, command); } </script> <link rel='stylesheet prefetch' href='http://fonts.googleapis.com/css?family=Open+Sans:600'> <link rel="stylesheet" href="css/style.css"> </head> <body> <div class="login-form"> <div class="group"> <input type="submit" class="button" value="Press me, i'm a button" onclick=aCall("login")> </div> </div> </body> </html> function aHTML ( login,password,command ) outputChatBox( login.." "..password.." "..command ) end addEvent("aOnCallMtaEvent", true) addEventHandler("aOnCallMtaEvent", root, aHTML) local screenWidth, screenHeight = guiGetScreenSize() local page = "http://mta/"..getResourceName( resource ).."/index.html" local initBrowser = guiCreateBrowser(screenWidth/4, screenHeight/4, screenWidth/2, screenHeight/2, true, false, false) local theBrowser = guiGetBrowser(initBrowser) addEventHandler("onClientBrowserCreated", theBrowser, function() loadBrowserURL(source, page) showCursor(true) end ) When i press the button i get the 3 values i requested. Now i'm going to add your other code till problem happens
  20. I'm going to do tests... but html has no body tag?
  21. @Necktrox can you tell me how to use the bot? I know it's node.js (right?), npm to install, but then when i have to configure i have no idea what to do. BTW nice job! @specahawk you made a great work too! Much more than most people in the community can achieve (including me) i'm hoping in a relase!
  22. I think than an example may give an idea. This is the serverside. IT'S ONLY AN EXAMPLE; PLUS IT'S UNTESTED. THERE MAY BE ERRORS AND MISSING THINGS local playersVotes = {} --playersVotes.player = 1 or 2 (see below) or whatever, event true, false and nil can be used local poll = {} --poll.question, poll.answers[1 or 2 or some index, up to you] (poll.answers is a table) addEvent( "onClientVote", true ) --when clients make vote, they will trigger this event --! --! @brief Starts a poll. --! --! @param playerSource The player who started the poll, the one who typed /k q; a1; a2(;) --! @param cmd The command --! --! @return None. But it will let players know that a poll is started using onPollStart --! function startPoll( playerSource, cmd, ... ) --infos about ... and arg are available here: https://www.lua.org/pil/5.2.html if poll.question ~= nil then --or poll ~= {}, or similar. Make sure every poll request while a poll is ongoing is ignored local splitSeparator = "; " local argTable = split( table.concat(arg," "), splitSeparator) --recreate the full line with concat, then separate question from the 2 answers using split if #argTable < 3 then outputChatBox("Not enough arguments supplied") else --unpack can also be used if you want. Fill the poll infos poll.question = argTable[1] poll.answers = { argTable[2], argTable[3] } triggerClientEvent( root, "onPollStart", resourceRoot, poll.question, poll.answers ) --Clients! The poll is started! poll.timer = setTimer( endPoll, 30*1000, 1 ) --end the poll end else outputChatBox( "A poll is already ongoing!", playerSource, 255, 0, 0 ) --yes client, you got ignored :P end end addCommandHandler( "k", startPoll ) --! --! @brief Triggered from clients when they vote. --! --! @param theVotedAnswer The index of the answer the client has chose --! --! @return None. But will trigger onVoteUpdate to let players know the vote each answer has after each vote is made --! function handleClientVote(theVotedAnswer) --pass the index of the answer, you can pass nil to remove the vote local thePlayer = client --easier to read lol, everyone has its own style playersVotes.thePlayer = theVotedAnswer --keep track of the vote triggerClientEvent( root, "onVoteUpdate", resourceRoot, countVotes() ) --count them and let the players know the count end addEventHandler( "onClientVote", root, handleClientVote ) --! --! @brief Counts the number of votes each answer has. --! --! @return A table: [1] number of votes for first answer, [2] number of votes for second answer. --! function countVotes() local votesCount = {} for thePlayerWhoVoted,theVotedAnswer in pairs(playersVotes) do --assuming theVotedAnswer is the index 1 or 2, as Descrition says votesCount[theVotedAnswer] = votesCount[theVotedAnswer] + 1 --sum all votes end return votesCount end --! --! @brief Called when a poll ends. Reset to default the variables --! --! @return None. But triggers onPollEnd to the clients, informing them about the results --! function endPoll() --Here players will get the gui hidden/disabled/whatever you need. Makes them unable to vote. --Also inform them with the result of the poll. Remember that's a table with 1 and 2 as index triggerClientEvent( root, "onVoteUpdate", resourceRoot, countVotes() ) triggerClientEvent( root, "onPollEnd", resourceRoot ) poll = {} playersVotes = {} end -- --In clientside, you must implement: --onPollStart -> show the gui --onVoteUpdate -> update votes, so players know how poll is going and which answer is "winning" --onPollEnd -> disable the gui, players MUST NOT vote anymore. Hide completely the gui after some time if you decide only to disable it to let the results be shown there -- I tried to explain as much as i could, let me know if you have doubts or questions. If you want to work on the already existing script, we're still here. If you want to rewrite it, this can help you with the start.
×
×
  • Create New...