Jump to content

Kazafka

Members
  • Posts

    143
  • Joined

  • Last visited

Everything posted by Kazafka

  1. Thank you, but I resignated And as a map? I couldn't save it as a map, because I have one. I'll rather make just a pay-n-spray
  2. Here you have the whole function: addEventHandler("onPlayerConnect", root, function(nickname) for k, v in ipairs(playersT) do if(nickname ~= v) then local size = #playersT local i = size + 1 -- playersT[i] = nickname --Add new player to bank moneyT[i] = "0" --Set new player's bank aco:O value to "0" -- outputChatBox("#09ff00Your account has been added!", player, 255, 255, 255, true) end end end) I'll try that Oh yeah That started working That started working thank you! TOPIC TO CLOSE! Jesus, now I know, how small knowledge I have 'bout programming! 'gain, thanks!
  3. But, I want to do something like, if connected player's nick isn't already in the table "playersT", then add the nickname.
  4. Just nothing thats the case I want to add something into this table after player connect, and if players nick isnt already in this table
  5. Wrote script 3 times, script thinks, that table "playersT", wich's empty, is the same as not empty string. --Table playersT = {} --Code addEventHandler("onPlayerConnect", root, function(nickname) for k, v in ipairs(playersT) do if(nickname ~= v) then --some code end end end) It's just keep not working. I RE-WROTE WHOLE SCRIPT 3 TIMES!
  6. Nah bro, I have a special function for table.size(theTable), but it says that it tries to preform arithmetic on a nil value on line 13, I don't know why bro. On line 12* You know what's funny? That the table.find(table, "word") isn't working the whole time! But I tought that it will work, 'cause I have a special function for that! Anyways, I'm trying now to figure out to make depositing money to bank working Gimme time please 'K! Finally! It started working But the point is, that I need to test another way to deposit money to bank. This way depends on, if you don't have a bank account yet!
  7. Attempt to do arithmetic on a nil value. And the code is: --Here you have the tables playersT = {"VaporZ"} moneyT = {"100"} addCommandHandler("deposit", function(player, commandName, amount) --Here is our "nil" value (I often use "100" for "amount", when I have $12,000) for k, v in ipairs(playersT) do if(string.match(playersT[k], getPlayerName(player))) then if amount and (tonumber(amount) <= getPlayerMoney(player)) then local i = table.find(players, getPlayerName(player)) local am = tonumber(amount) --Setting "am" as "amount", but changed into number takePlayerMoney(player, am) --Here's everyting ok moneyToLow = tonumber(moneyT[i]) - am --But here is a problem with "am" IDK why ("Attempt to do arithmetic on a nil value") moneyT[i] = tostring(moneyToLow) outputChatBox ("#09ff00Transfered into bank account #ffffff$" .. amount .. "#09ff00!", player, 255, 255, 255, true) end elseif(not string.match(playersT[k], getPlayerName(player))) then local size = table.size(playersT) local i = size + 1 playersT[i] = getPlayerName(player) moneyT[i] = amount takePlayerMoney(player, tonumber(amount)) outputChatBox ("#09ff00Transfered to bank account #ffffff$" .. amount .. "#09ff00!", player, 255, 255, 255, true) end end end) I will say only one thing - What The *F word here*?! Help!
  8. OK. I was re-writing this script second time, after I wrote it at first. I wanted to add new feature. Then I've broke the script and I had to re-write it 2 times. Even second time didn't helped me. If you, community can help me, please, do whatever you want with these commands (addCommandHandlers) to make them work. Please. Here's the full script code IT'S IN POLISH, TRANSLATE IT A LITTLE BIT: --Tabele playersT = {} moneyT = {} --Funkcja zczytująca zapisane tabele addEventHandler("onResourceStart", root, function() local xml = xmlLoadFile("accounts.xml") -- if xml then local xml = xmlLoadFile("accounts.xml") -- local plrsBrnch = xmlFindChild(xml, "players", 0) local mnBrnch = xmlFindChild(xml, "money", 0) -- local plrsTable = xmlNodeGetChildren(plrsBrnch) local mnTable = xmlNodeGetChildren(mnBrnch) -- for i, node in ipairs(plrsTable) do playersT[i] = xmlNodeGetAttribute(node, "name") end -- for i, node in ipairs(mnTable) do moneyT[i] = xmlNodeGetAttribute(node, "value") end -- xmlUnloadFile(xml) else local xml = xmlCreateFile("accounts.xml", "main") -- local plrsBrnch = xmlCreateChild(xml, "players") local mnBrnch = xmlCreateChild(xml, "money") -- xmlSaveFile(xml) xmlUnloadFile(xml) end end) --Użyteczne 2 funkcje function table.size(tab) local length = 0 for _ in pairs(tab) do length = length + 1 end return length end function table.find(tabl,word) if type(tabl) ~= "table" or word == nil then return false else local ret = false for k,v in pairs(tabl) do if v == word then return k end end end end -- --2 funkcje zapisujące tabele addEventHandler("onResourceStop", root, function() local xml = xmlCreateFile("accounts.xml", "main") -- local plrsBrnch = xmlCreateChild(xml, "players") local mnBrnch = xmlCreateChild(xml, "money") -- for k, value in ipairs(playersT) do local plrsTable = xmlCreateChild(plrsBrnch, "object") xmlNodeSetAttribute(plrsTable, "name", value) end -- for k, value in ipairs(moneyT) do local mnTable = xmlCreateChild(mnBrnch, "object") xmlNodeSetAttribute(mnTable, "value", value) end -- xmlSaveFile(xml) xmlUnloadFile(xml) end) addEventHandler("onPlayerQuit", root, function() local xml = xmlCreateFile("accounts.xml", "main") -- local plrsBrnch = xmlCreateChild(xml, "players") local mnBrnch = xmlCreateChild(xml, "money") -- for k, value in ipairs(playersT) do local plrsTable = xmlCreateChild(plrsBrnch, "object") xmlNodeSetAttribute(plrsTable, "name", value) end -- for k, value in ipairs(moneyT) do local mnTable = xmlCreateChild(mnBrnch, "object") xmlNodeSetAttribute(mnTable, "value", value) end -- xmlSaveFile(xml) xmlUnloadFile(xml) end) -- --Reszta skryptu (komendy) --Funkcja do przelewów addCommandHandler("przelew", function(player, command, pname, amount) for k, v in ipairs(playersT) do if(string.match(getPlayerName(player), v)) then if pname and (getPlayerFromName(pname) ~= player) then if amount and (tonumber(amount) <= tonumber(getPlayerMoney(player))) then takePlayerMoney(player, tonumber(amount)) givePlayerMoney(getPlayerFromName(pname), tonumber(amount)) outputChatBox ("#09ff00Przelew ukończony pomyślnie!", player, 255, 255, 255, true) outputChatBox ("#ffffff" .. getPlayerName(player) .. "#09ff00 przelał Ci #ffffff$" .. amount .. "#09ff00 do twojego portfela!", getPlayerFromName(pname), 255, 255, 255, true) end end end end end) --Funkcja do wpłacania pieniędzy addCommandHandler("wplac", function(player, command, amount) for k, v in ipairs(playersT) do if(string.match(getPlayerName(player), v)) then if amount and (amount <= getPlayerMoney(player)) then local i = table.find(players, getPlayerName(player)) moneyT[i] = tostring(tonumber(moneyT[i]) + tonumber(amount)) takePlayerMoney(player, tonumber(amount)) outputChatBox ("#09ff00Wpłaciłeś na konto bankowe #ffffff$" .. amount .. "#09ff00!", player, 255, 255, 255, true) end else local size = table.size(playersT) local i = size + 1 playersT[i] = getPlayerName(player) moneyT[i] = amount takePlayerMoney(player, tonumber(amount)) outputChatBox ("#09ff00Wpłaciłeś na konto bankowe #ffffff$" .. amount .. "#09ff00!", player, 255, 255, 255, true) end end end) --Funkcja do wypłacania pieniędzy addCommandHandler("wyplac", function(player, command, amount) for k, v in ipairs(players) do if(string.match(getPlayerName(player), v)) then if amount then local i = table.find(players, getPlayerName(player)) if(tonumber(moneyT[i] >= tonumber(amount))) then moneyT[i] = tostring(tonumber(moneyT[i]) - tonumber(amount)) givePlayerMoney(player, tonumber(amount)) outputChatBox ("#09ff00Wpypłaciłeś z konta bankowego #ffffff$" .. amount .. "#09ff00!", player, 255, 255, 255, true) end end end end end) XML: <main> <players></players> <money></money> </main> Do what u want with these command handlers, make them work and give the code back, please. I have no idea how to fix this.
  9. No, but my way to check if v ain't got any player names doesn't just work still, same's your way. Funny thing is, that earlier at like 12 o'clock am today it worked ^ EY PATRICK THAT STARTED CREATING PROBLEMS AGAIN XD Ok At this case, I will try to write this script up again, tomorrow, to see, what it will be creating. I regret my choice, to delete older version of script. It was working :''''(((
  10. 'k, wait please, Im trying to figure it out another way...
  11. Yeah, I'll check that. However not working BRO
  12. Why this thing doesn't work? for k, v in ipairs(accounts) do if(not string.match(getPlayerName(player), v)) then --some code end end when accounts table is {} And username is "VaporZ" I tried a lot but it kept not working. Help me.
  13. Ok, t h i s i s i n s a n e. I don't know WHAT IS WRONG, that Lua thinks, TABLE IS EMPTY!!! Code for creating table: enableGarageFunctions = {} Right? Then XML code: <list> <toggles> <toggle garage="Y"/> </toggles> </list> Lua code to read this: local xml = xmlLoadFile("police_settings.xml") -- if xml then local togglesBranch = xmlFindChild(xml, "toggles", 0) -- local togglesTable = xmlNodeGetChildren(togglesBranch) -- for i, node in ipairs(togglesTable) do enableGarageFunctions[i] = xmlNodeGetAttribute(node, "garage") end -- xmlUnloadFile(xml) end And for Lua, actually, THIS table is e m p t y. Because: for k, v in ipairs(enableGarageFunctions) do if(string.match("Y", v)) then --some code end end THIS RETURNS F A L S E. How in the world? Even in console it outputs, that the table isn't empty. CODE: outputConsole(inspect(enableGarageFunctions)) Output in console: {"Y"} h o w i n t h e w o r l d
  14. ok, but for me, my ways to do stuff are most understandable, until Im working with other people. Anyways, I will try to work with this table (enableGarageFunctions) today, maybe after 10 o'clock am, and I will show results in other topic. Thank you for the time, that you spent on this topic. See ya!
  15. IDK how it's not matching, because: policevehs = {} --XML sets that table to: {"596, "523", "402"} for k, v in ipairs(policevehs) do if(string.match(getElementModel(player), tonumber(v))) then --PLAYER IS VEHICLE!!! --some code end end and thats ok lol What u can say IIYAMA enableGarageFunctions IDK why its empty After XML sets it
  16. In console, it outputs: { "Y" } start: Resource 'policja' started In console, it outputs: { "Y" } start: Resource 'policja' started /\ 'police' I tried to: if(enableGarageFunctions[1] == "Y") then --some code end Still nothin' IIYAMA's typing still lol dude thats long xd I don't know how it could be empty
  17. I dont't really know what i've did here not valid, but please tell me: enableGarageFunctions = {} --XML file sets that table to "Y" --And string.match doesn't matches "Y" with table, that have inserted only "Y" in it for k, v in ipairs(enableGarageFunctions) do if(string.match("Y", v)) then --some code end end What's wrong? I tried even to do this in XML file (I doubled "Y"): <list> <garage> <condition enable="Y"/> <condition enable="Y"/> </garage> <taser> <condition enable="Y"/> <condition enable="Y"/> </taser> </list> But even this doesn't work. Tell me, what I'm doing w r o n g. I don't know what I did w r o n g for real.
  18. WARNING! Script messages (outputChatBoxes) and hints (comments) are in POLISH LANGUAGE! If you want, you can translate script into English and send your translation into my e-mail ([email protected]), then I will add a link to your translation to my release post! Example: ENGLISH VERSION - (your link here) -+=========================================================================================================+- PRACA POLICJANTA Ten skrypt pierwotnie miał być tylko na mój serwer, ale w końcu zdecydowałem się, aby udostępnić go na MTA Forumsach. Więc tak, może przejdźmy do komend i omówienia. Oczywiście, wybrałem departament policji w Los Santos (LSPD). .Skrypt automatycznie buduje barykady do garażu policyjnego, tak, aby osoby, które nie są policjantami, nie mogły wejść do niego. .Generuje markery, blip, blip jest po to, aby można było wiedzieć, gdzie dokładnie znajduje się LSPD. Blip widać tylko z odległości 500 metrów (0.5km). .Posiada użyteczne komendy, np. po to, aby zaaresztować gracza (pełna lista później). .PARALIZATOR! Tak, napisałem nawet skrypt na to, aby zamienić pistolet z tłumikiem (nazwa broni w grze: "Silenced", ID: 23) na paralizator. *KOMENDY /police.jail (nickGracza) - Policjant aresztuje wybranego gracza na czas 3minut. /police.unJail (nickGracza) - Policjant wypuszcza z więzenia gracza, kiedy chce. /police.send (nickGracza) (ilośćKasy) - Dajesz graczowi mandat. ROZWIJANE (na razie nie działa) /pay.police (nickPolicjanta) (ilośćKasy) - Płacisz policjantowi za mandat, w wyznaczonym miejscu w departamencie policji (oznaczenia markerów później). *OZNACZENIA Pickup koszulki - Zmiana ubrań policjanta. Strzałka koloru niebieskiego - Zazwyczaj - teleport. Marker koloru fioletowego - Miejsce płacenia za mandat (komenda do tej akcji rozwijana - jest, ale nie działa) Marker koloru żółtego - Spawner pojazdów policyjnych Marker koloru czerwonego - Niszczarka pojazdów policyjnych. WAŻNE INFORMACJE W skrypcie, policjantami mogą być tylko wyznaczone osoby z pewnej listy. Aby tak ową listę graczy edytować, należy po dodaniu skryptu do serwera, otworzyc folder skryptu ("policja"), kliknąć prawym przyciskiem myszy na plik "police_settings.xml", wybrać opcję "Edytuj", lub edytować innym dowolnym edytorem tekstu, reszta - opisana w komentarzach charakterystycznych dla plików *.XML. W skrypcie, samochody policyjne też nie są przypadkowe - można je dodawać usuwać. Podobnie jak w przypadku policjantów, samochody policyjne dodajemy w pliku "police_settings.xml". POBIERANIE: Kliknij poniższy link, który przekieruje Cię na stronę "zippyshare.com", a tam, pobierz plik klikając przycisk "Download", zainstaluj skrypt i baw się dobrze! Link: https://www96.zippyshare.com/v/BKxeO55S/file.html
  19. Ok ok dude Im doing it myself now
  20. single script or edit freeroam.zip? BTW ok XD
  21. So, when I wanted to test my policeman job script, (that I've already posted: ) I quit my server, changed username and joined back. When I wanted to go for a ride to LSPD, I tought, let's teleport. So I've pressed F1 and Freeroam Panel appeared. I don''t know why It does, because I've declarated to ACL.XML file, that only me and my friend are administrators, so to other player, it shouldn't appear, I guess. ANY HELP NOW?
  22. I'll test that Lua: local xml = xmlLoadFile("policja.xml") local polmen = xmlNodeGetChildren(xml, 0) local polvehs = xmlNodeGetChildren(xml, 1) for i, node in ipairs(polmen) do policemen[i] = xmlNodeGetValue(node) end for i, node in ipairs(polvehs) do policevehs[i] = xmlNodeGetValue(node) end xmlUnloadFile(xml) XML: <root> <policemen> <!--<user>(nazwaGracza)</user>--> <user>VaporZ</user> <user>maxeo11</user> </policemen> <policevehicles> <!--<user>(IDPojazdu)</user>--> <vehicle>596</vehicle> <vehicle>523</vehicle> <vehicle>402</vehicle> </policevehicles> </root> Still nothing, error: [...] expected table at argument 1, got userdata (ipairs error). BTW, I've released:
×
×
  • Create New...