Jump to content

kevin433

Members
  • Posts

    66
  • Joined

  • Last visited

Everything posted by kevin433

  1. Yeah, sorry. I didn't thought of that when I created the script. The problem is that I don't need help very often, and then I write automatically in my language. (Either norwegian or german) 1. No, I didn't get any errors 2. I got infinite money when I stayed in the checkpoint and the checkpoint were I had to empty it was the same I was standing in. That was the problem. I fixed it now. Thanks! Can you just show me a little snippet of code which show how I can improve it?
  2. Ok, I now decided to make it Client and Server-side, but I have some problems. When I enter the checkpoint the ckeckpoint doesn't get deleted and I just get infinite money. Can someone help me with this? here's my code: Client-side: MullCheckpoints = { {-2363.0908203125,1017.8466796875, 50.6953125}, --> SF {-1723.16015625,1368.2421875, 7.046875}, {-1803.8447265625,959.4697265625, 24.890625}, {-1930.8134765625,831.3427734375, 38.341430664063}, {-1813.7744140625,615.0048828125, 35.171875}, {-2685.2626953125,270.13671875, 4.3359375}, {-2333.34375,-133.62890625, 35.3203125}, -- <-- SF {-2146.5927734375,-2445.44921875, 30.625}, -- ANGEL PINE {784.13671875,-1607.7431640625, 13.3828125}, --> LS {1194.9658203125,-880.6630859375, 43.038318634033}, {2116.013671875,-1777.853515625, 13.390511512756}, {2374.3203125,-1936.41796875, 13.546875}, {2393.4794921875,-1492.53515625, 23.828125}, {2337.5322265625,73.4375, 26.479593276978}, {206.5341796875,-170.6806640625, 1.578125}, -- <-- LS {1903.111328125,2099.689453125, 10.8203125}, {2059.3154296875,2214.3447265625, 10.8203125}, {2147.62109375,2812.025390625, 10.8203125}, {2369.4150390625,2575.9501953125, 10.8203125}, {2441.6962890625,2002.6728515625, 10.8203125}, {2630.16796875,1843.37109375, 10.8203125}, {2627.6259765625,1669.390625, 10.8203125}, {2842.8544921875,2393.1708984375, 10.8203125} } function MarkerCreaten() randommuell = math.random(#MullCheckpoints) muellblip = createBlip(MullCheckpoints[randommuell][1],MullCheckpoints[randommuell][2],MullCheckpoints[randommuell][3], 11, 2, 255,0,0,170, 0, 99999.0) muellmark = createMarker(MullCheckpoints[randommuell][1],MullCheckpoints[randommuell][2],MullCheckpoints[randommuell][3],"checkpoint", 6.0, 255,0,0,170) end addEvent("MuellMarkerCreaten", true) addEventHandler("MuellMarkerCreaten", getRootElement(), MarkerCreaten) function CheckpointHit(player) if(getElementData(player, "MussEntleeren") == 0) then if(getElementData(player, "Muell") >= 100) then destroyElement(muellblip) destroyElement(muellmark) muellblip = createBlip(-1871.685546875,-1718.490234375, 21.75, 11, 2, 255,0,0,170,0,99999.0) muellmark = createMarker(-1871.685546875,-1718.490234375, 21.75, "checkpoint", 6.0, 255,0,0,170) outputChatBox("Du musst deinen Trashmaster entleeren!") setElementData(player, "MussEntleeren", 1) else destroyElement(muellblip) destroyElement(muellmark) muellblip = createBlip(MullCheckpoints[randommuell][1],MullCheckpoints[randommuell][2],MullCheckpoints[randommuell][3], 11, 2, 255,0,0,170, 0, 99999.0) muellmark = createMarker(MullCheckpoints[randommuell][1],MullCheckpoints[randommuell][2],MullCheckpoints[randommuell][3],"checkpoint", 6.0, 255,0,0,170) local muellrandom = math.random(30) triggerServerEvent("Geldbekommen", getLocalPlayer(), player, muellrandom) outputChatBox("Du hast "..muellrandom.." Muelleinheiten geladen!") setElementData(player, "Muell", getElementData(player, "Muell")+muellrandom) end else destroyElement(muellblip) destroyElement(muellmark) muellblip = createBlip(MullCheckpoints[randommuell][1],MullCheckpoints[randommuell][2],MullCheckpoints[randommuell][3], 11, 2, 255,0,0,170, 0, 99999.0) muellmark = createMarker(MullCheckpoints[randommuell][1],MullCheckpoints[randommuell][2],MullCheckpoints[randommuell][3],"checkpoint", 6.0, 255,0,0,170) outputChatBox("Du hast deinen Trashmaster entleert und 1000$ verdient!") triggerServerEvent("Geldbekommen", getLocalPlayer(), player, 166.66667) setElementData(player, "MussEntleeren", 0) setElementData(player, "Muell", 0) end end addEventHandler("onClientMarkerHit", getRootElement(), CheckpointHit) Server-side function MuellMoney(player, muell) if(getElementData(player, "InJob") == 1) then if(getElementData(player, "Hauptjob") == 5 or getElementData(player, "Hauptjob") == 6) then if(getPedSkin(player) == 27) then if(player and muell) then setElementData(player, "Muell", 0) local rechnung = muell*6 setElementData(player, "Geld", getElementData(player, "Geld")+rechnung) setPlayerMoney(player, getElementData(player, "Geld")) outputChatBox("Dein Trashmaster wurde entleert und du hast ".. rechnung .."$ verdient!", player) end end end end end addEvent("Geldbekommen", true) addEventHandler("Geldbekommen", getRootElement(), MuellMoney)
  3. Hello everyone! I'm currently trying to create a "trash" job for my server. The objective is to get in the Trashmaster, and then random a checkpoint appears. Each time the person enters the checkpoint, a random value gets added to the existing value of the person, and if the value is e.g above 100, he must drive back to a specific checkpoint where he gets his value updatet to 0. My only problem with this is to create the Checkpoints. I really want this to be server-side, but when I create a checkpoint and then delete it, it gets deleted for everyone. Is there any other way to make it server-side without deleting the checkpoint for everyone, or do I just have to do it client-side?
  4. Try this (Not tested, but I think it should work): function enterVehicle (player) local id = getElementModel (source) if normalcars[getElementModel (source)] then if (getAccountData (getPlayerAccount (player), "License-A") == "false") then --removePedFromVehicle ( player) outputChatBox ( "You're not allowed to drive this car! Buy a license at the office!", player,255,0,0 ) cancelEvent() elseif (getAccountData (getPlayerAccount (player), "License-A") == "true") then outputChatBox ( "You're allowed to drive this car!", player) end elseif aircrafts[getElementModel (source)] then if (getAccountData (getPlayerAccount (player), "License-B") == "false") then --removePedFromVehicle (player) outputChatBox ( "You're not allowed to fly this aircraft! Buy a license at the office!", player,255,0,0 ) cancelEvent() elseif (getAccountData (getPlayerAccount (player), "License-B") == "true") then outputChatBox ( "You're allowed to fly this aircraft!", player) end elseif military[getElementModel (source)] then if (getAccountData (getPlayerAccount (player), "License-C") == "false") then --removePedFromVehicle (player) outputChatBox ( "You're not allowed to use military vehicles or aircrafts! Buy a license at the office!", player,255,0,0 ) cancelEvent() elseif (getAccountData (getPlayerAccount (player), "License-C") == "true") then outputChatBox ( "You're allowed to use military vehicles or aircrafts!", player) end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) As MaddDog said, source is not the player, but the vehicle which has been entered.
  5. Thank you varez and 50p! Works great now!
  6. I'd like to answer your question but I don't get your idea. I meant when the remaining gas in the Gasstation is dropping, the fuel price is getting higher per liter. Like this: Remaining Gas in station: 500 Remaining gas in Car: 50/70 "standard" gas price: 9$ After I have filled up my car it should be like this:
  7. Hi, I'm currently trying to fix my vehicle system, since it was messed up. I store the car information in the SQL Database, and I want to create a DB with this: executeSQLCreateTable("Vehicles", "CarID INT IDENTITY,Owner TEXT ,ModelID INTEGER, PosX FLOAT, PosY FLOAT, PosZ FLOAT, PosRotX FLOAT,PosRotY FLOAT, PosRotZ FLOAT, Color1 INT, Color2 INT, Color3 INT, Color4 INT, Damage FLOAT, KMH1 INT, KMH2 INT, MaxFuel INT, CurrentFuel INT, Locked INT") I want to give "CarID" a uniqe ID, so every vehicle can have a uniqe ID. But IDENTITY isn't working, it doesn't even set a value in the "CarID" field. I also tried "AUTO_INCREMENT", but this also doesn't work. EDIT: Fixed it....
  8. I just added the coordinates from every Gas Station right to in the Table, and now I just load the remaining gas amount in the Gas Station with a "Gas Station ID". Here's a little question, because I don't want to create a new Topic just because of a small math thing: How can I get a higher Gas price when the amount of gas is getting "smaller"?
  9. I've created a Table in the SQL Database, and it's layout is like this: PosX FLOAT PosY FLOAT PosZ FLOAT Liter (amount of fuel in english) INTEGER I then want to store them into a table when I start the server.
  10. Thank you 50p! My last thing I want to ask is: How should I load them into the Table?
  11. Hi, I just wondered how I set up tables which have e.g 3 coords and this 5 times. Like this: x,y,z x2,y2,z2 x3,y3,z3 I know how to do it in SA:MP, but not in MTA. I've also searched through the forum and google for a tutorial for "how I create tables in LUA", but I didn't found anything like this. I want this because I want to load multiple coordinates for the gas stations, and then later check if the Player is near them.
  12. Thanks for your answer Hankey. We re-installed GTA and MTA, and then it finally worked.
  13. Hi, My friend got a problem. When he starts MTA, he is sees the splash-screen, but the game is minimzed. He then can't maximize it, it won't "open". After that he has to stop the .exe through the Task-manager. I searched in the forum for solutions, but everything we tried didn't work. We also tried the "Known issues" page on the MTA WIKI, but those solutions didn't work either. His PC specs are: Windows 7 Home Premium 64-bit Intel Core 2 Dou T6600 @ 2.2GHz Ati Radeon HD 4570 4GB RAM The singleplayer and SA:MP are also working. We tried to run MTA with admin' rights and run with the gta_sa.exe and the MultiTheftAuto.exe in XP Service Pack 3.0 compatible mode. But that didn't work either. We both wonder now why it doesn't work.
  14. Found it there. Thanks robhol!
  15. Before I started scripting in MTA:SA I've messed around with some files. I wanted to test something out, therefore I wrote the word "ROFL" in the code of a file I don't remember the name of. Now everytime I start my server it says: "ROFL" is in the same colour as the "Connected!" message. I've searched through every resource that that my server has running, but I haven't found "ROFL" in any of them. I've even searched through the Server-files for the word "ROFL", but it's neither there. When I deactivated the resource "admin" it disappeared. I then searched through the code of it again, but I couldn't find it. Where else can it be?
  16. kevin433

    The White Rabbit

    Isn't a .dmp file a dump file? I don't have a program to open dump files with, but a program is aviable at microsoft.com for this. The problem is just that it's over 600MB big, and it takes ages with my Netbook to download this.
  17. kevin433

    The White Rabbit

    I also found something in the pastebin code. From line 15 to 16 it says: the tests so far have been highly success(full)? and we're looking at ..... couldn't find more. Don't know if this has anything to say.
  18. I changed the Query now to Update... I'm executing isVehicleLocked client side. I thought that it didn't was nesaccary to post the whole checkowner.lua. Here is the whole: function OpenCar() local spieler = getLocalPlayer() if(isPedInVehicle(spieler)) then local vehicle = getPedOccupiedVehicle(spieler) if(getElementData(vehicle, "Owner") == getPlayerName(spieler)) then if(getElementData(vehicle,"Locked") == 1) then setElementData(vehicle, "Locked", 0) setVehicleLocked(vehicle, false) CarLockSound() triggerServerEvent("SC", getLocalPlayer(), vehicle) end end else local x, y, z = getElementPosition ( spieler ) local rot = getPedRotation ( spieler ) local radius = 4 local lx = x + math.sin ( math.rad ( -rot ) ) * radius local ly = y + math.cos ( math.rad ( -rot ) ) * radius local hit, hx, hy, hy, element = processLineOfSight ( x, y, z, lx, ly, z ) if (hit and getElementType(element) == "vehicle") then if(getElementData(element,"Owner") == getPlayerName(spieler)) then if(getElementData(element, "Locked") == 1) then setElementData(element, "Locked", 0) setVehicleLocked(element, false) CarLockSound() triggerServerEvent("SC", getLocalPlayer(), element) end end end end end function CloseCar() local spieler = getLocalPlayer() if(isPedInVehicle(spieler)) then local vehicle = getPedOccupiedVehicle(spieler) if(getElementData(vehicle, "Owner") == getPlayerName(spieler)) then if(getElementData(vehicle,"Locked") == 0) then setElementData(vehicle, "Locked", 1) setVehicleLocked(vehicle, true) CarLockSound() triggerServerEvent("SC", getLocalPlayer(), vehicle) end end else local x, y, z = getElementPosition ( spieler ) local rot = getPedRotation ( spieler ) local radius = 4 local lx = x + math.sin ( math.rad ( -rot ) ) * radius local ly = y + math.cos ( math.rad ( -rot ) ) * radius local hit, hx, hy, hy, element = processLineOfSight ( x, y, z, lx, ly, z ) if (hit and getElementType(element) == "vehicle") then if(getElementData(element,"Owner") == getPlayerName(spieler)) then if(getElementData(element, "Locked") == 0) then setElementData(element, "Locked", 1) setVehicleLocked(element, true) CarLockSound() triggerServerEvent("SC", getLocalPlayer(), element) end end end end end function CreateKeyPicture() KeyBild = guiCreateStaticImage(0.86,0.4,0.0859,0.1829,"pictures/key.png",true) guiSetAlpha(KeyBild,1) CloseButton = guiCreateButton(0.3232,0.3544,0.3737,0.1392,"",true,KeyBild) guiSetAlpha(CloseButton,0.5) OpenButton = guiCreateButton(0.3333,0.7532,0.3737,0.1582,"",true,KeyBild) guiSetAlpha(OpenButton,0.5) guiSetVisible(KeyBild, false) addEventHandler("onClientGUIClick", CloseButton, CloseCar, false) addEventHandler("onClientGUIClick", OpenButton, OpenCar, false) end function ShowCarKey() if(guiGetVisible(KeyBild) == true) then guiSetVisible(KeyBild, false) showCursor(false) else guiSetVisible(KeyBild, true) showCursor(true) end end function checkvehicleowner(player) if(getElementData(source, "Locked") == 1 and isVehicleLocked(source) == true) then if(getElementData(source, "Owner") == getPlayerName(player)) then setVehicleLocked(source, true) setElementData(source, "Locked", 1) else setVehicleLocked(source, true) setElementData(source, "Locked", 1) end else end end addEventHandler("onClientVehicleStartEnter", getRootElement(), checkvehicleowner)
  19. Hi, I've made a GUI where you can lock and open your car even if you're standing outside of it, but it just works the half way. When I open it it says 0 = Not locked. When I then close it it says 0 = Not locked. I don't know why. Can anyone please help me? checkowner.lua function OpenCar() local spieler = getLocalPlayer() if(isPedInVehicle(spieler)) then local vehicle = getPedOccupiedVehicle(spieler) if(getElementData(vehicle, "Owner") == getPlayerName(spieler)) then if(getElementData(vehicle,"Locked") == 1) then setElementData(vehicle, "Locked", 0) setVehicleLocked(vehicle, false) CarLockSound() triggerServerEvent("SC", getLocalPlayer(), vehicle) end end else local x, y, z = getElementPosition ( spieler ) local rot = getPedRotation ( spieler ) local radius = 4 local lx = x + math.sin ( math.rad ( -rot ) ) * radius local ly = y + math.cos ( math.rad ( -rot ) ) * radius local hit, hx, hy, hy, element = processLineOfSight ( x, y, z, lx, ly, z ) if (hit and getElementType(element) == "vehicle") then if(getElementData(element,"Owner") == getPlayerName(spieler)) then if(getElementData(element, "Locked") == 1) then setElementData(element, "Locked", 0) setVehicleLocked(element, false) CarLockSound() triggerServerEvent("SC", getLocalPlayer(), element) end end end end end function CloseCar() local spieler = getLocalPlayer() if(isPedInVehicle(spieler)) then local vehicle = getPedOccupiedVehicle(spieler) if(getElementData(vehicle, "Owner") == getPlayerName(spieler)) then if(getElementData(vehicle,"Locked") == 0) then setElementData(vehicle, "Locked", 1) setVehicleLocked(vehicle, true) CarLockSound() triggerServerEvent("SC", getLocalPlayer(), vehicle) end end else local x, y, z = getElementPosition ( spieler ) local rot = getPedRotation ( spieler ) local radius = 4 local lx = x + math.sin ( math.rad ( -rot ) ) * radius local ly = y + math.cos ( math.rad ( -rot ) ) * radius local hit, hx, hy, hy, element = processLineOfSight ( x, y, z, lx, ly, z ) if (hit and getElementType(element) == "vehicle") then if(getElementData(element,"Owner") == getPlayerName(spieler)) then if(getElementData(element, "Locked") == 0) then setElementData(element, "Locked", 1) setVehicleLocked(element, true) CarLockSound() triggerServerEvent("SC", getLocalPlayer(), element) end end end end end SaveCarLock for the triggerServerEvent function SaveCarLock(id) local vid = getElementID(id) local vlocked = getElementData(id, "Locked") executeSQLQuery("UPDATE Vehicles SET Locked = ? WHERE CarID = ?",vlocked, vid) outputChatBox(getElementData(id, "Locked")) end addEvent("SC", true) addEventHandler( "SC", getRootElement(),SaveCarLock)
  20. Have this now: function OpenCar() local x,y,z = getElementPosition(getLocalPlayer()) for i,vehicle in ipairs(getElementsByType("vehicle")) do local vx,vy,vz = getElementPosition(vehicle) if(getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) <= 4) then if(isElementOnScreen(vehicle)) then outputChatBox(getElementID(vehicle)) end end end end It works! Problem now: I want to get the ID of the Vehicle the player is looking at, because, when I stand between 2 vehicles and both are <=4 then I get both ID's, but I just want to get the one which I'm looking at, that's why I added "isElementOnScreen", but I get both ID's when I stand between them and I just look at one of them while the other car is "behind" my camer.
  21. That's how far I came: GUI Button -> triggerServerEvent -> get elementID's near the player -> ??? I didn't came further than in the example above. Client side: -- Player click a button, then OpenCar gets triggered function OpenCar() triggerServerEvent("CVehicles", getLocalPlayer()) end Server-side: function CheckVehiclesNear() local x,y,z = getElementPosition(source) local newcolshape = createColSphere(x, y, z,5) local vehicles = getElementsWithinColShape(newcolshape, "vehicle") for theKey,vehicles2 in ipairs(vehicles) do outputChatBox(getElementID(vehicles2)) end destroyElement(newcolshape) triggerClientEvent(source,"COnScreen", getRootElement(), vehicles2) end addEvent("CVehicles", true) addEventHandler("CVehicles", getRootElement(), CheckVehiclesNear) Client-side. tried it, but it didn't work: function CarOnScreen(vehicles) for theKey,vehicles2 in ipairs(vehicles) do if(isElementOnScreen(vehicles2)) then outputChatBox(getElementID(vehicles2)) end end end addEvent("COnScreen", true) addEventHandler("COnScreen", getRootElement(), CarOnScreen) Should I maybe set the "triggerClientEvent in the loop in the Server-side script?
  22. The only problem is then that I can't get the Player who triggered the event, because I triggered the "OpenCar" function with a GUI button , but a button doesn't "send" the player with it. So I would have to do this: Press Button -> triggerSeverEvent -> vehicle loop -> triggerClientEvent -> isElementOnScreen. But as I said I can't get the player who triggered the event, or can I?
  23. I made it now Client-side, but it's still not working function OpenCar() local x,y,z = getElementPosition(getLocalPlayer()) local newcolsphere = createColSphere(x,y,z,5) local vehicles = getElementsWithinColShape(newcolsphere, "vehicle") for theKey,vehicles2 in ipairs(vehicles) do if(isElementOnScreen(vehicles2)) then outputChatBox(getElementID(vehicles2)) end end end BTW: I'm still learning the generic for loop.
  24. 65000 Elements. I'm never going to reach that I tried "isElementOnScreen", but it gives me an error: attempt to call global 'isElementOnScreen' (a nil value) That's my code: local x,y,z = getElementPosition(player) local colsphere = createColSphere(x,y,z,5) local vehicles = getElementsWithinColShape(colsphere, "vehicle") for i,vehicles2 in ipairs(vehicles) do if(isElementOnScreen(vehicles2)) then outputChatBox(getElementID(vehicles2)) end end There's more above it in my script, but in that part is the error. I'm using a commandhandler to call the function. When I take out "if(isElementOnScreen(vehicles2)) then" everything works fine. EDIT: Found one wrong thing, I called the function "isElementOnScreen" in a Server-side file
×
×
  • Create New...