kevin433 Posted July 1, 2010 Share Posted July 1, 2010 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? Link to comment
Spider Pork Posted July 1, 2010 Share Posted July 1, 2010 Create a checkpoint server-side. Then create a client-side event with the code to delete the checkpoint then server-side trigger it when you want to delete the checkpoint. Maybe that'll work? Link to comment
kevin433 Posted July 1, 2010 Author Share Posted July 1, 2010 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) Link to comment
MaddDogg Posted July 1, 2010 Share Posted July 1, 2010 First of all you should use English identifiers and function names, otherwise people, who don't speak your language, won't be able to understand your script properly (although I am lucky right now). Actually I don't really get your script, but still some questions: 1. Do you get any server- or clientside errors? 2. When exactly do you get infinite money? When unloading the truck or at emptying a trash can? It seems like you don't re-randomize randommuell. So it seems like you just recreate the same checkpoint over and over again. This results in an infinite loop of calling this function, as long as you stay at this point. You could definitely improve your script, because all those if and else blocks do almost the same thing, just some output or some value is different. Rewriting it to an improved script would be very helpful, since it would be way more readable. Link to comment
kevin433 Posted July 1, 2010 Author Share Posted July 1, 2010 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? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now