Jump to content

Citizen

Moderators
  • Posts

    1,803
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by Citizen

  1. Citizen

    Any Proplem

    No. Learn more about events here: https://wiki.multitheftauto.com/wiki/Event @Amot: You used single quotes quotes instead a double quotes (it's not the same, see the syntax highlighting) outputChatBox("You Now Take Job Killer", client ) It was working, it's just you couldn't see it. Why did you use onClientPlayerDamage instead of onPlayerWasted ?? Client: Use the same code you did Server: local team1 = createTeam( "team1", 0, 255, 0 ) addEvent( "SetPTeam", true ) addEventHandler( "SetPTeam", root, function( ) setPlayerTeam( client, team1 ) giveWeapon( client, 31, 500 ) outputChatBox("You Now Take Job Killer", client) end ) addEventHandler ( "onPlayerWasted", root, function( attacker ) if getPlayerTeam( source ) == getTeamFromName( "team1" )then local x, y, z = 10, 15, 2 --change or remove if defined somewhere else spawnPlayer( source, x, y, z, 0, getElementModel(source)) end end ) And stop spamming, as said Bonsai or you will effectively get banned.
  2. I just didn't saw your posts.
  3. Citizen

    Radar blip

    Yeah ok, it's just because the code you stole was designed for a circular radar. And in this code, the author used this lines of code to prevent blip icons going outside the radar: local dist = getDistanceBetweenPoints2D(px, py, bx, by) if dist > range then dist = tonumber(range) end (range is defined on top of the script to 100) so just remove that lines to let our code (math.min and math.max on the blip position) prevents them (the blips) to go outside the radar.
  4. Ok so first we aren't our slaves, there is a proper way to ask for help which is not dropping the code and write the error (that you didn't completly wrote by the way). If you weren't that lazy, you would read in the error output that the function warpPedIntoVehicle was expecting an element at the 2nd argument and that he got nil instead. It just means veh variable doesn't exist at all ... functions you need to fix this: tonumber createVehicle Nothing else. NOTE: You should have been seen this basic function in the first tutorial on the wiki. Thing you didn't read apparently: https://wiki.multitheftauto.com/wiki/Scr ... troduction EDIT: Ok so it looks like some people doesn't really care to be treated as dogs/machines/slaves over here and the veh variable should be local.
  5. Citizen

    Mute Problem

    Same question to you ... Why didn't you wrote your code according to myonlake's post ? Your code is just confusing Jade. Your code should look like what WhoAmI wrote just because it's exactly what myonlake suggested and that it's a way better than your triggers. (Why ? Just because element datas are synced between the two sides and you can use that element data everywhere else on the client side where you need it)
  6. Citizen

    Radar blip

    Can you please rewrite this in english please ? Then what shows the red arrow ? Not my fault, you were supposed to give the radar height to my math.min for the Y axe and by that I mean only the height of the image being rendered: blipX = math.max(posX, math.min(posX + width/scale, blipX)) --pretty sure u need to do that too for the X blipY = math.max(posY, math.min(posY + height/scale, blipY))
  7. It will, but only in specific case. That's why your code shouldn't be used because it's dirty (duplication of code: draw1, draw2 ..; not removing event handler before adding another etc). So please dont.
  8. He already fixed the problem (by doing code duplication )
  9. Citizen

    Radar blip

    Well idk which bug it is but I already can see one: local blipX = (posX+(width/2))+cblipx-(blipsize/2) local blipY = (posY+(height/2))+cblipy-(blipsize/2) local blipX = math.max(posX, math.min(posX + width, blipX)) local blipY = math.max(posY, math.min(posY + height, blipY)) You are creating these local variables twice, which is forbidden. local blipX = (posX+(width/2))+cblipx-(blipsize/2) local blipY = (posY+(height/2))+cblipy-(blipsize/2) blipX = math.max(posX, math.min(posX + width, blipX)) blipY = math.max(posY, math.min(posY + height, blipY)) (I removed the local keywords on line 4 and 5). This bug is now fixed and the two variable will still be locals variables.
  10. Citizen

    Radar blip

    Well it wasn't what you asked us for. I thought you already did the math part. Well I would say you need to find the ratio of you map file (probably by watching the difference between what returns getElementPosition, your position on the default map get the position (pixels) to be at the same place of your map file) Note: the pos: 0, 0 is the middle of the map. The part above has to be done outside of the radar script. To get the ratioX and ratioY (should be equal if the map is a square, and it should be). Once you got them (and I suppose your map file is 3000x3000 pixels): local mapImgWidth, mapImgHeight = 3000, 3000 local ratioX, ratioY = --[[value here]], --[[value here]] local x, y = getElementPosition(localPlayer) local tempMapX, tempMapY = x*ratioX, y*ratioY --the position in pixels on your map file ( with the middle of this file as origin (0, 0) ) local mapX, mapY = tempMapX + mapImgWidth/2, tempMapY + mapImgHeight/2 --the position in pixels on your map file ( with the upper left corner of this image as origin (0, 0) ) --so now we have the real position in pixels, we draw the the map: dxDrawImageSection(radarX, radarY, radarWidth, radarHeight, mapX - mapWidth/2, mapY - mapWidth/2, mapX + mapWidth/2, mapY + mapWidth/2, "images/map.png") Please read and try to understand that code (also tell me if it works ^^). This code will only draw the right part of the map according to the player position (btw, ratioX and ratioY have to be correct). And the player is always in the center of the radar. Once you got that, you can easily calculate the blips positions aswell. But I won't give you the code because it's currently taking me too much time. EDIT: Damn it ! You stole code while I was writing. Which is making my big post almost useless ... np. I can't test it (I mean I don't have enough time for that). What's the problem ?? (details explaination + screens if needed)
  11. Citizen

    Radar blip

    You just have to calculate the pos like every others blip but before you render em, just verify if the position is out of the rectangle. If it is then replace the pos by the max. And do the reverse for the min pos they can have on the screen. local blipX = --some maths here to calculate the absolute X position of the blip local blipY = --some maths here to get the calculate Y position of the blip --for the X axe if blipX < radarX then blipX = radarX end --left side if blipX > radarX + radarWidth then blipX = radarX + radarWidth end --right side --for the Y axe if blipY < radarY then blipY = radarY end --top side if blipY > radarY + radarWidth then blipY = radarY + radarWidth end --bottom side --render everything For better performance, you can use elseif instead of two if in a row as I did (was a bit lazy ) We also can replace the if statements I did by using math.min (I'm writing it so check my post later, I just let you with the if version atm). EDIT: Here is the version with math.min and math.max: local blipX = --some maths here to calculate the absolute X position of the blip local blipY = --some maths here to get the calculate Y position of the blip blipX = math.max(radarX, math.min(radarX + radarWidth, blipX) blipY = math.max(radarY, math.min(radarY + radarHeight, blipY) I didn't tested it but I hope I didn't made mistakes in this version
  12. Citizen

    I need help

    I'm agree with pa3ck. the local keyword has nothing to do with mysql nor MTA. It's from the Lua language (Lua ~= MTA). By the way, we need the code that loads the vehicles from database. This is where you have to get and set the power of the vehicle or call the loadPower(veh)
  13. local currentDrugs = getElementData(localPlayer, "drugs") or 0 setElementData(localPlayer, "drugs", currentDrugs + 1)
  14. First wrong reply I think I got it: replace this: pro = getElementData(localPlayer, "Drugs") by this: pro = getElementData(localPlayer, "Drugs") or 0
  15. Citizen

    I need help

    No. You have to get the data from the database (using the a query) and store the result in power (so remove it from your function arguments and the query should executed before the setVehicleHandling You also have to add the argument veh to know which vehicle you want to load the power of. local vehID = getElementID(veh) local power = mysql:query_free("SELECT power INTO vehicles WHERE id="..vehID) So you shall not call this function with the onResourceStart event but right after the vehicle has been created (in the function that loads all vehicles from the database).
  16. Use /drugs and it won't be nil anymore
  17. Sorry to say that but you didn't helped him, you just renamed the variable player into playerV which is totally pointless. Plus, you didn't renamed player into playerV for the outputConsole so you are just breaking his function. The real solution was to send localPlayer (which is the same as getLocalPlayer()) with the trigger: triggerServerEvent ( "onWheelInstall", getLocalPlayer(), getLocalPlayer()) or triggerServerEvent ( "onWheelInstall", localPlayer, localPlayer ) Another solution (the best one) is to use the implicit variable source into the function: function advan_racingv2 () if isPedInVehicle ( source) then local theVehicle = getPedOccupiedVehicle ( source ) local success = addVehicleUpgrade ( theVehicle, 1080 ) if success then outputConsole ( " Se ha instalado nuevas llantas.", source) else outputConsole ( "No se pudo instalar nuevas llantas.", source) end else outputConsole ( "Nesecitas estar en un vehiculo!", source) end end addEvent( "onWheelInstall", true ) addEventHandler( "onWheelInstall", getRootElement(), advan_racingv2 )
  18. Nope, it will do the same. @CodeLewis: check if the function toggleEditor has arguments. Maybe you can specify the player to show it. Otherwise, modify that function to do so. Huh? Why would it? hitElement is the element that has entered the marker, I don't get it why would it be the same. Yeah my bad, forgot we were on the client side
  19. Nope, it will do the same. @CodeLewis: check if the function toggleEditor has arguments. Maybe you can specify the player to show it. Otherwise, modify that function to do so.
  20. Two reasons: 1 - You didn't created the timers yet. 2 - They already have been killed (so you probably killing them twice). and I would suggest you to use google translate. It would probably help us to understand you better.
  21. I was exactly writing that your code didn't make any sense since it was triggering ALL the ranks ! And not the current player rank. You first need to get the current player rank (i dunno where you are saving that data, but i would suggest an element data). Once you got the rank (the string version) then you loop the table usranks (in your loop, therank will hold the rank he gets from the table. So at 1st loop, therank will be "[1]PVT" then for the 2nd loop, it will be "[2]PFC" and so on.) then your condition inside the loop will be: if playerRank == therank then --where playerRank is the current rank of the player you got from getElementData and not: if therank == usranks[i] then because they both are the same because the loop is doing usranks to set the value of therank. Hope it's more clear.
  22. Show us what you tried first ...
  23. Citizen

    Help

    You have to save somewhere (database for exemple) that the player X is muted untill Y (Y means a datetime, for example a timestamp). When a player join/login again, you will check if the current datetime is older or not that the datetime you saved for that player. If it's older, just don't do anything (he is already unmuted) otherwise, mute him and call a timer that will unmute him in milliseconds.
  24. Like this ? function basla() setTimer(isik, 1000, 3) --will execute isik each 1000 milliseconds but only 3 times end function isik() local playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then setVehicleOverrideLights ( playerVehicle, 1 ) end end
×
×
  • Create New...