-
Posts
156 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Ayush Rathore
-
For every player the icon will be same the below method will change the icon for your own mta game so you have to make your own F11 map script.
-
Please provide additional information and possibly a code excerpt so that we can assist you more effectively. Also, do not expect someone to create the script from start; pay someone.
-
[HELP] Send webhook on Discord using fetchRemote
Ayush Rathore replied to Dzardys's topic in Scripting
Firstly place your resource in acl as admin (bad practice but to test just do it) <group name="Admin"> <object name="resource.dt"></object> </group> I have named my resource "dt" now in server.lua place this sendOptions = { queueName = "Discord Test Queue", connectionAttempts = 3, connectTimeout = 5000, formFields = { username= "your webhook bot name", avatar_url= "", content= "Hello World" } } function callback(data, info) iprint( "Discord Message Sent:" .. " success:" .. tostring(info.success) .. " statusCode:" .. tostring(info.statusCode) .. " data:" .. tostring(data)) end fetchRemote( "your webhook url", sendOptions, callback ) Enjoy- 1 reply
-
- 1
-
It is a particle effect, you can see this link https://vincentgarreau.com/particles.js/ To make it you have to make a web browser on client side and load javascript. you can use the below link for help https://wiki.multitheftauto.com/wiki/Client_Scripting_Functions#Browser_functions
-
How do I make zombies spawn in specific locations
Ayush Rathore replied to oblivionosaka's topic in Scripting
You should read these links https://wiki.multitheftauto.com/wiki/Slothman/Zombies https://forum.multitheftauto.com/topic/20409-rel-zday-a-zombie-infestation-script/ -
You have to attach javascript and then attach it to lua for something to happen. Head to the below wiki link to make it work: https://wiki.multitheftauto.com/wiki/Client_Scripting_Functions#Browser_functions
-
If you are in server and scripts are not optimized fan speed will increase. try changing servers and see.
-
You should use folder as MTA when run the scripts it unzips the folder in to resource-cache folder so its does not matter.
-
What you can do is: On server side Make a temporary ped using event "wastedEvent". Make this ped have the same features of the player dieing (skin, rotation) etc. Make ped collison disabled. (makes ped free from damage from other elements) Set the alpha of player to 0 and make him froze. Perform the animation on the ped. Afterwards destroy ped and reset alpha on player respawn.
-
Client side local sounds = { [1] = "soundsMM/1.mp3", [2] = "soundsMM/2.mp3", [3] = "soundsMM/3.mp3", [4] = "soundsMM/4.mp3", [5] = "soundsMM/5.mp3", [6] = "soundsMM/6.mp3", [7] = "soundsMM/7.mp3", [8] = "soundsMM/8.mp3", [9] = "soundsMM/9.mp3", [10] = "soundsMM/10.mp3", [11] = "soundsMM/11.mp3", [12] = "soundsMM/12.mp3" }; local resourceRoot = getResourceRootElement(); local sound = nil addEvent("playSoundRound", true); addEventHandler("playSoundRound", resourceRoot, function(id) sound = playSound(sounds[id], false); end); function SayChatik() local meta = getSoundMetaTags(sound); local art = "Артист: "; local tag = "[Legends]"; outputChatBox("[Legends] Artist(s) or track: " .. meta.artist .. " " .. xuesosina1 .. ""); end; addEventHandler("onClientMapStopping", resourceRoot, SayChatik); Server Side local totalSounds = 12 -- change it when you change sound table in client side local resourceRoot = getResourceRootElement() function musicround() triggerClientEvent(root,"playSoundRound",resourceRoot,math.random(1,totalSounds)) end addEventHandler ("onRoundFinish", root, musicround) This will do the needful!
-
https://wiki.multitheftauto.com/wiki/GetVehicleUpgrades <- the function returnes a table and you cannot store it directly you have save the upgrade one by one. Another thing which i noticed that the syntax of GetVehicleUpgrades is wrong in your code and you have to pass only a vehicle in that function. Now to save you can use the below code local theVehicle = getPedOccupiedVehicle ( thePlayer ) local model = getElementModel(theVehicle) if(not theVehicle) then return end for i=0, 16 do local upgrade = getVehicleUpgradeOnSlot ( theVehicle, i ) if ( upgrade ) then setAccountData (account, "veh_"..model.."_"..i, upgrade) end end It is saving vehicle date per vehicle so you will not run in overwriting the data. Now there are 4 scenarios you have to look to successfully load and unload upgrades When player logouts if he is in the vehicle save the upgrade. When player quits if he is in the vehicle save the upgrade. When player logins if he is in vehicle load and apply the vehicle upgrade. if he is not in vehicle load and apply the upgrade when he enters the vehicle. Saving the vehicle data to account as soon as the player leaves the vehicle. Apart from upgrades there are many things you have to save like Vehicle Handling Color Door State Paint job Plate text Health Wheel State Locked If you are making a role play game the above list is the desired but you may skip it.
-
myfont = "default-bold" nametags_Root = getRootElement() nametags_ResRoot = getResourceRootElement(getThisResource()) nametags_Players = getElementsByType('player') nametags_Me = getLocalPlayer() nametag = {} local nametags = {} local sWidth,sHeight = guiGetScreenSize() local Nametags_Hide = false local Nametags_Scale = 0.36 local Nametags_Alpha_Distance = 30 local Nametags_Distance = 40 local Nametags_Alpha = 255 local Nametags_Text_Bar_Space = 1 local Nametags_Width = 50 local Nametags_Height = 20 local Nametags_Size = 0.45 local Nametags_Outline_Thickness = 1.2 local Nametags_Alpha_Diff = Nametags_Distance - Nametags_Alpha_Distance Nametags_Scale = 1/Nametags_Scale * 800 / sHeight local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} } local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} } local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} } function nametags.Create ( player ) if (player == nametags_Me) then return end nametags[player] = true end function nametags.Destroy ( player ) nametags[player] = nil end addEventHandler ( "onClientRender", nametags_Root, function() if getElementData(getLocalPlayer(), "state.hud") == "disabled" then return end for i,player in ipairs(nametags_Players) do if isElement(player) then setPlayerNametagShowing ( player, false ) if not nametags[player] then nametags.Create ( player ) end end end if Nametags_Hide then return end local x,y,z = getCameraMatrix() for player in pairs(nametags) do while true do if not isElement(player) then break end if getElementDimension(player) ~= getElementDimension(nametags_Me) then break end local px,py,pz = getElementPosition ( player ) local bx, by, bz = getPedBonePosition( player, 5 ) if processLineOfSight(x, y, z, px, py, pz, true, false, false, true, false, true) then break end local playerDistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz ) if playerDistance <= Nametags_Distance then --Get screen position local sx,sy = getScreenFromWorldPosition( bx + 0, by, bz + 0.4 ) if not sx or not sy then break end --Calculate our components local scale = 1/(Nametags_Scale * (playerDistance / Nametags_Distance)) local alpha = ((playerDistance - Nametags_Alpha_Distance) / Nametags_Alpha_Diff) alpha = (alpha < 0) and Nametags_Alpha or Nametags_Alpha-(alpha*Nametags_Alpha) scale = math.evalCurve(maxScaleCurve,scale) local textScale = math.evalCurve(textScaleCurve,scale) local textAlpha = math.evalCurve(textAlphaCurve,alpha) local outlineThickness = Nametags_Outline_Thickness*(scale) --Requirements local team = getPlayerTeam(player) local level = getElementData(player, "LV") or 0 local Reputation = getElementData(player, "Reputation") or "player" local r,g,b = getPlayerNametagColor(player) local offset = (scale) * Nametags_Text_Bar_Space/2 local playerName = getPlayerName(player) local imageSize = dxGetFontHeight ( textScale*Nametags_Size, myfont ) local lp = getElementData(player, "experience.rank") or "Newbie" local bitt = interpolateBetween(40, 0, 0, 255, 0, 0, ((getTickCount()) / 1300), "SineCurve") local isim = getPlayerName(player):gsub('#%x%x%x%x%x%x', '') --Draw our text dxDrawText ( isim.."", sx + 0.5*scale, sy - offset + 0.5*scale, sx + 0.5*scale, sy - offset + 0.5*scale, tocolor(0,0,0,255), textScale*Nametags_Size*1., myfont, "center", "bottom", false, false, false, true, true ) dxDrawText ( playerName.."", sx, sy - offset, sx, sy - offset, tocolor(r,g,b,255), textScale*Nametags_Size*1., myfont, "center", "bottom", false, false, false, true, true ) nameWidth = dxGetTextWidth ( playerName.."", textScale*Nametags_Size, myfont ) teamWidth = nameWidth if Reputation then -- dxDrawImage ( sx - math.max(nameWidth/2, teamWidth/2) - 40*scale, sy - 2*imageSize, 7*imageSize, 2*imageSize, ""..Reputation..".png" ) end end break end end end ) function nametagsCreate() for i,player in ipairs(getElementsByType"player") do nametags.Create ( player ) setElementData(player, "nametags", "enabled") end end addEventHandler('onClientResourceStart', nametags_Root, nametagsCreate) function nametagsCreateOnJoin() if source == nametags_Me then return end setPlayerNametagShowing ( source, false ) nametags.Create ( source ) end addEventHandler('onClientPlayerJoin', nametags_Root, nametagsCreateOnJoin) function nametagsDestroy() nametags.Destroy ( source ) end addEventHandler('onClientPlayerQuit', nametags_Root, nametagsDestroy) function math.lerp(from,to,alpha) return from + (to-from) * alpha end function math.evalCurve( curve, input ) if input<curve[1][1] then return curve[1][2] end for idx=2,#curve do if input<curve[idx][1] then local x1 = curve[idx-1][1] local y1 = curve[idx-1][2] local x2 = curve[idx][1] local y2 = curve[idx][2] local alpha = (input - x1)/(x2 - x1); return math.lerp(y1,y2,alpha) end end return curve[#curve][2] end function dxDrawColorText(str, ax, ay, bx, by, color, scale, font,alignX,alignY,clip, wordBreak, postGUI) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font,alignX,alignY,clip, wordBreak, postGUI) ax = ax + w color = tocolor(tonumber("0x"..string.sub(col, 1, 2)), tonumber("0x"..string.sub(col, 3, 4)), tonumber("0x"..string.sub(col, 5, 6)), 255) end last = e+1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font,alignX,alignY,clip, wordBreak, postGUI) end end This will do the needful.
-
You can make client side elements and using events update the visibility(create or destroy) of the element.
-
I know just run this and tell if your problem is solved
-
You can make use of Col Shapes
-
What is the control state for player blocking punches?
Ayush Rathore replied to Bean666's topic in Scripting
Please provide the important part of script -
For this you may use this little script --server side function reloadWeapon(weapon, ammo) if client then takeWeapon( client, weapon ) giveWeapon( client, weapon, ammo, true) end end addEvent("relWep", true) addEventHandler("relWep", resourceRoot, reloadWeapon) --client side local slots = { [5] = { aimDelay = 1000, }, [6] = { aimDelay = 1000, } } local canAim = true function hideRadar(player, slot, weapon, ammo, aimDelay) if slot == 0 then return end setPedWeaponSlot(player,0) canAim = false if ammo > 1 then if (not isPedDucked(player)) then setPedAnimation(player, "silenced", "silence_reload", aimDelay, false, false, false, false) end triggerServerEvent("relWep", resourceRoot, weapon, ammo) end setTimer(function() canAim = true end, aimDelay, 1) end function playerPressedKey(button, press) if (press) and button == "mouse2" then if canAim == false then cancelEvent() end end end addEventHandler("onClientKey", root, playerPressedKey) addEventHandler("onClientPlayerWeaponFire", root, function() local player = getLocalPlayer() local slot = getPedWeaponSlot(player) local weapon = getPedWeapon(player) local ammo = getPedTotalAmmo(player, slot) if (slots[slot]) then hideRadar(player, slot, weapon, ammo, slots[slot].aimDelay) end end)
-
After this you have to draw that render target also like this for index, info in ipairs(blips) do dxSetRenderTarget(MiniMap["RenderTarget"], true) local bx = info.x local by = info.y local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by) local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2)) local rot = findRotation(bx, by, playerX, playerY)-camZ local blipX, blipY = getPointFromDistanceRotation( (MiniMap_x+MiniMap["width"]+MiniMap_x)/2, (MiniMap_y+MiniMap_y+MiniMap["height"])/2, math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]- (MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)), rot ) local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX)) local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY)) local color = 255 dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,255,255,255)) dxSetRenderTarget() end dxDrawImage(MiniMap_x,MiniMap_y,MiniMap["width"],MiniMap["height"], MiniMap["RenderTarget"],0,0,0,tocolor(255,255,255,255)) And also you have a typo in dxDrawImage in tocolor. I fixed it.
-
[HELP] attempt to perform arithmetic on a nil value
Ayush Rathore replied to GLC's topic in Scripting
try this local KumarhaneTable = { markerPos = { {2241.845,1618.0186,1005.3,"cylinder", 1, 0, 0, 255, 255}, {2241.0264,1615.9229,1005.3,"cylinder", 1, 0, 0, 255, 255}, {2231.0354,1618.2883,1005.3,"cylinder", 1, 0, 0, 255, 255}, {2230.1758,1615.9615,1005.3,"cylinder", 1, 0, 0, 255, 255}, {2230.1707,1596.1257,1005.3,"cylinder", 1, 0, 0, 255, 255}, {2230.1282,1590.5557,1005.3,"cylinder", 1, 0, 0, 255, 255}, {2241.9907,1590.5559,1005.3,"cylinder", 1, 0, 0, 255, 255}, {2241.9663,1596.1257,1005.3,"cylinder", 1, 0, 0, 255, 255} }, deger = 10000000, hesap = getAccount("mert") } --[[local kumarhanecubo = createColCuboid(2179.8726,1659.6299,11.046875,17,38,5) function kumarhanecubohit(hitElement, matchingDimension) if (isElement(hitElement)) and (getElementType (hitElement) == "player") then setTimer(function() if getElementData(hitElement,"GuvenliBolge")~=true then triggerClientEvent (hitElement, "enableGodMode", hitElement) toggleControl (hitElement, "fire", false) toggleControl (hitElement, "next_weapon", false) toggleControl (hitElement, "previous_weapon", false) toggleControl (hitElement, "aim_weapon", false) toggleControl (hitElement, "vehicle_fire", false) setElementData(hitElement, "GuvenliBolge", true) end end,500,1) end end addEventHandler ("onColShapeHit", kumarhanecubo,kumarhanecubohit) function kumarhanecuboleave(leaveElement, matchingDimension) if (getElementType (leaveElement) == "player") then triggerClientEvent (leaveElement, "disableGodMode", leaveElement) toggleControl (leaveElement, "fire", true) toggleControl (leaveElement, "next_weapon", true) toggleControl (leaveElement, "previous_weapon", true) toggleControl (leaveElement, "aim_weapon", true) toggleControl (leaveElement, "vehicle_fire", true) setElementData(leaveElement, "GuvenliBolge", false) end end addEventHandler ("onColShapeLeave", kumarhanecubo,kumarhanecuboleave)--]] addEventHandler("onResourceStart",resourceRoot,function() for i, loc in ipairs(KumarhaneTable.markerPos) do local marker = createMarker(unpack(KumarhaneTable.markerPos[i])) setElementDimension(marker,62000) setElementInterior(marker,1) addEventHandler("onMarkerHit",marker,onMarkerHitForKumar) end createBlip(2192.1455,1677.2106,12.303028, 52, 1, 0, 0, 0,255,0,200 ) end) addCommandHandler("kumarhanetesting00",function() setAccountData(KumarhaneTable.hesap,"Sahip","Satılık") setAccountData(KumarhaneTable.hesap,"Zaman","Bilinmiyor") setAccountData(KumarhaneTable.hesap,"Ciro","Bilinmiyor") end) function onMarkerHitForKumar(player,md) if getElementType ( player ) == "player" and md then triggerClientEvent(player, "RuletPanel", getRootElement(getThisResource())) end end kumarhanepickup = createPickup (2194.8066,1668.5844,12.367188, 3, 1274) addEventHandler("onPickupHit", kumarhanepickup, function(player) if getElementType ( player ) ~= "player" then return end cancelEvent() local zaman = getAccountData(KumarhaneTable.hesap,"Zaman") or 0 local sahip = getAccountData(KumarhaneTable.hesap,"Sahip") local ciro = getAccountData(KumarhaneTable.hesap,"Ciro") or 0 local sahipmi = getAccountName(getPlayerAccount(player)) if zaman ~= "Bilinmiyor" then zaman = secoundsToDays(tonumber(zaman)-getRealTime().timestamp) end if ciro == "Bilinmiyor" then ciro = 0 end if sahip == sahipmi then triggerClientEvent(player, "KumarhanePanel", getRootElement(getThisResource()),sahip,zaman,ciro,true) else triggerClientEvent(player, "KumarhanePanel", getRootElement(getThisResource()),sahip,zaman,ciro,false) end end) function KumarhaneSatinAl() local sahip = getAccountData(KumarhaneTable.hesap,"Sahip") if sahip == "Satılık" then local para = getPlayerMoney(source) if para >= KumarhaneTable.deger then takePlayerMoney(source,KumarhaneTable.deger) setAccountData(KumarhaneTable.hesap,"Zaman",getRealTime().timestamp+86400*7) setAccountData(KumarhaneTable.hesap,"Sahip",getAccountName(getPlayerAccount(source))) setAccountData(KumarhaneTable.hesap,"Ciro",0) outputChatBox("#ffff00"..getPlayerName(source).." #ff7f00Adlı Oyuncu Kumarhaneyi 1 Haftalığına Kiraladı",root,255,0,255,true) end else outputChatBox("Kumarhane Daha Önceden Kiralandı",source,255,0,0,true) end end addEvent("KumarhaneSatinAl", true) addEventHandler("KumarhaneSatinAl", getRootElement(getThisResource()),KumarhaneSatinAl) function KumarhaneCiro(miktar,type) local ciro = getAccountData(KumarhaneTable.hesap,"Ciro") if ciro=="Bilinmiyor" then if type==true then setAccountData(KumarhaneTable.hesap,"Ciro",miktar) else setAccountData(KumarhaneTable.hesap,"Ciro",0-miktar) end else if type==true then setAccountData(KumarhaneTable.hesap,"Ciro",ciro+miktar) else setAccountData(KumarhaneTable.hesap,"Ciro",ciro-miktar) end end end addEvent("KumarhaneCiro", true) addEventHandler("KumarhaneCiro", getRootElement(getThisResource()),KumarhaneCiro) function KumarhaneGiveMoney(money) givePlayerMoney(source,money) end addEvent("KumarhaneGiveMoney", true) addEventHandler("KumarhaneGiveMoney", getRootElement(getThisResource()),KumarhaneGiveMoney) function KumarhaneTakeMoney(money) takePlayerMoney(source,money) end addEvent("KumarhaneTakeMoney", true) addEventHandler("KumarhaneTakeMoney", getRootElement(getThisResource()),KumarhaneTakeMoney) function KumarhaneCiroCek(miktar) local ciro = getAccountData(KumarhaneTable.hesap,"Ciro") local sahip = getAccountData(KumarhaneTable.hesap,"Sahip") local accountname = getAccountName(getPlayerAccount(source)) if ciro~="Bilinmiyor" then if accountname == sahip then if miktar <= ciro then setAccountData(KumarhaneTable.hesap,"Ciro",ciro-miktar) givePlayerMoney(source,miktar) triggerClientEvent(source, "KumarhanePanelGuncelle", getRootElement(getThisResource()),ciro-miktar) end end end end addEvent("KumarhaneCiroCek", true) addEventHandler("KumarhaneCiroCek", getRootElement(getThisResource()),KumarhaneCiroCek) setTimer(function() local zaman = getAccountData(KumarhaneTable.hesap,"Zaman") local sahip = getAccountData(KumarhaneTable.hesap,"Sahip") if sahip ~= "Satılık" then if zaman then if zaman < getRealTime().timestamp then setAccountData(KumarhaneTable.hesap,"Sahip","Satılık") setAccountData(KumarhaneTable.hesap,"Zaman","Bilinmiyor") setAccountData(KumarhaneTable.hesap,"Ciro","Bilinmiyor") outputChatBox("#00ffffKumarhane Satışa Çıktı Gidip Kiralayabilirsin (F6 > Kumarhane)",root,255,255,0,true) end end end end,15*60000,0) function secoundsToDays(secound) if secound then local value,state if secound >= 86400 then value = math.floor(secound/86400) if secound - (value*86400) > (60*60) then value = value.." gün "..math.floor((secound - (value*86400))/(60*60)).." saat" else value = value.." gün" end state = 1 else value = math.floor(secound/(60*60)).." saat" state = 2 end return value else return false end end Hope it corrected the error. -
Can you please elaborate more as your problem seems to be big. ?
-
FFS map loader only loads client side scripts and if you have made scripts which are server sided it wont work. ( My brother made a map long time ago and he also faced the same problem like yours ). I hope the answer gave you a clarity. ?
-
Using @Overkillz script Make a folder in resource directory named antiafk make three files: afk_c.lua, afk_s.lua, meta.xml in afk_s.lua paste: function kickPlayerFromServer() kickPlayer (source) outputChatBox(getPlayerName(source).." #ffffffhas been kicked by ANTI-AFK BOT",root,255,255,255,true) end addEvent("onkickPlayerFromServer",true) addEventHandler("onkickPlayerFromServer",getRootElement(),kickPlayerFromServer) in afk_c.lua paste: local afkTime = 30 --In Minutes local antiAFKkeys = {"accelerate", "vehicle_left", "vehicle_right", "brake_reverse"} --Check out more keys at https://wiki.multitheftauto.com/wiki/Key_names kickerTimer = setTimer(function() triggerServerEvent("onkickPlayerFromServer",localPlayer) end,afkTime*1000*60,1) function afkReset() resetTimer(kickerTimer) end do for i,key in ipairs(antiAFKkeys) do bindKey ( key, "down", afkReset ) end end in meta.xml paste this: <meta> <info author="OVERKILLZ" type="script" name="ANTI-AFK" /> <script src="afk_c.lua" type="client" cache="false" /> <script src="afk_s.lua" type="server" /> </meta> Now go to your server window and type refresh or refreshall and then type start antiafk
-
https://github.com/Bonsai11/Multigamemode this resource might help you as it deals with loading map script files for specific player ( only client sided but might give you an idea on how to do it). CCS_wrapper This resources handles the loading of map scripts. Only clientside scripts are supported. CSS_wrapper is what you are looking for !
-
In my opinion you can attach this table to the resource using setElementData(getResourceRootElement(getThisResource()),"texts",texts,false) -- keep this table client side and then you can get this table from anywhere on the server using getElementData(getResourceRootElement(getResourceFromName("resource")),"texts") -- client side and i think it will take less CPU but more ram.
-
First go to your mta sa directory by right clicking on short cut and clicking open file location and then open server/mods/deathmatch/resources/ Make a new folder named eab. In this folder make three files meta.xml, c.lua, s.lua. In c.lua paste in s.lua paste Now in meta.xml <meta> <info author="AlirezaPlus" description="Expire after blow" version="1.5" type="script" /> <script src="c.lua" type="client"/> <script src="s.lua" type="server"/> </meta> Now go to this server gui window and type start eab. This is how you will do it. ?