Lynch

Members
  • Content Count

    1,051
  • Joined

  • Last visited

Community Reputation

4 Neutral

1 Follower

About Lynch

  • Rank
    Hard-@ss
  • Birthday 30/06/2002

Details

  • Location
    Pakistan
  • Occupation
    Chick sexer
  • Interests
    Scripting

Recent Profile Visitors

1,383 profile views
  1. Lynch

    How to use multidimensional tables?

    Thanks a lot, @Patrick. Got the general concept as to how they can be implemented.
  2. I just found out that there's a way to store multiple values in a table. So, I planned to make a custom punish system with it. Stored three values in the table, a rule id, a description for what it is, and it's punishment. I'd like to know how can I implement these, for example, if i typed /punish [player] [id], it should automatically derive it's description and punishment from the table, and punish the player. (and output description in the chat) rules = { {["ruleID"] = "1", ["description"] = "Trash talking", ["punishment"] = "kick"} } Thanks.
  3. Lynch

    Custom mute system

    The code is written to mute the player upon spamming, which works fine, except that if a player quits the game, changes his nick, and joins again, he does get muted, but won't get unmuted. Also, if the player quits after being muted, and waits some time before joining back, he'll be forever muted again and won't get unmuted. Can't think of a way to fix this. Any help would be appreciated. mutedPlayerSerials = {} interval = 20000 addEvent("mutePlayer", true) addEventHandler("mutePlayer", root, function() local mutedPlayer = getPlayerName(source) local serial = getPlayerSerial(source) outputChatBox(mutedPlayer.." has been muted by console for spamming.", root, 255, 100, 100) table.insert(mutedPlayerSerials, serial) setPlayerMuted(source, true) setTimer(function() local serial = nil mutedPlayerSerials = {} local player = getPlayerFromName(mutedPlayer) if player then setPlayerMuted(player, false) outputChatBox(mutedPlayer.." has been unmuted by console.", root, 100, 255, 100) end end, interval, 1) end) mutedPlayer = false addEventHandler("onPlayerJoin", root, function() local serial = getPlayerSerial(source) for _, v in pairs(mutedPlayerSerials) do if serial == v then mutedPlayer = true break end end if mutedPlayer == true then local mutedPlayerName = getPlayerName(source) local mutedPlayer = getPlayerFromName(mutedPlayerName) setPlayerMuted(mutedPlayer, true) outputChatBox(mutedPlayerName.." has been muted by console.", root, 255, 100, 100) end end)
  4. Lynch

    Immortal Peds 0_0

    There's no such argument as 'immortal' in createPed. ped createPed ( int modelid, float x, float y, float z [, float rot = 0.0, bool synced = true ] ) It must be something else in your code which is making your ped invincible. Or it could be this issue, https://bugs.mtasa.com/view.php?id=8790.
  5. Lynch

    [HELP] Issue with tables

    Thank you once again @IIYAMA. Was really easy to understand this time. Solved.
  6. Lynch

    [HELP] Issue with tables

    I made three tables, local insults = {":O you", ":O off", "cry", "suck my :O", "pussy", ":O", "idiot", "whore", "dickhead", "mother:Oer", "your mom sucks", "bitch", ":Oer", "virgin", "peace of :~", "piece of :~", ":~ of peace", ":~ of piece", "retard", "gay :O", ":O", "gay :O", "gay", "dicksucker", "coward", "angry german kid", "kid", "agk", "asshole"} local answers = {"oki", "stfu", "kid", "tenks", "lol", "kiddy", "wow", "pff", "lmao", "noob", "omg"} local random = {"if i die tell my mom i love she", "omg my heart", "i miss you"} and stored some string values (insults) in it. Then, looped through them to find if a player said one of those in chat. It is supposed to work like this, if he said one of those in chat, then it would trigger functionA, but if he did not, that would trigger functionB. addEventHandler("onPlayerChat", root, function(message, messageType) if not messageType == 0 then return end if not isElementWithinColShape(source, colArea) then return end if not getElementData(tarek, "alive") == true then return end if getElementData(tarek, "rage") == true then return end for _, sMessage in pairs(insults) do if message == sMessage then functionA() else functionB() return end end end) But in this case, it triggered both functionA and function B. What each of these functions do, functionA: Checks if the player insulted the ped a certain number of times, and outputs ped's reaction according to that. (tarek = ped) If the player has not yet insulted a set number of times (end_time_value) then, it outputs something else. functionB: If the player did not say any value from the 'insults' table, then a random value from 'random' table will be outputed. function functionA() setTimer(function() local end_limit_value = 5 if getElementData(tarek, "limit_value") == tonumber(end_limit_value) then setElementData(tarek, "rage", true) setPedAnimation(tarek, "graveyard", "mrnf_loop") outputChatBox("#FFBC74Tarek: #FFFFFFgtfo kiddy", source, 255, 255, 255, true) playAgkRageSound() setTimer(function() outputChatBox("#FFBC74Tarek: #FFFFFFgod get a pussy you virgin :~ of peace", source, 255, 255, 255, true) end, 3000, 1) setTimer(function() outputChatBox("#FFBC74Tarek: #FFFFFFmother:Oer you mom dont want you", source, 255, 255, 255, true) setTimer(function() local x, y, z = getElementPosition(tarek) createExplosion(x, y, z, 6) createExplosion(x, y, z, 6) createExplosion(x, y, z, 6) killPed(tarek) setElementData(tarek, "alive", false) outputChatBox("Angry German Kid has exploded and killed you!", source, 255, 100, 100) setTimer(function() destroyElement(tarek) reviveTarek() setElementData(tarek, "rage", false) end, 20000, 1) end, 6000, 1) end, 2000, 1) return end outputChatBox("#FFBC74Tarek: #FFFFFF"..table.random(answers).."", source, 255, 255, 255, true) index = index + (index_value and 1 or -1) setElementData(tarek, "limit_value", tonumber(index)) end, 3000, 1) end function functionB() outputChatBox("#FFBC74Tarek: #FFFFFF"..table.random(random).."", source, 255, 255, 255, true) end Complete code; https://pastebin.com/hHQs3qZR The problem is with the loop, it does not output what is required, but outputs both of the functions at the same time. (Btw, this script is an *attempt* to create a clone of my friend. Pretty lame, but that's what it is) Any help regarding this would be really appreciated.
  7. Lynch

    [HELP] Case sensitive table

    So, if I derive values from a certain table and use those values to do something, they will always be case sensitive. How can I remove that? I don't want the values of the table to be case sensitive, For example, local values = {"Hi", "Hello", "Hey"} And if I detect if a player said one of these in chat by looping through them, it will work but only if the player typed the first letter capital. addEventHandler("onPlayerChat", root, function(message, messageType) if not messageType == 0 then return end for _, msg in pairs(values) do if message == msg then outputChatBox("Console: Hey!", source, 255, 100, 100) else return end end end) I heard string.gsub can do this but I'm not sure how to use that. Any help regarding this would be appreciated.
  8. Lynch

    [HELP] Issue with setting a ped's skin

    It worked like a charm @IIYAMA. Thank you. (Still figuring out how you did it)
  9. So, i created two buttons in a gui, '>' for 'next skin' and '<' for previous skin. But unfortunately, the code doesn't seem to work very well. Any help regarding this would be really appreciated. skin_btn_next = guiCreateButton(96, 273, 33, 16, ">", false, window) skin_btn_previous = guiCreateButton(58, 273, 33, 16, "<", false, window) function isSkinValid(skinid) local allSkins = getValidPedModels() for _, skin in ipairs(allSkins) do if skin == tonumber(skinid) then return true else return false end end end ped = createPed(0, -2614.0212402344, 1451.1651611328, 7.1875, 180) local skin = getElementModel(ped) local new_skin = skin + 1 local previous_skin = new_skin - 1 if source == skin_btn_next then if isSkinValid(new_skin) then setElementModel(ped, new_skin) else setElementModel(ped, new_skin + 1) end end if source == skin_btn_previous then setElementModel(ped, previous_skin) end (These are just the relevant parts of the script) Entire script; https://pastebin.com/aYydg3TX
  10. Lynch

    [HELP] GUI GridList

    Thank you very much @Mahlukat. Problem is fixed.
  11. Lynch

    [HELP] GUI GridList

    Wanted to fill up a grid list with locations that are specified in a table, based on a team that was selected in another grid list, but I can't seem to get it right. No errors in the debug. Any help regarding this would be appreciated. Thanks. addEventHandler("onClientGUIClick", resourceRoot, function(button, state) if button == "left" and state == "up" then local LALocations = {"LA Test 1", "LA Test 2", "LA Test 3"} local IFLocations = {"IF Test 1", "IF Test 2", "IF Test 3"} local row, col = guiGridListGetSelectedItem(team_gridlist) if row and col and row ~= -1 and col ~= -1 then local team = guiGridListGetItemText(team_gridlist, row, col) if team == "Liberation Army" then outputChatBox("Test successful", 100, 255, 100) for _, locations_LA in ipairs(LALocations) do local location_row_LA = guiGridListAddRow(location_gridlist) guiGridListSetItemText(location_gridlist, location_row_LA, location_col, locations_LA, false, false) end if team == "Imperial Forces" then for _, locations_IF in ipairs(IFLocations) do local location_row_IF = guiGridListAddRow(location_gridlist) guiGridListSetItemText(location_gridlist, location_row_IF, location_col, locations_IF, false, false) end end end end end end) Here's the complete client sided code; https://pastebin.com/NL7YfyZ4
  12. Lynch

    Issue with setTimer and onVehicleWeaponFire

    Thank you, the problem was resolved. I guess toggleControl can block bindKey.
  13. I wanted to shoot missiles with intervals of 5 seconds between them. Tried the following code, but it only works for the first or second time when shooting missiles, then it shoots like normal (no interval). Tried different ways but couldn't fix it. Any help regarding this? armedVehicles = {[425]=true, [520]=true, [476]=true, [447]=true, [430]=true, [432]=true, [464]=true, [407]=true, [601]=true} function vehicleWeaponFire(thePresser, key, keyState, vehicleFireType) local vehModel = getElementModel(getPedOccupiedVehicle(thePresser)) if (armedVehicles[vehModel]) then triggerEvent("onVehicleWeaponFire", thePresser, vehicleFireType, vehModel) end end function bindOnJoin() bindKey(source, "vehicle_fire", "down", vehicleWeaponFire, "primary") bindKey(source, "vehicle_secondary_fire", "down", vehicleWeaponFire, "secondary") end addEventHandler("onPlayerJoin", root, bindOnJoin) function bindOnStart() for index, thePlayer in pairs(getElementsByType("player")) do bindKey(thePlayer, "vehicle_fire", "down", vehicleWeaponFire, "primary") bindKey(thePlayer, "vehicle_secondary_fire", "down", vehicleWeaponFire, "secondary") end end addEventHandler("onResourceStart", getResourceRootElement(), bindOnStart) function stopMissileSpam() player = source toggleControl(player, "vehicle_secondary_fire", false) toggleControl(player, "vehicle_fire", false) setTimer(function() toggleControl(player, "vehicle_secondary_fire", true) toggleControl(player, "vehicle_fire", true) end, 5000, 1) end addEvent("onVehicleWeaponFire", true) addEventHandler("onVehicleWeaponFire", root, stopMissileSpam)
  14. Lynch

    [Help] givemoney

    function giveMoney(sender,command,name,amount) if not name or not amount then outputChatBox("Usage: #FFFFFF/givemoney [player name] [amount]",sender,255,0,0,true) return end local receiver = getPlayerFromName(name) if not receiver then outputChatBox("Couldn't find a player with the name #FFFFFF("..name..").",sender,255,0,0,true) return end local receiver = getPlayerFromName(name) if receiver == sender then outputChatBox("You can't give money to yourself.",sender,255,0,0) return end if not tonumber(amount) then outputChatBox("Please enter a valid value.",sender,255,0,0) return end local receiver = getPlayerFromName(name) local receivername = getPlayerName(receiver) local sendername = getPlayerName(sender) local sendermoney = getPlayerMoney(sender) if receiver and tonumber(amount) <= sendermoney then if (amount < 0) then return outputChatBox("Please select a positive number to send.", sender, 255, 0, 0) end takePlayerMoney(sender,amount) givePlayerMoney(receiver,amount) outputChatBox("You gave #FFFFFF"..receivername.." #00FF00$"..tonumber(amount)..".",sender,0,255,0,true) outputChatBox(""..sendername.." #00FF00gave you $"..tonumber(amount)..".",receiver,255,255,255,true) else outputChatBox("You don't have $"..tonumber(amount)..".",sender,255,0,0,true) end end addCommandHandler("givemoney",giveMoney)
  15. Lynch

    [Help] Custom Mute System

    Same problem persisting, muted player is muted if he reconnects, but doesn't get unmuted even after 'unmuted' message shows up. ('unmuted' message shows up twice as well).