Jump to content

Hex547

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by Hex547

  1. Hexadecimal has no limit to the amount of characters. In this case the HEX strings are 2 characters long, and there's a string of 3 or 4 depending on if Alpha is included. Each 2 character string is 0-F with A-F representing the numbers 10-15. By translating this you can convert HEX into more readable numbers by multiplying each individual character by 16 to the power of the digit representing how far it is from the last character, like so: FA F = 15, A = 10 F = 15*(16^1) = 240 A = 10*(16^0) = 10 F+A = 250. Now, colours are often represented by a 0-255 value (00-FF in HEX) because a single byte of data (2^ can represent a value anywhere from 0 to 255, depending on the bits.
  2. This is pretty ambiguous as to what you need help with. Please read the subforum rules before posting, they prohibit posts like these. viewtopic.php?f=91&t=47897
  3. If the int is an actual int, and the database table reflects that, then it should not be within quotes. That would be throwing errors. But considering your naming conventions, that's probably not the case. If they are all set as varchars then I don't see any problems with the SQL, without some errors to go on, and especially without verifying the "notify" function is created properly, it's hard to say. It may be worth trying to change "int" to something else, as it may be protected and causing errors, but that's just a long shot guess, I don't know if it would apply to LUA.
  4. The weapon can only target 1 person at a time, I'd imagine. You're better off creating a colshape around the weapon of the desired radius, then catching only the elements within the colshape, verify they're humans, then make a function that will select one of them, start firing, catch their death, and signal it should stop firing and move on to the next target. Also, be distrustful of the MTA commands regarding weapon firing. My first ever script in MTA was a shooter mod with all types of guns attached to vehicles, it went really well, and I made the first proper version in about 6-8 hours, but I found that most of the weapon functions are useless. Want to fire the gun? Use createProjectile. For it to work effectively, every thing needs to absolutely synced with the server, so it's always in the same position on everyone's screen, facing the same direction, and firing more or less the same amount. To do this I caught when the player started/stopped pressing down on the fire button, and then just used timers to iterate automatic fire.
  5. for index = 1, 8 do local top = topTable [ index ] dxDrawText ( "\n\n\n\n\n#FF0000".. tostring ( index ) ..". #FFFFFF".. tostring( top.name ), x-245, ( 20 * index ), 250, 120, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, true, false ) dxDrawText ( "\n\n\n\n\n"..tostring ( top.data ).." #ff0000wins", x-50, ( 20 * index ), x-15, 40, tocolor(255, 255, 255, 255), 1.00, "default-bold", "right", "top", false, false, true, true, false ) end Here you aren't checking to see if topTable is actually populated with results before trying to find index's. Also you should check to make sure each index garners a result as well before attempting to get the .data and .name from it. Also I don't see the events you're creating every being triggered in the scripts, which is obviously your own deal, but topTable is only populated through the first event, so if you're never triggering it, you'll never be able to get anything from it. Other than that it looks OK, good luck!
  6. Hex547

    Radians

    Your original question as to why the code with math.rad created the circle was answered. The question of why radians is used is a lot simpler; the creator of LUA decided the mathematical functions should and would use radians rather than degrees, degrees are easier for a person to understand/remember, 0 is north, 90 is east, 180 is south, 270 is west, easy, but people don't want to remember 1.57079633 is east, 3.14159265 is south, 4.71238898 is west, because that's a lot of long complex numbers, however for a computer which can do the calculation relating to pi that gives a radian value, since 2pi = 1 circle, radians are probably more logical. With modern systems, whatever the programming justification the actual saved time is probably so miniscule you could run the differences a million times and barely see a few ms difference overall. It may also have to do with the fact that if using degrees, for precise measurements someone may round to keep the number an int, whereas with radians, it's going to be a float at least unless you want to round so much that you may as well give it a random number anyway.
  7. Hex547

    Radians

    cos and sin in LUA take radians as arguments, when you convert the i to radians first the math functions give the proper results because... Well, because that's the proper way to use it, so you get proper results. 1 radian is 57.296 degrees. Consider that the sin/cos functions are expecting basically 1/57th of the value you're inputting. This means the result is hard to pin down because of the fact that after reaching 360, sin/cos essentially reset and treat that as new 0. At the 7th degree, you're already over a full revolution in radians. The oval is because of the ratio between radians and degrees, if you were to * the i by 6.28318531 which is the conversion rate for 1 circle in degrees to 1 circle in radians, you would essentially be reaching the new 0 every time it went around, with a small addition proportional to the difference, but there's no other reason to do this than to change the number you * i by to watch the ratios of the oval change. If you want a proper circle, just convert to radians the normal way like you have. I don't really know any other way to explain why the oval is an oval other than that, and that isn't particularly in depth, so I don't know if that's of any help (interest) to you.
  8. if health > 0 then return, really? Return if they're alive? That doesn't seem very productive. local health = math.ceil(getElementHealth(localPlayer)) if health > 0 then dxDrawImage(x*Tlargura, y*Taltura, largura, altura, "health/"..(math.ceil(getElementHealth(localPlayer)/5)*5)..".png" ) end This code will do what the previous 20 iterations of elseif's was meant to do, and the only compromise is changing the health/05.png file to health/5.png.
  9. Make sure the line local sound = nil is present at or near the top of the code, before any conditions, and also remove the function you got from Dealman, instead add sound = playSound("File.mp3") inside the first if statement somewhere, and don't forget to change the filename to your mp3.
  10. Hi there, Dealman referred you to me, I am his mentor, and I spotted your problem right away! Your problem lies in the fact your source can never be stopbutton because it's within the if statement whereby to get to that state it must be start button. In short/english: you need to put the "stopsound" else/if one level down by putting and end just before it. Hope this helps.
  11. Dope, I think you've misunderstood how this community works. There aren't "fully authorised plugins" that get spread around from a main source. Plenty of sub-communities hosting MTA servers make their own plugins, or get ones they find others have made, and customise them. The plugin creation process for MTA is extremely easy. A bright person with no programming experience could pick it up and create something decent within a couple days, someone with programming experience can jump into MTA and make something unique and interesting in hours. Now, I understand that you may make revenue through ads, or your clients make their revenue through your ads, and when someone hotlinks your data you miss out on that, or they do. But coming onto here to ask who's doing it is honestly pointless, anyone could have made it, even someone who isn't registered onto this forum. As for trying to "make it more efficient", there's nothing wrong with the functions. It's just someone's made a plugin, used your links, and may not have used the function as efficiently as possible. But it may be worth noting, servers can't send data easily after connection unless it's packaged into the original resource but held back from immediate downloading, ie, a server can't download your stream and then redistribute the data to all the clients itself as need be. It's just not designed for that.
×
×
  • Create New...