Jump to content

kieran

Members
  • Posts

    367
  • Joined

  • Last visited

Everything posted by kieran

  1. I am trying to make an anti advertise script where server owners can put in known server names and parts of IP's, for example if you typed 'mtasa://192.192.192.192:22003' it would grab mtasa:// and cancel the message, outputting a warning to the sender of the message. Currently it works when I type in mtasa://, but if I type anything before or after it doesn't detect it, I know the problem is how I am checking the string, I just have no clue how I could get an IP between words from the chat. Script is below (still in early phases so it's messy and very simple.) strings = { {'mtasa://', 'DO NOT ADVERTISE'}, --tablesting[1], outputmessage[2] } function checkText( message, messageType ) if messageType == 0 then for i=1,#strings do --For all lines in table tablestring = strings[i][1] --Get the text to check outputmessage = strings[i][2] --And text to send back if ( string.gsub ( message,'','' ) == tostring(tablestring) ) then --if the message contains the checked text cancelEvent() --The event will be cancelled so the text is not seen outputChatBox(tostring(outputmessage), source, 255, 0, 0) --And the player will get the warning message end end end end addEventHandler("onPlayerChat", root, checkText) I know it's line 10 and the problem is that I'm just getting the message and not a part of the message, the problem is that I don't want to just get the start of the message, I want to get the text from the table within the message, if that makes sense. so for example 'textmtasa://text' I just want to get the mtasa:// part. Thanks for any help/advice.
  2. What do you mean by "Targets" exactly? Peds? Other Players? Or normal targets?
  3. @CodyJ(L) Thanks so much, it's embarrassing but I still have one question... Should be last one, at least for a while haha! Do you know how I can export a group as a col? I made a house with many different objects, grouped them, exported dff (so only one dff was exported and not many)... But I can't find out how to properly export a group of objects as 1 col file, I keep getting the message "Please re-install export_steve_col_script.ms script!" but I have no clue what that is, it was working fine until I tried exporting a group of objects with SA Tools, seems it doesn't like it.
  4. That works sure, but not by default, you can't set an object ID to double-sided, only a named object created in a script.... I think Dutchman has the best idea... But I was wondering how to add another layer of polys for slightly more complex objects that you might have extruded and are hard to create again, any easy way of turning an object inside out? The likes of making a double-sided material into just polys? Or even better, any ways of setting an object to be double-sided by default?
  5. Thanks @Dutchman101, done a quick test file and came up with the object below. But I have one final question... How do you make the texture so it can be seen from the inside? (it's invisible from inside) Should I face flip and just put the new object inside or is there an easier way?
  6. I am fairly new to 3Ds max and I am trying to create a simple object with a texture. I followed a whole bunch of tutorials on YouTube and so far the col and dff files show in game... But the object is bright white, even when I turn the brightness right down or use an image that's nearly black from the hue being so low. I done a quick search on forums and found out you need UV Wrapping? I have no clue how this effects textures so it would be nice if someone explained what it is and how it works... Also I am not sure if I am using txd workshop right, got the image in, but no alpha/mask image shows. I made a custom object, applied a 2 sided custom texture, exported dff/cst files with SA Tools, made the col file from cst choosing metal floor for it, then I just imported an image into txd workshop and saved it as a compressed .txd file, also done the obvious and loaded it all with the following script. If anyone can see where I'm going wrong it would be much appreciated. \ meta.xml client.lua
  7. I've tried and that doesn't work for players money changing, anyway, like an idiot I forgot you could make data so it's only client side, so useful reminder from IIYAMA. Thanks all for help.
  8. It is :Oing up ... As it is setting element data when player renders, the point of creating this topic was hopefully to limit the players rendering so the element data isn't so much... But I am not used to using a script with exports or anything, I can't think of any way to add delays, the setElementData is only for the column in the scoreboard, that's all it effects, I have noticed even more FPS drops as today I added play time to scoreboard which uses getTickCount. Bear with me here because I am confusing myself, but I believe that I can't use onClientElementDataChange as no data is being changed until I setElementData to update the scoreboard from the dxscoreboard resource, I believe it uses onClientElementDataChange and this is how it sets the columns text in the scoreboard, but I am not entirely sure.... The frame rate is the same on most servers as this resource is now famous across the MTA community, having its own wiki page and everything, replacing the old one for good on professional (well scripted, active) servers, so this topic was an attempt to find an answer on how to solve the FPS drops, and I believe the issue lays within the real time updating for money/teams/play time, so I came to the conclusion most servers must use onClientRender as it's the easiest way, so if there's an answer to this problem it might help some other servers/developers using this scoreboard. Bear in mind my server is purely for testing scripts (so 5 players max), rolling out stuff that's helpful on the community or resources other developers can build on, small simple resources, but tricky and confusing at the same time to try save them the headache of doing something from scratch, I don't know if there's a solution but the following code is my full scoreboard (well the exports). exports.scoreboard:scoreboardAddColumn( "Wanted", 43 ) --Wanted string here exports.scoreboard:scoreboardAddColumn( "Money", 55 ) exports.scoreboard:scoreboardAddColumn( "Play Time", 55 ) function ScoreBoard(thePlayer) for _,player in ipairs(getElementsByType("player")) do setElementData ( player, "Wanted", getPlayerWantedLevel ( ) ) --Updates wanted string by getting players wanted level setElementData ( player, "Money", getPlayerMoney ( ) ) --Updates "Money" by getting players money end --play time if not savedTime then savedTime = getTickCount () --Store the system tick count, this will be 0 for us end currentCount = getTickCount () local secs = currentCount - savedTime local mins = getElementData ( localPlayer, "PlayTimeMin" ) local hours = getElementData ( localPlayer, "PlayTimeHour" ) secs = math.floor(secs/1000) --Convert MS to seconds, and round to closest whole number if hours == false then --If it got boolean from hour/min set them to 0 as they'd be false setElementData( localPlayer, "PlayTimeHour", 0 ) end if mins == false then setElementData ( localPlayer, "PlayTimeMin", 0 ) end if secs >= 60 then --Every 60 secs add a minute to players data setElementData ( localPlayer, "PlayTimeMin", (getElementData ( localPlayer, "PlayTimeMin" ) or 0) + 1 ) savedTime = false --Set saved time to false so it starts counting secs from 0 again end if mins > 60 then --If minutes over 60, add a hour to players data and set their mins to 0 setElementData ( localPlayer, "PlayTimeHour", (getElementData ( localPlayer, "PlayTimeHour" ) or 0) + 1 ) setElementData ( localPlayer, "PlayTimeMin", 0 ) if string.len(hours) == 1 then --If hours are less than 9 add 0 plus the number setElementData ( localPlayer, "Play Time", '0'..hours..':'..mins ) else --Else just add the number setElementData ( localPlayer, "Play Time", hours..':'..mins ) end elseif mins < 60 then --If minutes are under 60 then add a minute to players data if string.len(mins) == 1 then if string.len(hours) == 1 then --If hours are less than 9 add 0 plus the number setElementData ( localPlayer, "Play Time", '0'..hours..':0'..mins ) else --Else just add the number setElementData ( localPlayer, "Play Time", hours..':0'..mins ) end else if string.len(hours) == 1 then setElementData ( localPlayer, "Play Time", '0'..hours..':'..mins ) else setElementData ( localPlayer, "Play Time", hours..':'..mins ) end end end end function addRender() addEventHandler("onClientRender", getRootElement(), ScoreBoard) end addEvent("addScoreboardRender", true) addEventHandler("addScoreboardRender", root, addRender) Confusing, but it works..... for rendering mins/hours can be moved outside the function and made global, then be updated when the event handler is added (on login) hope it helps you understand what I'm doing, I have potato PC btw, so it's why my FPS is so low, but hey, I can at least make stuff playable for other potato PCs. Thanks for help, but guess this is just the way of the potato.
  9. That's cool @Zorgman, I'll need to think up some good lines. Do they say different things depending which faction you're in BTW? I've always been curious about that...
  10. One of the best servers I've played on, even when there's no players there's always something to do! Love how factions/bots fight you and zombies chase you down, also love how realistic loot is dropped by zombies/bandits/Raiders..... Well there's lots of bots! Great work, you are a really talented scripter/mapper and I am amazed you can do so much, it's just a shame so few players are seeing this server... Is more enjoyable when you have a human to talk to, guards just say the same thing over and over again. The one thing I noticed, is my FPS changes daily, so you must be working hard to help us potatoians! One of my biggest likes about this server is that it's so realistic compared to other zombie servers, which give you the ability to warp a car magically to you. I love the support on discord, always helpful and always replies quick. Only downside in my opinion is that a lot of stuff is still in testing phase, so a few bugs here and there, but nothing major. If you haven't played this server yet then try it, you don't know what you're missing!
  11. Sorry but doesn't actually work, the problem is..... I don't want to get when the players data changes, I do want to get when their money/wanted level changes. The reason I use setElementData is because this resource uses onClientElementDataChage or something similar to update the scoreboard, this is why is uses setElementData (I think), so far onClientRender is the only thing that keeps it updated, is there something to detect when money/wanted level changes? Thanks again.
  12. So I've finally found the amazing dxscoreboard resource made by Awwu and can add rows by just setting players element data, but I am wondering if there's a less CPU intensive way to update the scoreboard as I am constantly setting clients data when they render, code is below (tested for one player only). exports.scoreboard:scoreboardAddColumn( "Wanted", 45 ) exports.scoreboard:scoreboardAddColumn( "Money", 55 ) function ScoreBoardWanted(thePlayer) for _,player in ipairs(getElementsByType("player")) do setElementData ( player, "Wanted", getPlayerWantedLevel ( ) ) setElementData ( player, "Money", getPlayerMoney ( ) ) end end addEventHandler("onClientRender", getRootElement(), ScoreBoardWanted) I noticed a lot of servers that use this panel now as it's easy, but I have noticed a change in FPS (5-15 loss) using it and I'm just curious if there's a less intensive way. As always, any help/info would be nice, thanks.
  13. Thanks a lot, forgot you could do tables/lists like that!
  14. I made a short script that allows only certain serials to join, but the problem is in my for loop it checks every serial from a table, then it kicks the player if their serial is not in that table, of course it kicks them if the first serial it gets isn't equal to theirs..... And I am struggling to come up with a way to fix it, here is code. local allowedAccountSerials = {--Table of all allowed serials { "1K23GKG4K12B4B4K12B4K1B4J1BK1B43" }, { "F2412KL4NHLK1NH41NH24KJ14K1B4144" }, { "FB1244HK4HK1H1H4K14H12HK4K1H4142" }, { "89AF8AFAW90F8A08FAW9FAF8ASF9WAF8" }, } addEventHandler("onPlayerJoin", getRootElement(), function() local playerSerial = getPlayerSerial(source) --Get players serial for i = 1, #allowedAccountSerials do --For all serials in the list if playerSerial ~= allowedAccountSerials[i] then --If the players serial doesn't match one in the table kickPlayer(source, "Serial " ..playerSerial.. " is not allowed to join.") --Kick them return else outputChatBox(source, "Welcome to the server "..playerSerial) end end end ) I'm trying to get this to work for map editor as any player could come and ruin the map when I start editor on my server, thanks for any help/input.
  15. Ah thanks, I should of payed attention instead of drawing triangles in class.
  16. I've never touched OOP... What would I need to know for this? Only reason I ask is that I have made a script for a friend where the player climbs up a ladder, that part works fine, but when they go down the ladder (even if I spin them 180 degrees) they glitch through walls and it's horrible.
  17. I'll be straight up, took the following code straight off another topic from a while back where the guy was getting a ramp to spawn in front of the player, I modified it to move the player, but it moves them forwards and I want to move them backwards.... I am not the best at math but I am trying to learn from scripting, code to move player forwards is below. local x, y, z = getElementPosition ( localPlayer ) local r = getPedRotation ( localPlayer ) x = x + math.sin ( math.rad ( r ) ) * 1.5 --What does this actually do? y = y - math.cos ( math.rad ( r ) ) * 1.5 --And this? setElementPosition ( localPlayer, x, y, z ) setElementRotation ( localPlayer, 0, 0, r ) Can someone explain what's actually happening? It works but my problem is dealing with: math.sin, math.cos and math.rad. Any info would be greatly appreciated.
  18. Basically I was checking if timer was active inside the timer, so it could be triggered twice if my player went up pressing w and then down pressing s without leaving the col.... I don't know if I was just checking the timer wrong or what, but the following works.... local moveTimer function movePlayer(key, state) if state then if (key == "w" or key == "s") and isTimer(moveTimer) then killTimer(moveTimer) end moveTimer = setTimer(function() if getKeyState ("w") == true then x, y, z = getElementPosition ( localPlayer ) setElementPosition ( localPlayer, x, y, z+0.5, false ) elseif getKeyState ("s") == true then x, y, z = getElementPosition ( localPlayer ) elseif (key == "w" or key == "s") and isTimer(moveTimer) then killTimer(moveTimer) end end, 150, 0) end end function addTheHandlers() setElementFrozen( localPlayer, true ) addEventHandler("onClientKey", root, movePlayer) end
  19. Thanks, but now if I go down when climbing up my player gets the W key stuck..... I have no clue why. local moveTimer function movePlayer(key, state) if state then moveTimer = setTimer(function() if getKeyState ("w") == true then x, y, z = getElementPosition ( localPlayer ) setElementPosition ( localPlayer, x, y, z+0.5, false ) elseif getKeyState ("s") == true then x, y, z = getElementPosition ( localPlayer ) elseif (key == "w" or key == "s") and isTimer(moveTimer) then killTimer(moveTimer) end end, 250, 0) end end function addTheHandlers() setElementFrozen( localPlayer, true ) addEventHandler("onClientKey", root, movePlayer) end addEvent("addLadderHandlers", true) addEventHandler("addLadderHandlers", root, addTheHandlers) By the way, the player is in a colShape if that has something to do with it..... Even when I exit the col shape I still have W stuck on. Edit fixed it, checked timer before it started.
  20. Yeah, well it still doesn't let me just hold and climb, it only registers the key press once, then stops til I press it again..... Also getKeyState done the exact same... I want to be able to hold it and basically use it like onClientRender rather than onClientResourceStart, if that makes sense... function movePlayer() if getKeyState ("w") == true then x, y, z = getElementPosition ( localPlayer ) setElementPosition ( localPlayer, x, y, z+1, false ) elseif getKeyState ("s") == true then x, y, z = getElementPosition ( localPlayer ) setElementPosition ( localPlayer, x, y, z-1, false ) end end function addTheHandlers() setElementFrozen( localPlayer, true ) addEventHandler("onClientKey", root, movePlayer) --Want this to be constantly checked... end Okay problem was onClientKey, but how can I sort this? I am a bit mind f**ked at the moment...
  21. Hello, I want to make a script for a ladder, I am half way there, and my player moves up and down..... But the problem is I have to spam W! Is there any way to check if a key is being held rather than checking if it is pressed? Here's the part of the script where I move the player. function movePlayer(key, state) if key == "w" and state then --If the key is w and it's pressed. x, y, z = getElementPosition ( localPlayer ) setElementPosition ( localPlayer, x, y, z+1, false ) --I move the player after I get their position. setElementFrozen( localPlayer, true ) elseif key == "s" and state then --If it's s. x, y, z = getElementPosition ( localPlayer ) setElementPosition ( localPlayer, x, y, z-1, false ) --They move down. setElementFrozen( localPlayer, true ) end end function addTheHandlers() addEventHandler("onClientKey", root, movePlayer) --When the player hits the key they will be moved up or down, I want it to be if they HOLD the key down they move. end addEvent("addLadderHandlers", true) addEventHandler("addLadderHandlers", root, addTheHandlers) I know that onClientKey basically checks the key presses, so would I need to add an onClientRender and check the pressed key and state? Or is their an easier way/handler? Would appreciate ideas/solutions, thanks.
  22. I don't know if this will work, just modified urbans code to how I'd s --[[if reason == "1" then --So this code block isn't in a function? I assume it's pasted with no function, but if not, put it in a function... if isPlayerMuted(target) then outputChatBox("Player is already muted.", player, 255, 0, 0) end if playeraccount then if not isGuestAccount(playeraccount) then setPlayerMuted(target, true) setAccountData(playeraccount, "mutedfor30secs", true) outputChatBox("* "..name.." has been muted by "..plrname.."!", root, 13, 107, 39, true) setTimer(setPlayerMuted,30*1000,1,target,false) setTimer(setAccountData,30*1000,1,playeraccount,"mutedfor30secs",false) setTimer(outputChatBox,30*1000,1,"unmuted",root) end end end]] function muteOnLogin(_, playeraccount) if playeraccount then if not isGuestAccount(playeraccount) then local muted = getAccountData(playeraccount, "mutedfor30secs") if muted ~= false then setPlayerMuted(source, true) outputChatBox("muted", source) --You tried outputting message to root :/ try avoid this... setTimer(setPlayerMuted,30*1000,1,source,false) setTimer(outputChatBox,30*1000,1,"unmuted",source) end end end end addEventHandler("onPlayerLogin", root, muteOnLogin) addEventHandler("onPlayerQuit", root, function(_, playeraccount) if (playeraccount) and not isGuestAccount(playeraccount) then if isPlayerMuted(source) then setAccountData(playeraccount, "mutedfor30secs", true) end end end) To be honest... Too lazy to comment it all but basically you were using root, playeraccount, and all sorts of weird stuff when "source" would of done the job, every time you look on the wiki, look at what the source element is... When a player triggers a function by doing an action (logging in, quitting, entering a vehicle) you can use "source" as the source element is the player, the wiki tells you this Also I assume the code above muteOnLogin isn't just loose in your actual script like that, if it is, you should put it in a function or tell me what you want done with it, this might help if it's not in a function.... function muteThePlayer(player,_,target) if reason == "1" then if isPlayerMuted(target) then outputChatBox("Player is already muted.", player, 255, 0, 0) end if playeraccount then if not isGuestAccount(playeraccount) then setPlayerMuted(target, true) setAccountData(playeraccount, "mutedfor30secs", true) outputChatBox("* "..target.." has been muted by "..player.."!", source, 13, 107, 39, true) setTimer(setPlayerMuted,30*1000,1,target,false) setTimer(setAccountData,30*1000,1,target,"mutedfor30secs",false) setTimer(outputChatBox,30*1000,1,"unmuted",target) end end end end addCommandHandler("mute", muteThePlayer) You were doing this: "if playeraccount then else return end" This literally does NOTHING! Something should be after "then" even if it's another if, the fact you put and else in there is beyond me.... This code might not work, but I hope it helps somehow, make sure to /debugscript 3 when you login and tell us what it says also look at console for errors.
  23. Thanks, I thought since it was mapping related people wouldn't like it in scripting since it's just me deleting an image on txde and exporting it.... So was a little unsure, but thank you for this, I will try it, and if I have any problems I'll post in scripting.
×
×
  • Create New...