Jump to content

Tails

Members
  • Posts

    740
  • Joined

  • Days Won

    16

Everything posted by Tails

  1. Tails

    help

    local accName = getAccountName ( getPlayerAccount (player) ) Change player to hitElement addEventHandler ("onMarkerHit",marker,hitElement) Change hitElement to your function name You're also missing an end. function teleport (hitElement) local accName = getAccountName ( getPlayerAccount (hitElement) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then setElementPosition (hitElement,182.4287109375, 1451.6865234375, 33.012893676758) else outputChatBox ("# off!You are not admin.") end end addEventHandler ("onMarkerHit",marker,teleport) Also, put it server-side. Tip: type /debugscript 3 in-game, it'll tell you what's wrong with your code when you run it.
  2. Tails

    .

    This is what you're looking for: local maxPoints = 75 function onCmd(cmd, myPoints) local color = (255 / maxPoints) * myPoints local r,g,b = 255-color, 255, 255-color outputChatBox("You have "..myPoints.." points.", r, g, b) end addCommandHandler("setPoints", onCmd, false) It goes from white to green. You can easily modify it and take the math to use it in your code. I suppose it'll get a little more difficult if you want to go from say, purple to orange, but this is all I can do for you. Because math.
  3. Nothing was wrong with your code. It was just outputting it to the console. There's really no need for "if thePlayer and isElement(thePlayer) then" with onCommandHandler.
  4. In short: if isElementWithinColShape(source, hillAreaLV) then is probably what your old code needed.
  5. Yeah I understand. local bannedIds = { [16] = true, [17] = true, [18] = true, [39] = true, [40] = true, } local hillAreaLS = createColRectangle ( -905.5929, -2933.0986, 4000, 3500 ) local hillAreaSF = createColRectangle( -2994.09448,-1378.01746,2000,4900) local hillAreaLV = createColRectangle (-905.5929,602.33,4000,2500) function forcePlayerWeapon(prevId, curId) if isElementWithinColShape(source, hillAreaLV) then if bannedIds[curId] then outputChatBox("blocked explosives") setPedWeaponSlot(source, 0) end end end addEventHandler("onPlayerWeaponSwitch", root, forcePlayerWeapon) This seems to work for me fine when I'm in within the LV colshape. The getElementZoneName wasn't returning LV everywhere within your colshape. For the welcoming you can use something like: function welcomePlayer(hitElem, matchingDim) if getElementType(hitElem) == "player" and matchingDim then if source == hillAreaLS then outputChatBox("Welcome to Los Santos", hitElem) elseif source == hillAreaSF then outputChatBox("Welcome to San Fierro", hitElem) elseif source == hillAreaLV then outputChatBox("Welcome to Las Venturas", hitElem) local curId = getPlayerWeapon(hitElem) if bannedIds[curId] then setPedWeaponSlot(hitElem, 0) -- Switch player weapon if they have an explosive equipped end end end end addEventHandler("onColShapeHit", resourceRoot, welcomePlayer) Btw, for i, thePlayer in ipairs(getElementsByType("player")) do is unnecessary in your code and really really bad for your servers performance to do it on weapon switch. You can use 'source' which is the player for this function. Also, if you really want to block the player from firing their weapon then you probably want to do it client-side using: https://wiki.multitheftauto.com/wiki/On ... WeaponFire EDIT: Modified table back to how you had it, it is better because you don't have to loop through it. My mistake.
  6. Are you still using the colshapes? If you are then you can add this: local current = getPedWeapon(thePlayer) for _,id in ipairs(bannedIds) do if current == id then setPedWeaponSlot(thePlayer, 0 ) end end Do that on colshape hit. This forces the player to switch to fists if they had already equipped the explosives before they entered the colshape/zone. So since they'll enter and their not holding the exploves and the switch weapon event is in place then they shouldn't be able to switch back them.
  7. Exactly. Updated my post. Using getElementZoneName now even better.
  8. Something is wrong with the code you posted: slot == -- s8) --> Probably just a paste error and not your issue. Have you tried getZoneName with true at the end already? Something like this on switching weapons and/or onHitColshape: bannedIds = {16,17,18,39,40} local city = getElementZoneName(thePlayer, true) if city == "Las Venturas" then local slot = getPedWeaponSlot(thePlayer) for _,id in ipairs(bannedIds) do if slot == id then setPedWeaponSlot(thePlayer, 0) end end end outputChatBox("Welcome to "..city, thePlayer)
  9. Replace everything with this. The timer doesn't always match up perfectly with the server, though. Probably getTimerDetails or making everything client-side would be better so the timer would match up correctly. It's the best I can do for you for now. And, mores. Instead of begging constantly for every little change, why not put that effort in trying to fix it on your own? I was hesistant about replying again to this thread but this is the final thing I will post here unless you actually try and show some code (that indicates you've put some time and thought into) of your own. Good luck Some great learning material: https://wiki.multitheftauto.com/wiki/Main_Page https://en.wikibooks.org/wiki/Lua_Programming http://lua-users.org/wiki/TutorialDirectory http://luatut.com/crash_course.html Client: -->> -- This piece of code probably won't make a lot of sense to you. It replaces the original dxDrawText function to make it scale and fit on every resolution, so you don't have to worry about it. local osW, osH = 1024,768 -- Original screen width and height, do not change it unless you're trying to position dxDrawText's on your own screen then change this to your own resolution. local csW, csH = guiGetScreenSize() -- Client/player screen width and height local DrawText = dxDrawText function dxDrawText(...) arg[2], arg[3], arg[4], arg[5], arg[7] = arg[2]/osW*csW, arg[3]/osH*csH, arg[4]/osW*csW, arg[5]/osH*csH, (arg[7] or 1)/osW*csW return DrawText(unpack(arg)) end --<< local isTimerVisible = false function displayCounter() dxDrawText("Your vehicle will change in: "..count, 237 + 1, 644 + 1, 811 + 1, 685 + 1, tocolor(0, 0, 0, 255), 1.60, "default", "center", "center", false, false, true, false, false) -- background (shadow) dxDrawText("Your vehicle will change in: "..count, 237, 644, 811, 685, tocolor(255, 162, 0, 255), 1.60, "default", "center", "center", false, false, true, false, false) -- foreground end function showCounter(Time) if Time then count = Time counting = setTimer(function() count = count - 1 end,1000,count) if not isTimerVisible then addEventHandler("onClientRender",root,displayCounter) isTimerVisible = true end else if isTimer(counting) then killTimer(counting) end removeEventHandler("onClientRender",root,displayCounter) isTimerVisible = false end end addEvent("showCounter",true) addEventHandler("showCounter",resourceRoot,showCounter) Server: local Time = 15 -- Change this to your preferred time in seconds function onRoundStart(state) if state == "Running" then changeVeh() changeTimer = setTimer(changeVeh,Time*1000,0) elseif state == "PostFinish" or state == "TimesUp" or state == "EveryoneFinished" or state == "SomeoneWon" or state == "ResourceStopping" or state == "NoMap" or state == "LoadingMap" then if isTimer(changeTimer) then killTimer(changeTimer) end triggerClientEvent("showCounter",resourceRoot,false) end end addEvent("onRaceStateChanging",true) addEventHandler("onRaceStateChanging",root,onRoundStart) function onRacerWasted() outputChatBox(getPlayerName(source).." died.") triggerClientEvent(source,"showCounter",resourceRoot,false) end addEvent("onPlayerRaceWasted",true) addEventHandler("onPlayerRaceWasted",root,onRacerWasted) function changeVeh() for _,plr in ipairs(getElementsByType("player")) do if not isPedDead(plr) then triggerClientEvent(plr,"showCounter",resourceRoot,Time) local veh = getPedOccupiedVehicle(plr) local model = vehicleIDS[math.random(1,#vehicleIDS)] if veh and model and getPedOccupiedVehicleSeat(plr) == 0 then local x,y,z = getElementVelocity(veh) setElementVelocity(veh,x,y,z+0.05) local hp = getElementHealth(veh) setElementModel(veh,model) setElementHealth(veh,hp) end end end end
  10. Nice. I didn't know you could just add events from other resources like that.
  11. I can't really help you to get it exactly on 3, 2, 1, go, since you'd have to use the functions in the race script and I have no idea what they are or how to use them. Maybe someone else does. This should work as a fix though. All I did is add a timer to the entire function so it will start after 10 seconds. setTimer(function() setTimer( function() for _,plr in pairs(getElementsByType("player")) do local veh = getPedOccupiedVehicle(plr) local model = vehicleIDS[math.random(1,#vehicleIDS)] if veh and model and getPedOccupiedVehicleSeat(plr) == 0 then local x,y,z = getElementVelocity(veh) setElementVelocity(veh,x,y,z+0.05) local hp = getElementHealth(veh) setElementModel(veh,model) setElementHealth(veh,hp) end end end ,15000,0) end,10000,1)
  12. Tails

    weather script

    Put the time vars in your function like so: function nuclearWeather () local time = getRealTime() local hour = time.hour if (hour >= 1) and (hour <= 5) then setFarClipDistance( 70 ) setFogDistance ( 30 ) ........... When you put the time fuction outside the timer you'll only get the time once. You need to get it every time.
  13. An auto-whitelisting option would be nice.
  14. This will work for every player's vehicle on your server. Here's a list of ID's that you can use: https://wiki.multitheftauto.com/wiki/Vehicle_IDs Currently every ID is added to the table so it'll turn you in litterally anything like boats, planes, trailers.... vehicleIDS = { 602, 545, 496, 517, 401, 410, 518, 600, 527, 436, 589, 580, 419, 439, 533, 549, 526, 491, 474, 445, 467, 604, 426, 507, 547, 585, 405, 587, 409, 466, 550, 492, 566, 546, 540, 551, 421, 516, 529, 592, 553, 577, 488, 511, 497, 548, 563, 512, 476, 593, 447, 425, 519, 520, 460, 417, 469, 487, 513, 581, 510, 509, 522, 481, 461, 462, 448, 521, 468, 463, 586, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 485, 552, 431, 438, 437, 574, 420, 525, 408, 416, 596, 433, 597, 427, 599, 490, 432, 528, 601, 407, 428, 544, 523, 470, 598, 499, 588, 609, 403, 498, 514, 524, 423, 532, 414, 578, 443, 486, 515, 406, 531, 573, 456, 455, 459, 543, 422, 583, 482, 478, 605, 554, 530, 418, 572, 582, 413, 440, 536, 575, 534, 567, 535, 576, 412, 402, 542, 603, 475, 449, 537, 538, 570, 441, 464, 501, 465, 564, 568, 557, 424, 471, 504, 495, 457, 539, 483, 508, 571, 500, 444, 556, 429, 411, 541, 559, 415, 561, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503, 579, 400, 404, 489, 505, 479, 442, 458, 606, 607, 610, 590, 569, 611, 584, 608, 435, 450, 591, 594 } setTimer( -- initiate a timer function() -- create a function within the timer for _,plr in pairs(getElementsByType("player")) do -- loop through every player in the server local veh = getPedOccupiedVehicle(plr) -- get their vehicle if they have one local model = vehicleIDS[math.random(1,#vehicleIDS)] -- pick random value from the table if veh and model and getPedOccupiedVehicleSeat(plr) == 0 then -- check if veh and model are present and wether the player is the one driving it local x,y,z = getElementVelocity(veh) -- get the vehicle's current velocity setElementVelocity(veh,x,y,z+0.05) -- set its new velocity and add 0.05 to the z value. the z value means up and down local hp = getElementHealth(veh) -- get the vehicle's current health setElementModel(veh,model) -- change the vehicle's model setElementHealth(veh,hp) -- re-apply the vehicle's health end -- end if statement end -- close for loop end -- end the function ,15000,0) -- trigger function after 15000 milliseconds and 0 for infinite calls -- close timer. If you don't want the vehicles to retain their health remove these 2 lines: local hp = getElementHealth(veh) setElementHealth(veh,hp) It also makes your car jump slightly so the vehicles won't get stuck in the ground. If you don't want that remove these lines: local x,y,z = getElementVelocity(veh) setElementVelocity(veh,x,y,z+0.05)
  15. So, is there no other way then?
  16. Hi D&G, Take a look at this thread, it has all your answers in it in regard to scaling and making it fit on any resolution. Read my post especially, I explain exactly what's happening and why. https://forum.multitheftauto.com/viewtopic.php?f=91&t=94987
  17. Hello, I've tried many different things (including processLineOfSight) but it does not detect the marker element. It's going right through it. There's no problem with objects, though. Is there any way to detect markers with a mouse click? function pickupItem(button,state,_,_,x,y,z,clickedElem) if button == "left" and state == "down" and getKeyState("e") then if isElement(clickedElem) then if getElementType(clickedElem) == "marker" then outputChatBox("hit marker") end end end end addEventHandler("onClientClick",root,pickupItem)
  18. It just shows detected in Chrome and Opera but no flash player detected in-game. Does this not work for you? sW,sH = guiGetScreenSize() bW,bH = 640,360 Screen = createBrowser(bW,bH,false,false) function loadURL() loadBrowserURL(Screen,"https://www.youtube.com/watch?v=t60roHM1t7o") end addEventHandler("onClientBrowserCreated",Screen,loadURL) function drawBrowser() dxDrawImage((sW-bW)/2,(sH-bH)/2,bW,bH,Screen) end addEventHandler("onClientRender",root,drawBrowser) I'm pretty sure Youtube uses html5 now. So, Youtube shouldn't have to be a problem. When I load this: requestBrowserDomains({"get.adobe.com"}) function loadURL() loadBrowserURL(guiGetBrowser(Screen),"https://get.adobe.com/flashplayer/") end addEventHandler("onClientBrowserWhitelistChange",root,loadURL) addEventHandler("onClientBrowserCreated",guiGetBrowser(Screen),loadURL) The page says it's installed but that it's disabled, even though it's enabled in my settings. So yeah, I'm not sure either.
  19. As far as I know you can't really override hardcoded MTA commands. But you can do what you said and it won't cancel anything before cancelEvent() so you can still override it that way: function cmds(cmd) if cmd == "whois" then outputChatBox("hello",source) cancelEvent() elseif cmd == "whowas" then outputChatBox("bye",source) cancelEvent() end end addEventHandler("onPlayerCommand",root,cmds)
  20. Can you post the test resource? In the mean time try loading it with Youtube TV https://www.youtube.com/tv#/watch/video ... ?v=ID_HERE
  21. Don't worry about it anymore, I was being stupid. Instead of storing the eventHandlers, I'm now storing the dxDrawImage functions instead.
  22. Hello MTA scripters, I currently have a script where I need to render multiple images or rows based on the clients input. This is working fine but for some reason I can't seem to remove them, it keeps giving me: 'Expected function at argument 3 got boolean'. This is the first time I'm trying to store eventHandlers in a table. Maybe I'm missing something. Here's the code, the problem is on line 9. 'Expected function at argument 3 got boolean'. sr.item.render[i] = addEventHandler("onClientRender",root, function() dxDrawImage(182, 331+sr.item.height[i], 24, 25, "images/image.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) end ) function clearResults() for i in pairs(sr.item.render) do removeEventHandler("onClientRender",root,sr.item.render[i]) sr.item.render[i] = nil end end addCommandHandler("clear",clearResults)
  23. Be sure to update your server to the latest 1.5.2! This resource won't work on MTA 1.5.0
×
×
  • Create New...