Jump to content

Dzsozi (h03)

Members
  • Posts

    696
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Dzsozi (h03)

  1. Hello community, I have a question/problem with my script. So, I don't really understand how does the loops work, I mean these things: for k, v, in ipairs(somethingHere) do -- or for i, somethingHere in #numberOfSomething do -- and more 'for ... do' things First of all I would be very grateful if someone could explain it or send me a source to read through and learn it. So my problem is that I took the wiki's example and edited it, but for some reason it's not working. Since I don't understand loops I can't manage out how to fix it, even if debugscript tells me errors. I want to loop through all the accounts and set their "funmodev2-" account datas to false, because I don't need them anymore. Here's my code: function deleteAllData ( ) local account = getPlayerAccount (source) local accountTable = getAccounts () for accountTable, accounts in ipairs(getAccountName(account)) do local data = getAllAccountData( accounts ) for k,v in pairs ( data ) do setAccountData (v, "funmodev2-money", false) setAccountData (v, "funmodev2-skin", false) setAccountData (v, "funmodev2-health", false) setAccountData (v, "funmodev2-armor", false) setAccountData (v, "funmodev2-team", false) setAccountData (v, "funmodev2-R", false) setAccountData (v, "funmodev2-G", false) setAccountData (v, "funmodev2-B", false) setAccountData (v, "funmodev2-x", false) setAccountData (v, "funmodev2-y", false) setAccountData (v, "funmodev2-z", false) setAccountData (v, "funmodev2-int", false) setAccountData (v, "funmodev2-dim", false) setAccountData (v, "funmodev2-wantedlevel", false) setAccountData (v, "funmodev2-weaponID0", false) setAccountData (v, "funmodev2-weaponID1", false) setAccountData (v, "funmodev2-weaponID2", false) setAccountData (v, "funmodev2-weaponID3", false) setAccountData (v, "funmodev2-weaponID4", false) setAccountData (v, "funmodev2-weaponID5", false) setAccountData (v, "funmodev2-weaponID6", false) setAccountData (v, "funmodev2-weaponID7", false) setAccountData (v, "funmodev2-weaponID8", false) setAccountData (v, "funmodev2-weaponID9", false) setAccountData (v, "funmodev2-weaponID10", false) setAccountData (v, "funmodev2-weaponID11", false) setAccountData (v, "funmodev2-weaponID12", false) setAccountData (v, "funmodev2-weaponAmmo0", false) setAccountData (v, "funmodev2-weaponAmmo1", false) setAccountData (v, "funmodev2-weaponAmmo2", false) setAccountData (v, "funmodev2-weaponAmmo3", false) setAccountData (v, "funmodev2-weaponAmmo4", false) setAccountData (v, "funmodev2-weaponAmmo5", false) setAccountData (v, "funmodev2-weaponAmmo6", false) setAccountData (v, "funmodev2-weaponAmmo7", false) setAccountData (v, "funmodev2-weaponAmmo8", false) setAccountData (v, "funmodev2-weaponAmmo9", false) setAccountData (v, "funmodev2-weaponAmmo10", false) setAccountData (v, "funmodev2-weaponAmmo11", false) setAccountData (v, "funmodev2-weaponAmmo12", false) end end end addCommandHandler( "delallacc", deleteAllData ) When I write /delallacc debugscript tells me this: Thanks for the help in advance! P.S.: Sorry for the bad English if there was something written wrong, I'm from Hungary!
  2. Thanks for everybody, I've got an idea, I hope that this will work, thank you again!
  3. So by that you mean there's no fix for this problem? So I can't make a custom chat that supports commands? Or what would be the best way to make custom chats that supports commands?
  4. Thanks! And is there any way to get the count of the arguments? So you don't have to make this: msgTable[2], msgTable[3] ... but this: msgTalbe[count] -- or something like this How is this possible?
  5. Try it. function toggleEngine(source, key, keystate) local veh = getPedOccupiedVehicle(source) local inVehicle = getElementData(source, "realinvehicle") if veh and inVehicle == 1 then local seat = getPedOccupiedVehicleSeat(source) if (seat == 0) then local model = getElementModel(veh) if not (enginelessVehicle[model]) then local engine = getElementData(veh, "engine") local vehID = getElementData(veh, "dbid") local vehKey = exports['global']:hasItem(source, 3, vehID) if engine == 0 then local vjob = tonumber(getElementData(veh, "job")) local job = getElementData(source, "job") local owner = getElementData(veh, "owner") local faction = tonumber(getElementData(veh, "faction")) local playerFaction = tonumber(getElementData(source, "faction")) if (vehKey) or (owner < 0) and (faction == -1) or (playerFaction == faction) and (faction ~= -1) or ((getElementData(source, "adminduty") or 0) == 1) then local fuel = getElementData(veh, "fuel") local broke = getElementData(veh, "enginebroke") if broke == 1 then exports.global:sendLocalMeAction(source, "cenšās piestartēt transportlīdzekļa dzinēju, bet tas atsakās strādāt.") outputChatBox("Transportlīdzekļa dzinējs ir sabojājies.", source) elseif exports.global:hasItem(veh, 74) then elseif fuel >= 1 then toggleControl(source, 'brake_reverse', true) setVehicleEngineState(veh, true) setTimer(setVehicleEngineState, 9200, 1, true, veh) exports['anticheat-system']:changeProtectedElementDataEx(veh, "engine", 1, false) elseif fuel < 1 then exports.global:sendLocalMeAction(source, "cenšās piestartēt transportlīdzekļa dzinēju, bet tas atsakās strādāt.") outputChatBox("Transportlīdzeklim ir beigusies degviela.", source) end else outputChatBox("Jums ir nepieciešamas transportlīdzekļa atslēgas, lai piestartētu tā dzinēju.", source, 255, 0, 0) end else toggleControl(source, 'brake_reverse', false) setVehicleEngineState(veh, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "engine", 0, false) end end end end end addCommandHandler("engine", toggleEngine)
  6. Thank you! You helped me alot! But, I made more functions, I made the local chat and made this command thingy for the local chat first, because this is gonna be the main chat. But I have one problem. If I write in any command, for example /debugscript 3 then nothing happens, I've added the resource to acl admin group, and debugscript doesn't show me errors. Here's the current function: local distance = 30 function sendMessageToNearbyPlayers(thePlayer, cmd, ...) local x, y, z = getElementPosition( thePlayer ) local nr, ng, nb = getPlayerNametagColor(thePlayer) local name = getPlayerName(thePlayer) local affectedPlayers = { } local msgTable = { ... } local message = table.concat ( msgTable, " " ) local first = msgTable[1] if getElementData(thePlayer, "chat:spam") == 1 then sendServerMessage("Másodpercenként egy üzenetet küldhetsz.", thePlayer) else if string.sub(first,1,1) == "/" then local command = string.sub(first,2,string.len(first)) executeCommandHandler( command, thePlayer ) else local shownto = 0 for index, nearbyPlayer in ipairs(getElementsByType("player")) do if isElement(nearbyPlayer) and getDistanceBetweenPoints3D(x, y, z, getElementPosition(nearbyPlayer)) < ( distance or 20 ) then if not isPedDead(nearbyPlayer) and getElementDimension(thePlayer) == getElementDimension(nearbyPlayer) then outputChatBox("#F58C14[LOCAL]" .. RGBToHex(nr, ng, nb) .. " " .. name .. "#FFFFFF: " .. message, nearbyPlayer, 255, 255, 255, true ) outputServerLog("[LOCAL]: ".. name ..": "..message) table.insert(affectedPlayers, nearbyPlayer) shownto = shownto + 1 end end end setElementData(thePlayer, "chat:spam", 1) setTimer(function(thePlayer) setElementData(thePlayer, "chat:spam", 0) end, 1000, 1, thePlayer) end end end addCommandHandler("Local",sendMessageToNearbyPlayers) What could be the problem? EDIT: I've noticed that the commands are not working only with more arguments. I made a command to get the online admins list, and it's command is /admins. If i write it in the local chat then it outputs the admins, so the problem is with the more arguments, I think. For example there's one more parameter in the debugscript command, in this case the 3. So how could I fix this? EDIT 2: UPDATED THE CODE!
  7. 1. You gave me an idea, but I don't know how to search for "/" as the first typed character. Because after this, I could execute it with executeCommandHandler function. 2. I don't want that commands will appear in the global chat. So people who made a mistake, don't have to afraid that the command is not working.
  8. Here's the full code: function sendMessageToAllPlayers(thePlayer, cmd, ...) local message = table.concat ( { ... }, " " ) local nr, ng, nb = getPlayerNametagColor(thePlayer) local name = getPlayerName(thePlayer) if isTimer(antiSpam[thePlayer]) then sendServerMessage("Másodpercenként egy üzenetet küldhetsz.", thePlayer) else outputChatBox("#48D4A3[GLOBAL]" .. RGBToHex(nr, ng, nb) .. " " .. name .. "#FFFFFF: " .. message, getRootElement(), 255, 255, 255, true ) outputServerLog("[GLOBAL]: ".. name ..": "..message) antiSpam[thePlayer] = setTimer(function(thePlayer) antiSpam[thePlayer] = nil end, 1000, 1, thePlayer) end end addCommandHandler("Global",sendMessageToAllPlayers) function blockChatMessage(message) cancelEvent() end addEventHandler("onPlayerChat", getRootElement(), blockChatMessage) addEventHandler("onPlayerJoin",getRootElement(), function () bindKey(source,"x","down","chatbox","Global") end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"x","down","chatbox","Global") end end)
  9. No, only the function of the custom chat.
  10. Hello community! I made my custom chat system, but I have one problem. I can't execute commands, for example /start resourcename. The chat outputs it like a simple text, everyone can see it, but nothing happens. So my question is how can I make it to execute the command that I wrote in the custom chat? Here's my code: function sendMessageToAllPlayers(thePlayer, cmd, ...) local message = table.concat ( { ... }, " " ) local nr, ng, nb = getPlayerNametagColor(thePlayer) local name = getPlayerName(thePlayer) if isTimer(antiSpam[thePlayer]) then sendServerMessage("Másodpercenként egy üzenetet küldhetsz.", thePlayer) else outputChatBox("#48D4A3[GLOBAL]" .. RGBToHex(nr, ng, nb) .. " " .. name .. "#FFFFFF: " .. message, getRootElement(), 255, 255, 255, true ) outputServerLog("[GLOBAL]: ".. name ..": "..message) antiSpam[thePlayer] = setTimer(function(thePlayer) antiSpam[thePlayer] = nil end, 1000, 1, thePlayer) end end addCommandHandler("Global",sendMessageToAllPlayers) P.S.: Sorry for the bad English if there was something written wrong, I'm from Hungary, but I hope that I was understandable!
  11. Very nice script man, good job! But I have a question. Is this possible to remove/destroy private cars? So, for example if you want money you can go to the junkyard and destroy it. Then it will remove the table from SQL and destroys the car. So, a new export function to destroy cars. Or admins can delete cars by vehicle IDs (I mean the element data, because I can see that there is a "private" ID for each cars). It would be nice! EDIT: I'm edited your code, now it can store the secondary color of the car, and added some features, like if you exit the vehicle then the engine will turn off and if the lights are on then they will turn off as well, and if you enter the vehicle then the engine will turn on, and the lights based on time. So if it's night then they will turn on. Added information for admins if the arguments are wrong of /create command. I want to add one more feature, that the script stores the vehicle's health. Hope that it's not a problem. Rated 5/5
  12. Title tells everything. My question is that how/where to edit the default mission timer resource to be shown only specified players on server side. For example show the timer only the person who entered a script generated vehicle. Or if someone already have an edited version of mission timer as I've instructed and could send me it would be awesome! Thanks!
  13. Hello community! I've got a script from my friend, and I edited it as GTA V's notifications: My only problem is that I got some problem with the maths, that I can't find, and I don't know how to fix the problem. I've tried several things, but none of them worked. It always had a little bug. The current version looks like this: I would be very thankful if someone could fix this for me! local sx, sy = guiGetScreenSize() --------------------- -- GTA V küldetés és telefon --------------------- local sx,sy = guiGetScreenSize () local font = "default-bold" local font2 = "clear" local headerSize = 1.25 local notificationTextSize = 1.05 local notificationWidth,notificationHeight = 256,128 local notificationHeaderX,notificationHeaderX2,notificationHeaderY,notificationHeaderY2 = 52,150,10,37 local notificationTextX,notificationTextX2,notificationTextY,notificationTextY2 = 10,256,50,118 local notificationIconSize = 32 local notificationIconX = 10 local notificationIconY = notificationHeaderY local notificationX = 50 * sx / sx local notificationStartY,notificationCenterY = sy - notificationHeight,sy/2 local notificationsOffset = 10 local notificationsList = {} local notificationsShowingTime = 1000 local notificationsRenderTime = 10000 local notificationsHidingTime = 1000 local notificationStartColor = { 255, 255, 255 } local notificationEndColor = { 0, 0, 0 } local priorityText = {} priorityText[1] = "Franklin" priorityText[2] = "Michael" priorityText[3] = "Trevor" priorityText[4] = "Simeon" priorityText[5] = "Lester" priorityText[6] = "Ron" priorityText[7] = "Dave" local notificationsToDelete = {} function dxDrawMissionNotification (text,priority) if text and priority then local sound = playSound("files/notification.mp3") local cTick = getTickCount () if notificationsList[1] then if notificationsList[1]["startTick"]+notificationsShowingTime > cTick then -- still showing cTick = notificationsList[1]["startTick"]+notificationsShowingTime end end local tab = {} tab["text"] = text tab["priority"] = priority tab["startTick"] = cTick table.insert (notificationsList,1,tab) end end addEvent ("onNewNotificationCreate",true) addEventHandler ("onNewNotificationCreate",getRootElement(), function (text,priority) dxDrawMissionNotification (text,priority) end ) function teszt() dxDrawMissionNotification ("aaaaaaaaaaaaaaaaaaaaaaaaaa", 3) setTimer(function() dxDrawMissionNotification ("aaaaaaaa", 4) setTimer(function() dxDrawMissionNotification ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 1) setTimer(function() dxDrawMissionNotification ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 5) end, 2000, 1) end, 2000, 1) end, 2000, 1) end addCommandHandler("teszt", teszt) function renderMissionNotifications () for k,v in ipairs(notificationsToDelete) do table.remove (notificationsList,v-k+1) end notificationsToDelete = {} if #notificationsList > 0 then local lowestY = 0 local n = 0 local cTick = getTickCount () local renderingY = nil for k,v in ipairs(notificationsList) do if cTick >= v["startTick"] then if n == 0 then local delay = cTick-v["startTick"] if delay <= notificationsShowingTime then local boxPadding = 10 local lineHeight = dxGetFontHeight( 1.05, "clear" ) local lineHeight2 = dxGetFontHeight( 1.25, "default-bold" ) local minimumWidth = 256 local lines2 = 0 local wordbreak2 = false local lineWidth2 = dxGetTextWidth( v["text"], 1.05, "clear" ) while ( lineWidth2 > minimumWidth ) do lineWidth2 = lineWidth2 - minimumWidth lines2 = lines2 + 1 wordbreak2 = true end local boxWidth, boxHeight = ( minimumWidth + ( boxPadding * 2 ) ), ( lineHeight2 + lines2 ) + ( lineHeight * ( lines2 + 1 ) ) + ( boxPadding * 2 )*2 local progress = delay/notificationsShowingTime local alpha = interpolateBetween ( 0,0,0, 200,0,0, progress*2,"Linear" ) local wr1, wg1, wb1 = unpack(notificationStartColor) local wr2, wg2, wb2 = unpack(notificationEndColor) local wr, wg, wb = interpolateBetween ( wr1, wg1, wb1, wr2, wg2, wb2, progress*2, "InOutBack") local currentY = sy/2 local renderY = currentY-boxHeight local textWidth, textHeight = notificationX + minimumWidth, renderY + lineHeight dxDrawRectangle(notificationX, renderY, boxWidth, boxHeight, tocolor(wr,wg,wb,alpha), true) dxDrawRectangle(notificationX+notificationIconX,renderY+notificationIconY,notificationIconSize,notificationIconSize, tocolor(wr,wg,wb,alpha), true) --kép dxDrawText (priorityText[v["priority"]], notificationX+notificationHeaderX, renderY+notificationHeaderY, notificationX+notificationHeaderX2, renderY+notificationHeaderY2, tocolor(255,255,255,alpha-50),headerSize,font,"left","center",false,false,true) dxDrawText (v["text"],notificationX+notificationTextX, renderY+notificationTextY, textWidth, textHeight,tocolor(255,255,255,alpha-50),notificationTextSize,font2,"left","top",false,wordbreak2,true) local criticalY = currentY-notificationsOffset-boxHeight if criticalY <= currentY then renderingY = currentY end else local boxPadding = 10 local lineHeight = dxGetFontHeight( 1.05, "clear" ) local lineHeight2 = dxGetFontHeight( 1.25, "default-bold" ) local minimumWidth = 256 local lines2 = 0 local wordbreak22 = false local lineWidth2 = dxGetTextWidth( v["text"], 1.05, "clear" ) while ( lineWidth2 > minimumWidth ) do lineWidth2 = lineWidth2 - minimumWidth lines2 = lines2 + 1 wordbreak2 = true end local boxWidth, boxHeight = ( minimumWidth + ( boxPadding * 2 ) ), ( lineHeight2 ) + ( lineHeight * ( lines2 + 1 ) ) + ( boxPadding * 2 )*2 renderingY = false local delay = delay-notificationsShowingTime local alpha = 200 if delay > notificationsRenderTime then local progress = (delay-notificationsRenderTime)/notificationsHidingTime alpha = interpolateBetween ( 200,0,0, 0,0,0, progress,"Linear" ) if progress >= 1 then table.insert (notificationsToDelete,k) end end local currentY = sy/2 renderY = currentY-boxHeight local textWidth, textHeight = notificationX + minimumWidth, renderY + lineHeight dxDrawRectangle(notificationX, renderY, boxWidth, boxHeight, tocolor(0,0,0,alpha), true) dxDrawImage (notificationX+notificationIconX,renderY+notificationIconY,notificationIconSize,notificationIconSize,"files/" .. v["priority"] .. ".png",0,0,0,tocolor(255,255,255,alpha),true) dxDrawText (priorityText[v["priority"]], notificationX+notificationHeaderX, renderY+notificationHeaderY, notificationX+notificationHeaderX2, renderY+notificationHeaderY2, tocolor(255,255,255,alpha),headerSize,font,"left","center",false,false,true) dxDrawText (v["text"],notificationX+notificationTextX, renderY+notificationTextY, textWidth, textHeight,tocolor(255,255,255,alpha),notificationTextSize,font2,"left","top",false,wordbreak2,true) end else local boxPadding = 10 local lineHeight = dxGetFontHeight( 1.05, "clear" ) local lineHeight2 = dxGetFontHeight( 1.25, "default-bold" ) local minimumWidth = 256 local lines2 = 0 local wordbreak2 = false local lineWidth2 = dxGetTextWidth( v["text"], 1.05, "clear" ) while ( lineWidth2 > minimumWidth ) do lineWidth2 = lineWidth2 - minimumWidth lines2 = lines2 + 1 wordbreak2 = true end local boxWidth, boxHeight = ( minimumWidth + ( boxPadding * 2 ) ), ( lineHeight2 ) + ( lineHeight * ( lines2 + 1 ) ) + ( boxPadding * 2 )*2 local delay = cTick-v["startTick"]-notificationsShowingTime local alpha = 200 if delay > notificationsRenderTime then local progress = (delay-notificationsRenderTime)/notificationsHidingTime alpha = interpolateBetween ( 200,0,0, 0,0,0, progress,"Linear" ) if progress >= 1 then table.insert (notificationsToDelete,k) end end local currentY = sy/2 if renderingY then currentY = renderingY - (notificationsOffset + boxHeight)*n elseif renderingY == false then currentY = sy/2 - (notificationsOffset + boxHeight)*n elseif renderingY == nil then currentY = sy/2 - (notificationsOffset + boxHeight)*(n-1) end renderY = currentY-boxHeight local textWidth, textHeight = notificationX + minimumWidth, renderY + lineHeight dxDrawRectangle(notificationX, renderY, boxWidth, boxHeight, tocolor(0,0,0,alpha), true) dxDrawImage (notificationX+notificationIconX,renderY+notificationIconY,notificationIconSize,notificationIconSize,"files/" .. v["priority"] .. ".png",0,0,0,tocolor(255,255,255,alpha),true) dxDrawText (priorityText[v["priority"]], notificationX+notificationHeaderX, renderY+notificationHeaderY, notificationX+notificationHeaderX2, renderY+notificationHeaderY2, tocolor(255,255,255,alpha),headerSize,font,"left","center",false,false,true) dxDrawText (v["text"],notificationX+notificationTextX, renderY+notificationTextY, textWidth, textHeight,tocolor(255,255,255,alpha),notificationTextSize,font2,"left","top",false,wordbreak2,true) end n = n+1 end end end end addEventHandler ("onClientRender",getRootElement(),renderMissionNotifications) Thank you for the help in advance!
  14. That's what I've tried before, but I've got an idea, tomorrow I'll try out something again. Thank you!
  15. I think we don't understand each other, I want to make the intro played to the player who registered on the server. So if you are a new player and have a new account, then the intro will be played. I don't want to make the intro being played to everybody who login's. Just the player who registered a new account. Or what do you mean by "logs in in the first place"? Sorry for being such a noob, but I'm new to account things, plus my main language is not English so it's possible that I will not understand that you wrote But I'm trying to be understandable.
  16. So you mean that I should trigger the intro to server side, and set the other datas there? Just trigger the intro from client side?
  17. Oh, thanks, I forgot about this command. But I can't understand the logic of this setting and getting account data's, I mean, if I make an intro, then it's gonna be client side. And on client side how do I set account data to played without bugs? Triggering is not working for me, I tried with this, but nothing happens and debugscript doesn't shows any error. I would appreciate it if someone could help me, write me an example or expalin it. EDIT: I could trigger the intro to server side. I'm using this save resource: https://community.multitheftauto.com/index.php?p= ... ils&id=977 But it's "new-registered-player-detection" doesn't works very well. I made a test account and I got the data of my main account. So I had money, position, weapons and other things from my main account on a fully new registered account. When I made my "new-registered-player-detection" function everything got messed up.
  18. I have one more question. Now I'm making a lot of test accounts, to test the script so, how or where can I delete them?
×
×
  • Create New...