Jump to content

Ali_Digitali

Members
  • Posts

    17
  • Joined

  • Last visited

Everything posted by Ali_Digitali

  1. This will save all player serials in a table. Every time someone joins it will check their serials against the ones in the table. Every time you restart your server the table will be cleared, and everyone will be new again. If you want something more permanent you'll need to the things mentioned above. playerSerials = {} -- create a table that will contain all the player serials function setPlayerState() local playerSerial = getPlayerSerial(source) local playerName = getPlayerName(source) for index,theSerial in ipairs(playerSerials) do -- go through the table if (playerSerial == theSerial) then -- if one of the serials matches the current player outputChatBox(playerName.. " has joined the game [Regular Player]",getRootElement(),0,190,90) -- the player is regular return --and we can stop end end outputChatBox(playerName.. "has joined the game [New Player]",getRootElement(),0,190,90) -- if no serial matches, the player is new table.insert(playerSerials,playerSerial) --add them to the table so they won't be new next time end addEventHandler("onPlayerJoin",root,setPlayerState)
  2. Try something like this: g_distance = 0 function addDistance() if x then local xNew,yNew,zNew = getElementPosition(localPlayer) local addedDistance = getDistanceBetweenPoints3D(xNew,yNew,zNew,x,y,z) g_distance = g_distance+addedDistance end x,y,z = xNew,yNew,zNew end addEventHandler ("onClientRender", root, addDistance) It checks the distance you traveled between two frames and adds it to a global counter. You can add aditional checks to see if the player is on foot or not and depending on that add the traveled distance to a different counter.
  3. Hmm, how are you testing this? If you shutdown your server when logging out it will clear all the element data.
  4. Alright, first things first. When using outputChatBox, the second argument tells you who the chat is visible to. If you want the chat to be visible to everyone, you need to use getRootElement() as argument. Look at serverside example #2 here: https://wiki.multitheftauto.com/wiki/OutputChatBox You've also got three functions that are all triggered when a player joins. If you are not using these functions for anything else you can merge them into one function. I think you will achieve the same thing when you use just one key. function setPlayerState() local playername = getPlayerName(source) if (getElementData(source, "regularPlayer")) then -- if this is not defined it will return false outputChatBox(playername.. "has joined the game [Regular Player]",getRootElement(),0,190,90) else setElementData(source,"regularPlayer",true) -- now the data corresponding to key 'regularPlayer' is defined and will return true the next time this player logs in outputChatBox(playername.. "has joined the game [New Player]",getRootElement(),0,190,90) end end addEventHandler("onPlayerJoin",root,setPlayerState) Didn't test this, but this should achieve a similar goal
  5. You can get the screen width and hight with guiGetScreenSize. You can then use something like local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) local scale = screenHeight/10 function createText ( ) dxDrawText ("TEXT HERE",200,200,0, 0, tocolor ( 255, 255, 255, 255 ), scale, "pricedown" ) end function HandleTheRendering ( ) addEventHandler ( "onClientRender", root, createText ) end addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering )
  6. the event on player join has no arguments in the function: https://wiki.multitheftauto.com/wiki/OnPlayerJoin The first error you get is saying your argument thePlayer does not exsist. You need to use source.
  7. There is no built in function that does this. You will either have to script it or find another public resource that does this. I would suggest looking at the zombie mod by Slothman: https://community.multitheftauto.com/ind ... ils&id=347 This spawns zombies that walk around and attack people in the area. I guess that sort of describes what you are looking for.
  8. Have you tried reading the wiki? https://wiki.multitheftauto.com/wiki/GetElementData There are some examples there. When using getElementData you need to pass the element you want data off and a key, which is a string. When using setElementData you need pass a third argument which has the value of the data you want to assign to the key. function setPlayerState(thePlayer) local elementdata = getElementData(thePlayer,"data.joindataold") if (elementdata) then return else setElementData(thePlayer, "data.joindatanew", "actual data you want to input") end end addEventHandler("onPlayerJoin",root,setPlayerState) function checkPlayerState(thePlayer) local check = getPlayerSerial(player) local playername = getPlayerName(thePlayer) if getElementData(thePlayer, "data.joindataold") then outputChatBox(playername.. "has joined the game [Regular Player]",0,190,90) elseif getElementData(thePlayer, "data.joindatanew") then outputChatBox(playername.. "has joined the game [New Player]",0,190,90) end end addEventHandler("onPlayerJoin",root,checkPlayerState) function savePlayerData(thePlayer) setElementData(thePlayer,"Data_key","value of data") end addEventHandler("onPlayerJoin",root,savePlayerData) Try using: [/code ]
  9. These are serverside functions so you cannot use dxDraw. Once you have created the display you need to add people to the display in order for them to see the text.
  10. Why do you need a table for this? When you use models[model] it will return the value you assigned to it. In this case you assigned true to all of the indices in the table. Example: models[2175] = true. This means that when you are using setElementData you are using a boolean as first argument, and this needs to be an element.
  11. Most servers will only need one radio. These are not hardcoded into the mta client, which means that there is not one standard radio resource. They are relatively easy to script, so that's why there are a lot of them. The way you describe it sounds to me like a custom script that lets people listen in. Maybe you'll have better luck talking to someone who actually runs such a script on a server.
  12. There are a lot of these 'apps', search the resource browser for 'radio' and it will return you with all the publicly available radio resources: https://community.multitheftauto.com/ind ... =resources MTA also has function called playSound, which allows for playing .pls files. https://wiki.multitheftauto.com/wiki/PlaySound I'm guessing that most radio resources use this function, but if you want to be sure I suggest looking at the source code of some radio resources.
  13. It was worth a shot, but I just tried it and it doesn't work. The only other instance where I chanced upon engine sounds was when browsing the SFX browser. Not sure if this helps.
  14. You might be able to do this with setVehicleHandling: https://wiki.multitheftauto.com/wiki/SetVehicleHandling Try: setVehicleHandling(theVehicle,"engineType","electric")
  15. function getPlayerFromNamePart(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function trollRandomPlayerWithFire(playerSource,commandName,theTarget) local target = getPlayerFromNamePart(theTarget) -- this function returns the element representing the player, not a name. local troller = getPlayerName(playerSource) if (target) then setPedOnFire(target,true) outputChatBox("You've been set on fire by" .. troller .. "!",root,255,0,0,true) outputDebugString(getPlayerName(target) .. "has been set on fire by" .. troller .. "" ) end end addCommandHandler("fire",trollRandomPlayerWithFire) Tested this serverside and it works. You needed to switch around the two arguments in line 13, and you used theTarget in stead of target in line 16
  16. This command should already be hardcoded, check: https://wiki.multitheftauto.com/wiki/Cl ... e_Commands Of course, if you want more flexibility it's always better to script a small resource that does this.
  17. You have also switched around the arguments for the source and the command name. Try function trollRandomPlayerWithFire(thePlayer,commandName,theTarget)
×
×
  • Create New...