Jump to content

Mathias Lui

Members
  • Posts

    41
  • Joined

  • Last visited

Everything posted by Mathias Lui

  1. Ou okay I will take a look at that, too ^^
  2. Idk how this bump system works, but I did not realize that. I realized, that the post was very old after I replied, though. Maybe this information was useful to someone else reading this thread.
  3. You can set it to 200 and as long as you fly below the clouds, you can see the whole map
  4. Hello world, I wanted to ask if somebody knows how to add new objects to MTA? Like 3d objects? If I e.g. modeled a house and wanted to import it into my server? I heard that you can do that hardly with replacing an existing object in your game files. But I want to add a new one, so my game files are not modded, so that it is just a resource. Hopefully someone can help me MathiasLui
  5. Lol how did you do that? I'm only an advanced beginner.. I don't do guis yet. This looks awesome!
  6. And how did he do this now? Because I have 3d Models, which I wanna have in my server, not my game, but as a resource. Did you now replace any object to get this object in the game? Or how?
  7. Hey world. I wanted to make a script which gives a desired player a desired amount of money. like /pay player money.. but when I try this with myself, like /pay myself money, it will just give me money, and not subtract it first. So i have 100$, I do /pay myself 100, and then I have 200$ So I don't know any further. Here's my full code with comments... [lua] function pay(playerSource, cmd, player, amount) local playermoney = getPlayerMoney(playerSource) --Don't know why I wrote this but when I deactivate this line, it makes no difference local x, y, z = getElementPosition(playerSource) --get Position of the paying Player local x1, y1, z1 = getElementPosition(getPlayerFromName(player)) --get Position of player who will recieve the money local dist = getDistanceBetweenPoints3D(x, y, z, x1, y1, z1) --gets distance between the two players local playermoney = getPlayerMoney(playerSource) --gets Money of the paying Player local targetmoney = getPlayerMoney(getPlayerFromName(player)) --gets Money of the player who will recieve the money local amount = tonumber(amount) --makes the amount typed in to a number. Amount is the money amount if not player or not amount then --if player or amount wasnt typed in there is a warning message outputChatBox("Usage: /pay Name Amount", playerSource, 255, 0, 0) else --if everything is typed in correctly... if (playermoney >= amount) then --if you have at least as much money as you wanna pay if (dist <= 10) then --and you are maximum 10 meters away from the recieving player setPlayerMoney(playerSource, playermoney-amount) --here's the problem. This should take the desired amount of money away setTimer(function() end, 1000, 1) --and this should be a pause, but it does nothing. btw Is there an easy way to make a pause of 1 second? setPlayerMoney(getPlayerFromName(tostring(player)), targetmoney+amount) --gives the recieving player the desired amount of money outputChatBox(getPlayerName(playerSource).." gave you "..amount.." $!", getPlayerFromName(player), 0, 255, 0) --message to inform both players outputChatBox("You gave "..player.." "..amount.." $!", playerSource, 0, 255, 0) --also just a message else --if the player is not in range to the other player there is a warning message (below) outputChatBox("The desired player is not in range.", playerSource, 255, 0, 0) --just warning message end --ends the distance if-statement else --if you haven't got at least as much money as you wanna pay there is a warning message, which also works (below) outputChatBox("You don't have enough money.", playerSource, 255, 0, 0) --just warning message end --ends playermoney if-statement end --ends typing correctly if-statement end --ends the whole pay function addCommandHandler("pay", pay) --command. Usage /pay target money [/lua] The meta isn't the problem. Just a server sided script. hope you can help me!
  8. That's a good idea. I didn't have that in mind. Just...I'm not familiar with timers, for loops and repeat and while loops. There aren't any good tutorials out there on the net.
  9. Thanks guys. After a bit I found it out myself and then I realized someone has answered. Thanks guuuys
  10. Hello Community, I hope this is in the right section. I wanted to ask you if you like this resource I made, or if you have any improvement suggestions. This is one of my first scripts. Here's the link: https://community.multitheftauto.com/in ... s&id=13524 would be great if you would take some minutes and test it. regards Mathias Lui
  11. Hi, how can I check, if a player is currently in the chatbox? e.g. I made a tiny script where the mouse cursor is showing when pressing the m or ralt key, or I made a script where you can jump with the vehicle by pressing z. but all these things also happen when typing Z or M in the chatbox. And I don't want them to jump when they type Z
  12. Hi, I wanted to make a script, which saves the money from a player, if he logs out or leaves, and then sets the money to 0. When he logs in again he should get the money back. With my first method it worked. I just saved the money amount in a text file. Now, I tried it with setAccountData, but there is one little Error. My first (working) script: function playerQuit() local playeracc = getPlayerAccount( source ) if (playeracc) and not isGuestAccount(playeracc) then local playername = getPlayerName( source ) local playercash = tostring(getPlayerMoney( source )) local fileHandle = fileCreate( "bankaccounts/"..playername..".txt" ) if fileHandle then fileWrite( fileHandle, playercash ) fileClose( fileHandle ) end end setPlayerMoney( source, 0 , true ) end function playerLogin() local playername = getPlayerName( source ) local playeracc = getPlayerAccount( source ) if (playeracc) and not isGuestAccount(playeracc) then local playername = getPlayerName( source ) local fileHandle = fileOpen( "bankaccounts/"..playername..".txt" ) local filesize = fileGetSize( fileHandle ) local money = fileRead( fileHandle, filesize ) setPlayerMoney( source, tonumber(money), true ) fileClose( fileHandle ) end end addEventHandler( "onPlayerLogin", getRootElement(), playerLogin ) addEventHandler( "onPlayerQuit", getRootElement(), playerQuit ) addEventHandler( "onPlayerLogout", getRootElement(), playerQuit ) my 2nd (not working) script: function playerQuit() local playeracc = getPlayerAccount( source ) if (playeracc) and not isGuestAccount(playeracc) then local playername = getPlayerName( source ) local playercash = getPlayerMoney( source ) setAccountData(playeracc, "cash", playercash) end setPlayerMoney( source, 0 , true ) end function playerLogin() local playername = getPlayerName( source ) local playeracc = getPlayerAccount( source ) if (playeracc) and not isGuestAccount(playeracc) then local playername = getPlayerName( source ) local money = getAccountData(playeracc, "cash") setPlayerMoney( source, tonumber(money), true ) end end addEventHandler( "onPlayerLogin", getRootElement(), playerLogin ) addEventHandler( "onPlayerQuit", getRootElement(), playerQuit ) addEventHandler( "onPlayerLogout", getRootElement(), playerQuit ) The error is in line 18. It says, it setPlayerMoney, expected a number in argument 2, but got nil. But I saved it as a number, didn't I? And also I wrote tonumber. would appreciate help. Mathias Lui
  13. Hi, i created a train, which drives along the tracks, but when I try to get in, it respawns, and I don't want players to get into this vehicle. Also the train only spawns, or drives, when in draw distance, so when I leave, get back, the train continues driving. But only when it is in somebodys draw distance. How can I change that?
  14. Hey. I wanted to make a script, which looks, if a file with the player's name already exists. usage: /setlicence playername 1/0 playername = target, which we wanna give (1) or remove (0) the driving licence. If a file with his name exists in this folder, there comes a fitting message. My script is serverside, and gives no errors... but I don't get a message, if it worked, and I can't delete or add my driving licence either... how = 0 or 1 function setLicence( playerSource, command, target, how ) how = how if how then targetsource = getPlayerFromName(target) adminname = getPlayerName(playerSource) accountName = getAccountName(getPlayerAccount(playerSource)) if isObjectInACLGroup("user."..accountName , aclGetGroup("Admin")) then if (fileExists(":wangcars/licences/"..target..".txt")) then local fileHandle = fileOpen(":wangcars/licences/"..target..".txt") if fileHandle then end end if (fileExists(":wangcars/licences/"..target..".txt")) and (how == 1) then outputChatBox( "The player already has a driving licence.", playerSource, 255, 0, 0 ) elseif (fileExists(":wangcars/licences/"..target..".txt")) and (how == 0) then fileDelete(fileHandle) outputChatBox("You deleted the driving licence of "..target".", playerSource, 0, 255, 0 ) outputChatBox("Your driving licence has been deleted by "..adminname.."!", targetSource, 255, 0, 0 ) elseif not (fileExists(":wangcars/licences/"..target..".txt")) and (how == 1) then fileHandle = fileCreate(":wangcars/licences/"..target..".txt") fileWrite(fileHandle, "--Got a driving licence by an admin--") fileClose(fileHandle) outputChatBox("You gave the player "..target.." a driving licence.", playerSource, 0, 255, 0 ) outputChatBox("You got a driving licence from "..adminname, targetsource, 0, 255, 0 ) elseif not (fileExists(":wangcars/licences/"..target..".txt")) and (how == 0) then outputChatBox("The player already hasn't got a driving licence.", playerSource, 255, 0, 0 ) end else outputChatBox("It is not confirmed, that you are an admin.", playerSource, 255, 0, 0 ) end else outputChatBox("Please enter a number. 1 = yes, 0 = no", playerSource, 255, 0, 0 ) end end addCommandHandler( "setlicence", setLicence )
  15. I fixed it by doing "if not" in line 7 now its working thanks! EDIT: Ah I see you changed it too function havelicence(playerSource,seat) if seat == 0 then local account = getPlayerAccount(playerSource) if account and not isGuestAccount(account) then local licence = getAccountData(account,"licence") if not licence then outputChatBox( "You do not have a driving licence. Buy one at Wang Cars for 1200$!",playerSource, 255, 0, 0 ) cancelEvent() end end end end addEventHandler("onVehicleStartEnter", getRootElement(), havelicence )
  16. I tried again and now I can buy a licence, but when I enter a vehicle with a licence, it says that I don't have one
  17. Thanks. The console says, that you forgot the "then" in line 12 And the begin bracket in line 28 And you forgot to end the first function and your script overall isn't working thank you you can still enter any vehicle without driving licence, and when you bought your driving licence (now you can buy unlimited ) you can't delete it anymore... EDIT: okay ill try again
  18. Thanks guys, I will implement that account and guest account thing! Didn't thought about that. EDIT:// Don't you have to use setAccountData first? so that licence can be stored there?
  19. So in the first you just changed, that it will get the account? And In the second, you also changed, that it will get the account, instead of the name? And you changed getRootElement() to root? 1. Did you change something else? 2. Why root instead of getRootElement()? Note: in the buy licence script there is a pedhealth variable, which wasn't meant to be there ;D I first tried to look whether pedhealth >= 1 so you can ignore the variable.
  20. Hi, i made a little script where someone can buy a driving licence for 1200$, and it works like a charm. If the player hasn't got one yet, a new file with the player's name will be created, and you can always check if a player has a driving licence, by checking whether there's a file with his name or not. Now, everytime a player enters a vehicle I want to check if the player has a licence. If not, the player will be forced out of the vehicle, and a text shows up in the chatbox. If yes, nothing will happen and the player is able to continue driving. But my script doesn't work. If I enter a vehicle with no driving licence, I can still drive it without any issues. Also, can I force the player to get out of the vehicle without removePedFromVehicle? I mean, like he then just leaves the vehicle, as if he pressed F. First, if it matters, the working script for the licence: desk = createObject( 2165, -1952.6999511719, 293.79998779297, 34.5, 0, 0, 90 ) ped = createPed( 69, -1952, 294, 35.5, 89.9986267, false ) function wangcars( playerSource ) local x, y, z = getElementPosition( playerSource ) local px, py, pz = getElementPosition( ped ) local dist = getDistanceBetweenPoints3D( x, y, z, px, py, pz ) local pedhealth = getElementHealth( ped ) if ( dist < 3 ) and not ( isPedDead( ped ) ) then local playername = getPlayerName( playerSource ) local playermoney = getPlayerMoney( playerSource ) if ( fileExists( "licences/"..playername..".txt" ) ) then outputChatBox( "You already bought a driving licence.", playerSource, 255, 0, 0 ) elseif ( playermoney < 1200 ) then outputChatBox( "You don't have enough money. A driving licence costs 1200$!", playerSource, 255, 0, 0 ) else outputChatBox( "You have successfully bought a driving licence for 1200$. #BD0000Type /dellicence to delete your driving licence.", playerSource, 28, 189, 0, true ) local fileHandle = fileCreate( "licences/"..playername..".txt" ) setPlayerMoney( getPlayerFromName( playername ), playermoney - 1200 ) if ( fileHandle ) then fileWrite( fileHandle, "--Bought a driving licence--" ) fileClose( fileHandle ) end end else outputChatBox( "Since you or someone else killed the trader, you can't buy a driving licence. Ask an administrator for help.", playerSource, 255, 0, 0 ) return end end addCommandHandler( "buylicence", wangcars ) --the player also has the ability to delete his licence: function dellicence( playerSource ) local playername = getPlayerName( playerSource ) if ( fileExists( "licences/"..playername..".txt" ) ) then fileDelete( "licences/"..playername..".txt" ) outputChatBox( "You deleted your driving licence.", playerSource, 0, 255, 0 ) else outputChatBox( "You don't have a driving licence!", playerSource, 255, 0, 0 ) end end addCommandHandler( "dellicence", dellicence ) and the non-working script, to check if a player has a driving licence to get him out of a vehicle: function havelicence( playerSource ) local veh = getPedOccupiedVehicle( playerSource ) if ( veh ) then local vehseat = getPedOccupiedVehicleSeat( playerSource ) if ( vehseat = 0 ) then if not( fileExists( "licences/"..playername..".txt" ) ) then removePedFromVehicle( playerSource ) outputChatBox( "You do not have a driving licence. Buy one at Wang Cars for 1200$!", 255, 0, 0 ) return else return end else return end end end addEventHandler( "onPlayerVehicleEnter", getRootElement(), havelicence ) I would appreciate some help
  21. Mathias Lui

    Fly Job

    Hey, I wanted to replicate a job from a server. You go in a marker, spawn in an andromada, and fly to 1 of 3 airports with math.random (that looks fine yet). And now what I can't do: I want the person, which flies, to get teleported back to the marker if the person leaves the vehicle. And I want everything to get removed, when the destination marker is hit. I can only fly through the end marker, and nothing happens. Also I can easily leave the vehicle without getting respawned. When the destinationmarker is hit, The marker, blip and plane shall be removed, player gets respawned, and the player should get 450$. The variable FF stands for the airport in the top middle (with all the broken airplanes). Also I have scriptet about a week yet, so I'm a beginner. The Event Handlers should call the functions in the main function when one of the markers is hit. At least I get no console errors... Or is it wrong that I put functions into other functions? I don't know how to do it otherwise. btw has somebody got a good tutorial for "for"-loops? I don't know what pairs and ipairs are, and so on... here's my full code: jobmarker = createMarker( -1414.59399, -299.01044, 6.20313, "corona", 1, 255, 255, 0 ) inPlane = false function inMarker( playerSource ) dim = math.random( 1, 65535 ) money = getPlayerMoney( playerSource ) skin = getElementID( playerSource ) setElementDimension( playerSource, dim ) plane = createVehicle( 592, -1633, -470.7998046875, 23.200000762939, 0, 0, 45.499877929688 ) setElementDimension( plane, dim ) warpPedIntoVehicle( playerSource, plane, 0 ) inPlane = true ort = math.random( 1, 3 ) if ( ort == 1 ) then outputChatBox( "Fliege dein Flugzeug unbeschaedigt zum Flugzeugfriedhof.", playerSource, 255, 255, 0 ) FFMarker = createMarker( 397.70001220703, 2503.6999511719, 16.5, "ring", 10, 255, 0, 0 ) setElementDimension( FFMarker, dim ) FFBlip = createBlip( 397.70001220703, 2503.6999511719, 16.5, 0, 2, 255, 0, 0, 255, 0, 99999 ) setElementDimension( FFBlip, dim ) function FFExit( playerSource ) inPlane = false spawnPlayer( playerSource, -1417.73401, -301.96399, 6.20313, 0, skin, 0, 0 ) setElementDimension( playerSource, 0 ) destroyElement( FFMarker ) destroyElement( FFBlip ) destroyElement( plane ) outputChatBox( "Auftrag gescheitert: Fahrzeug verlassen!", playerSource, 255, 0, 0 ) setPlayerMoney( playerSource, money ) end function FFHit( playerSource ) inPlane = false spawnPlayer( playerSource, -1417.73401, -301.96399, 6.20313, 0, skin, 0, 0 ) setElementDimension( playerSource, 0 ) destroyElement( FFMarker ) destroyElement( FFBlip ) destroyElement( plane ) outputChatBox( "Du bekommst 450$!", playerSource, 0, 255, 0 ) return setPlayerMoney( playerSource, money + 450 ) end elseif ( ort == 2 ) then outputChatBox( "Fliege dein Flugzeug unbeschaedigt zum Las Venturas Airport.", playerSource, 255, 255, 0 ) LVMarker = createMarker( 1429.3000488281, 1463.3000488281, 10.800000190735, "ring", 10, 255, 0, 0 ) setElementDimension( LVMarker, dim ) LVBlip = createBlip( 1429.3000488281, 1463.3000488281, 10.800000190735, 0, 2, 255, 0, 0, 255, 0, 99999 ) setElementDimension( LVBlip, dim ) function LVExit( playerSource ) inPlane = false spawnPlayer( playerSource, -1417.73401, -301.96399, 6.20313, 0, skin, 0, 0 ) setElementDimension( playerSource, 0 ) destroyElement( LVMarker ) destroyElement( LVBlip ) destroyElement( plane ) outputChatBox( "Auftrag gescheitert: Fahrzeug verlassen!", playerSource, 255, 0, 0 ) return setPlayerMoney( playerSource, money ) end function LVHit( playerSource ) inPlane = false spawnPlayer( playerSource, -1417.73401, -301.96399, 6.20313, 0, skin, 0, 0 ) setElementDimension( playerSource, 0 ) destroyElement( LVMarker ) destroyElement( LVBlip ) destroyElement( plane ) outputChatBox( "Du bekommst 450$!", playerSource, 0, 255, 0 ) return setPlayerMoney( playerSource, money + 450 ) end else outputChatBox( "Fliege dein Flugzeug unbeschaedigt zum Los Santos International Airport.", playerSource, 255, 255, 0 ) LSMarker = createMarker( 1837.3000488281, -2493.8999023438, 13.60000038147, "ring", 10, 255, 0, 0 ) setElementDimension( LSMarker, dim ) LSBlip = createBlip( 1837.3000488281, -2493.8999023438, 13.60000038147, 0, 2, 255, 0, 0, 255, 0, 99999 ) setElementDimension( LSBlip, dim ) function LSExit( playerSource ) inPlane = false spawnPlayer( playerSource, -1417.73401, -301.96399, 6.20313, 0, skin, 0, 0 ) setElementDimension( playerSource, 0 ) destroyElement( LSMarker ) destroyElement( LSBlip ) destroyElement( plane ) outputChatBox( "Auftrag gescheitert: Fahrzeug verlassen!", playerSource, 255, 0, 0 ) --means "left vehicle" return setPlayerMoney( playerSource, money ) end function LSHit( playerSource ) inPlane = false spawnPlayer( playerSource, -1417.73401, -301.96399, 6.20313, 0, skin, 0, 0 ) setElementDimension( playerSource, 0 ) destroyElement( LSMarker ) destroyElement( LSBlip ) destroyElement( plane ) outputChatBox( "Du bekommst 450$!", playerSource, 0, 255, 0 ) --means "you earned 450$!" return setPlayerMoney( playerSource, money + 450 ) end end end addEventHandler( "onMarkerHit", jobmarker, inMarker ) addEventHandler( "onPlayerVehicleExit", playerSource, FFExit) addEventHandler( "onPlayerVehicleExit", playerSource, LVExit) addEventHandler( "onPlayerVehicleExit", playerSource, LSExit) addEventHandler( "onMarkerHit", FFMarker, FFHit ) addEventHandler( "onMarkerHit", FFMarker, LVHit ) addEventHandler( "onMarkerHit", FFMarker, LSHit ) --on my screen it says "LS Hit"(without space) and when I submit it, it says ":~"
  22. Okay thanks, ill take a closer look at the timer. never heard about that before.
  23. Hey, my script isn't fully working. It teleports you into the city hall, but there is no fadeCamera visible. You get immediately teleported into the interior. Also is there a difference between source, playerSource and thePlayer? I get confused, which one to use, because I can't seem to find a full list of this words. EDIT:// It's all server sided local markerOut = createMarker( -2766.11597, 375.50665, 6.33468, "corona", 2, 255, 0, 0, 255 ) local markerIn = createMarker( 389.69968, 173.86449, 1008.38281, "corona", 2, 255, 0, 0, 255) setElementInterior( markerIn, 3 ) function markerHitOut( playerSource ) fadeCamera( playerSource, false, 2.0, 255, 0, 0 ) setElementInterior( playerSource, 3, 387.18585, 173.86874, 1008.38281 ) fadeCamera( playerSource, true, 1.0 ) end addEventHandler( "onMarkerHit", markerOut, markerHitOut ) function markerHitIn( playerSource ) fadeCamera( playerSource, false, 2.0 ) setElementInterior( playerSource, 0, -2762.59839, 375.23846, 5.69544 ) fadeCamera( playerSource, true, 1.0 ) end addEventHandler( "onMarkerHit", markerIn, markerHitIn )
  24. If you read the text you can see Name = guy i want to check if hes in a vehicle Vehicle = vehicle name
×
×
  • Create New...