Jump to content

ReZurrecti0n

Members
  • Posts

    123
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by ReZurrecti0n

  1. Using root will make things work, but very hard on the CPU. You will want to switch from root to getResourceRoot() instead for most cases, directed at those Event Handlers though. Also if it continues to execute for every player, add a check with onClientMarkerHit (outFourDragons) for the local player: if(hitPlayer == localPlayer)then -- Whatever Code end
  2. What about detecting when the fire key(s) are being pressed and released? Display the text when the fire key is down and then stop displaying when the fire key has been released? However, this may get complex because of the amount of ways to attack and may just need to check a whole mess of conditions...
  3. Why not just place the function under onClientResourceStart?
  4. English seems great to me, haven't even noticed it wasn't your native language... But as for how to figure out what parameters a event has: Let's say we want to know what parameters come with the OnPlayerWasted Event We first look up the event on the wiki: https://wiki.multitheftauto.com/wiki/OnPlayerWasted Look for where it says: Parameters You may rename these parameters to anything you want, but will always be the same So on this example: onPlayerWasted(totalAmmo,killer,killerWeapon,bodypart,stealth) Let's change the parameter names to be like: onPlayerWasted(candy,bird,sun,rock,tools) candy will still be the total ammo, bird will be the killer element if any, sun would still be the weapon used for the kill, so on and so forth... You're going to have to look into this wiki, search these forums and google search Lua to figure everything out. This is how I learned, but every now and then I won't be able to find anywhere on how to do this or that and so I finally make a thread for it
  5. infourdragons = createMarker (2019.76953125, 1007.0116577148, 9.7203125, "cylinder", 1, 255, 0, 0, 153) function saythis (player) -- Should consider adding the 2nd parameter for future use and renaming the player parameter to something more related such as element if (player == infourdragons) then -- The player is not infourdragons and never will be, you must be confusing this as checking the player touching infourdragons or something. Instead check if player is an actual player element AND if source (The Marker) is infourdragons outputChatBox ("What are you doing?", player, true) -- This would work currently, but what if player is a vehicle instead of a player? Should rename the player parameter for that reason end end addEventHandler("onHitMarker", player, "saythis") -- onHitMarker is wrong, you meant onMarkerHit. getRootElement() should be used instead of the player parameter, but unsure if player could or even should be used. Never tried, always gone with getRootElement() on all my Handlers
  6. Because you are using player, but player is not defined in this function anywhere. However, with onMarkerHit(hitElement, matchingDimension), the first parameter is the element that hit the marker which in this case is likely the player: infourdragons = createMarker (2019.76953125, 1007.0116577148, 9.7203125, "cylinder", 1, 255, 0, 0, 153) -- Coords for a spot next to the doors of the casino, on the outside. function enteredDragons(hitElement, matchingDimension) -- When anything hits the marker (players, objects, vehicles, etc.) it becomes "hitElement" if (source == infourdragons and getElementType (hitElement) == "player") then -- Making sure the element is a player setElementInterior (hitElement, 0) setElementPosition (hitElement, 2018.9376220703, 1017.0843505859, 996.875 ) -- Coords for a spot next to the doors of the casino, on the inside. setElementRotation (hitElement, 0, 0, 90) outputChatbox ("Entraste al Casino 'Four Dragons'", hitElement, true) end end addEventHandler ("onMarkerHit", root, enteredDragons) There are other options you may take, one is simply just changing that first parameter to player (But this may confuse you down the road because more than just a player can trigger the event) Another option is using onPlayerMarkerHit(markerHit, matchingDimension), source would then be the player that hit the marker
  7. Maybe the client file wasn't downloaded and run yet when the server attempted the triggerClientEvent. But after it finishes downloading and running the client file, it all works... A solution to this is starting your server from the onClientResourceStart event on your client side file. Once that event triggers, then you could just use triggerServerEvent to spawn in your player in etc. Oh, but you may want to make sure it only triggers once, so just do a quick resource check, I'll give a full example of what I mean: function ClientResourceStart(resource) if(getResourceName(resource)=="EXAMPLE")then triggerServerEvent("SomeFunction",localPlayer) end addEventHandler("onClientResourceStart",getRootElement(),ClientResourceStart) Where as "SomeFunction" would be a custom function created server side with all your starting player code and whatnot
  8. Strange, it does reach the event, thus you get the "test2" outputchatbox for it... It is saying expected Element at Argument 2, but getting a Function Well, maybe if you fix the showCursor(false) and showCursor(true)
  9. Ah yes, majqq is right, thank you So try changing the command from "test" to "showexample" or anything more unique that wouldn't mix with already existing hard coded commands
  10. 0 Interior is outside, but your z position is probably too high (1025.732323227) You would end up teleporting somewhere in the sky and then just falling back down to the ground... I don't recall what the Z limit for Interior 0 (Outside) is, but if you were to change below that limit, it would likely teleport you then. Change the Z to 500.0, it will likely work, but you'll also likely fall to your death as well
  11. Well, you just remove ALL those resource lines and then only add in the resource(s) you created To make a resource, you just need a script file and the meta file for it inside a folder or zip file (But keep in mind, your server will have nothing except what you created basically...)
  12. Thank you, you're right, thank you for pointing that out
  13. There are no messages or not even the timer itself either, you will need to work with the base script and then throw in the changes so that you have the entire working script. You won't learn much if you just copy and paste, it's better you construct your own. But here would be the final result anyway: local messages = { "Visit our website at www.google.com!", "Did you know? These messages are automated!", "Add another message here!" } local prefix = "[INFO] #FFFFFF" -- message prefix local interval = 5 -- time between messages (minutes) number = 0 -- Declare the variable outside the function function outputRandomMessage() number = number + 1 -- Add +1 so it changes each time the function is called local msg = messages[number] -- Display the Message outputChatBox(prefix .. msg, root, 3, 169, 244, true) -- Actual Message being sent out to everyone! if number = 3 then -- If it just Displayed the last Message... number = 0 -- Reset it to start all over again end end -- Forgotten End :( setTimer(outputRandomMessage, interval * 60 * 1000, 0) -- Message Timer
  14. addCommandHandler ("test", someFunction) -- Does not match up to the function, case sensitive, it should be: SomeFunction Anyway, my SomeFunction was just an example. If you copy and paste it only, then nothing will ever trigger SomeFunction(), therefore nothing would happen... It was meant for you to look at the example and then use it in your own code at the point you need it. But, just for understanding purposes, if you fix the command handler, then the command will trigger it and will then give you a better idea of how to implent/mod/use it into your own code Look over the Wiki Page for setCameraTarget and you may notice there are 2 ways of using this function IF used clientside: https://wiki.multitheftauto.com/wiki/SetCameraTarget
  15. Hmm, that could be... I'm afraid I'm not familiar with the default resources as I myself cut them ALL out and only use what I create myself... Make some form of backup Then plug and play with it and see what happens, try removing any resource you don't think you use and keep only the ones you actually do use etc.
  16. Instead of root or resourceRoot, try just using getRootElement() instead, for example:
  17. <!-- Specifies resources that are loaded when the server starts and/or which are protected from being stopped. To specify several resources, add more <resource> parameter(s). --> <resource src="EXAMPLE" startup="1" protected="0" /> <resource src="GUIEdit" startup="1" protected="0" /> <resource src="SFXBrowser" startup="1" protected="0" /> </config> Look for something similar in the above code at the very bottom of your mtaserver.conf and this will determine what resources start up automatically on the server. Remove whatever resource lines out that you don't want to auto load on server startup. You may also manually start or stop a resource by simply typing in "start EXAMPLE" or "stop EXAMPLE" in the console to start or stop running a resource. I would recommend getting and using the GUIEditor resource to easily make GUIs with. https://community.multitheftauto.com/index.php?p=resources&s=list&name=guiedit&descr=&category=
  18. skrypt_c.Lua local okno1 = guiCreateWindow(0.32, 0.21, 0.21, 0.27, "PRACA DORYWCZA", false) guiWindowSetSizable(okno1, false) guiSetVisible(okno1, false) local button1 = guiCreateButton(0.03, 0.58, 0.94, 0.38, "Jestem przyciskiem", false, okno1) addEvent("showGUI", true) addEventHandler("showGUI", getRootElement(), function () if (guiGetVisible(okno1) == false) then -- This never triggers because it is never nil (It's either true or false) So changed nil to false guiSetVisible(okno1, true) showCursor(true) end end) This should resolve the issue
  19. If you're just getting back into something, I would look into upgrading if possible rather than to deal with outdated resources/scripts But anyway, the reason it wouldn't work well in recent versions is because there is a 8 year gap and much has changed since 2012...
  20. Yes, let's say you have 2 script files named Server.Lua and Client.Lua. You know what file is which, but we must also tell the server which file is which and that is done in the meta file. <meta> <script src="Server.Lua" type="server" /> <script src="Client.Lua" type="client" /> </meta> Alright, so now then, we want to call something to run from the Client File, so we will make some function in the Client File (AKA Client Side): function ClientTest() -- The custom function name outputChatBox("Test: I'm the Client Script!") -- Just a very basic test message end addEvent("Client-ClientTest",true) -- We must add this event to be able to call it from the Server Script addEventHandler("Client-ClientTest",getRootElement(),ClientTest) -- We must also add this Event Handler to point it correctly at our Function Now we'll be able to call the new function from the Server File (AKA Server Side): function SomeFunction() outputChatbox("This is the Server Script!",source) -- Another very basic message triggerClientEvent(source,"Client-ClientTest",source) -- Calls the Client Side Event/Function end In this example, you would get 2 messages in the chat, one from the Server and the other from the Client If you use setCameraTarget(90, 90, 90) then it will show where ever X(90) is, Y(90) is and Z(90) is and thats not what you want... What you need to do is figure out where you want the camera to be looking at and use the coordinates of that exact location (No angles, rotations, etc)
  21. Sorry, forgot to add the "end" for the function itself... number = 0 -- Declare the variable outside the function function outputRandomMessage() number = number + 1 -- Add +1 so it changes each time the function is called local msg = messages[number] -- Display the Message if number = 3 then -- If it just Displayed the last Message... number = 0 -- Reset it to start all over again end end -- Forgotten End :(
  22. FecharProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? etapas[localPlayer] = true -- This line itself is actually just fine AbrirProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do?
  23. If you're not yet familiar with Lua or MTA's Functions and are just learning, then I have to recommend starting out much more simple. Rather than trying to jump into some complex scripting that is a bank system, make your own very simple command. Once you grasp the basic concept of things, it'll become easier to "mod" something more to your liking... function TestFunction(player,command) outputChatBox("This is just a test!",player,255,255,255) -- Add more code here, keep it simple until you got the very basics of scripting down, then move on to more complex things end addCommandHandler("test",TestFunction)
  24. If you want to allow multiple answers for each question, then continue using check boxes. However, if you want to allow only one answer, then use radio buttons instead. etapas = {}; acertou = {}; function Prova(button) local quantidade = acertou[localPlayer] if button == "left" then if etapas[localPlayer] == false then FecharProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? etapas[localPlayer] = true AbrirProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? elseif etapas[localPlayer] == true then if Pergunta == false then FecharProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? Pergunta = 1 AbrirProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? elseif Pergunta == 1 then if source == opcaoC then if guiCheckBoxGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? Pergunta = 2 AbrirProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? elseif Pergunta == 2 then if source == opcaoC then if guiCheckBoxGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? Pergunta = 3 AbrirProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? end elseif Pergunta == 3 then if source == opcaoC then if guiCheckBoxGetSelected(source) then acertou[localPlayer] = quantidade+1 end end FecharProva -- What is this? A Variable? Its not doing anything... Why is this here or what do you want it to do? if quantidade >= 2 then outputChatBox ( "[TLRP] #34eb3dVocê passou na prova com "..quantidade.." acertos. Parabéns!!", 255, 255, 255, true ) acertou[localPlayer] = 0 etapas[localPlayer] = false; triggerServerEvent(localPlayer, "NSCR:TerminouProva", localPlayer) -- The 1st argument (localPlayer) isn't needed for Server Side Triggers else outputChatBox ( "[TLRP] #ff0000Você falhou na prova com "..quantidade.." acertos e foi kickado. (Maximo de erros: 3)", 255, 255, 255, true ) kickPlayer(localPlayer) end end end end end
  25. Just set the interval for the desired seconds and then just rip out the 60 * setTimer(outputRandomMessage, interval * 1000, 0) -- Now interval is mearsured in seconds instead of minutes As for the order, replace the random bit with a new variable and after each message, add to the variable, also reset it when it reaches the last possible message number = 0 -- Declare the variable outside the function function outputRandomMessage() number = number + 1 -- Add +1 so it changes each time the function is called local msg = messages[number] -- Display the Message if number = 3 then -- If it just Displayed the last Message... number = 0 -- Reset it to start all over again end
×
×
  • Create New...