vanishSHC Posted January 5, 2011 Share Posted January 5, 2011 (edited) Okay, I've realized since the beginning that you guys aren't here to code these scripts for me... And I'm not looking to post my entire code here seeing as the amount of people taking code and claiming it as their own nowadays but basically I have 2 functions that don't function as well as I hoped. The Deliver function and the House function. My Deliver Function: function deliver(thePlayer, matchingDimension) if isElementWithinMarker(thePlayer, pizzamarker) then -- if element is indeed in the marker and types /deliver givePlayerMoney(thePlayer, 100) --reward destroyElement (pizzablip) destroyElement (pizzamarker) return mission2(theVehicle,Seat,Jacked) else end end addCommandHandler("deliver", deliver) My House Function: function mission1(theVehicle,seat,jacked) if ( getElementModel ( theVehicle ) == 448 ) then -- if its a pizzaboy outputChatBox("You have entered a Pizza Delivery Vehicle, Deliver the Pizza to the Red House Blip on your MiniMap and type /deliver!", source,255,0,0) pizzablip = createBlip(2363.1,-1672.0, 13.5, 32, 2, 255, 0, 0) pizzamarker = createMarker(2363.1,-1672.0, 12.8, "cylinder", 2, 255, 0, 0) end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), mission1 ) function mission2(theVehicle,seat,jacked) outputChatBox("Okay! That went well, You're next delivery is up! Don't forget to use /deliver!", source,255,0,0) pizzablip = createBlip(2157.4, -1792.0 ,13.3, 32, 2, 255, 0, 0) pizzamarker = createMarker(2157.4, -1792.0 ,13.3,"cylinder", 2, 255, 0, 0) end Now my issues are that each individual house that I have programmed with the "pizzablip" and "pizzamarker" responds to the function above... After the blip is destroyed upon delivery it points to another function (each house location being its own function). 1. I don't want a linear pattern I want it to randomly select a new house after each delivery (It would seem stupid and repetitive to drive the same pizza route) (especially being an ex pizza driver IRL i would probably cry if the same people ordered pizza everyday in the same exact order lol) I have it set so that when you enter the vehicle it starts mission1. The reason why my code is written the way it was because it was more trial and error to get it working. 2. The /deliver function does not destroy the second house's blip/marker (I've tried to make it pizzablip2 rather than just pizzablip but that causes it to function more linear and i want it more randomized) I dont want to have to make /deliver1 /deliver2 /deliver 3 to get each individual house to point the next house. 3. The first house is completely fine, It works... /deliver destroys it and points me to the 2nd house. When i go to the second house It doesnt destroy it but awards the money. Obviously this is something to do with the pizzamarker and pizzablip portion of my code on the second mission. 4. I don't want the same amount of money per house granted! That would mean everyone is making 100 dollar orders!!! So, That being said. Could anyone possibly point me in the right direction as far as making this script function the way I stated above? Oh and, I won't be surprised if any of you tell me i need to rewrite this completely. Feel free to PM me about this as well. Edited January 5, 2011 by Guest Link to comment
12p Posted January 5, 2011 Share Posted January 5, 2011 (edited) it would be cool if you use tag, not only [code]. Do that. Edited January 5, 2011 by Guest Link to comment
vanishSHC Posted January 5, 2011 Author Share Posted January 5, 2011 Done. Sorry bout that Overlooked it Link to comment
SDK Posted January 6, 2011 Share Posted January 6, 2011 You could try this way, using one table with all locations, and randomly selecting one location from it. local pizzablip, pizzamarker, house local locations = {} location[1] = { x = 2363.1, y = -1672, z = 13.5, blipicon = 32, reward = 100 } location[2] = { x = 2157.4, y = -1792, z = 13.3, blipicon = 32, reward = 250 } -- add other locations ... function enteredMissionvehicle (theVehicle,seat,jacked) if ( getElementModel ( theVehicle ) == 448 ) then -- if its a pizzaboy outputChatBox("You have entered a Pizza Delivery Vehicle, Deliver the Pizza to the Red House Blip on your MiniMap and type /deliver!", source,255,0,0) startRandomMission() end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enteredMissionvehicle ) function startRandomMission() house = locations[math.random(1,#locations)] pizzablip = createBlip ( house.x, house.y, house.z, house.blipicon, 2, 255, 0, 0 ) pizzamarker = createMarker ( house.x, house.y, house.z, "cylinder", 2, 255, 0, 0 ) end -- .... You'll still need to split things up in server and client side tho, else everyone will start seeing random blips. Link to comment
vanishSHC Posted January 6, 2011 Author Share Posted January 6, 2011 Thanks SDK for reworking my script Im just having one issue however... Server Sided File containing the location code is giving me an Error. Error:Missions\Mission2\.lua:3: attempt to index global 'location' (a nil value) local pizzablip, pizzamarker, house local locations = {} location[1] = { x = 2363.1, y = -1672, z = 13.3, blipicon = 32, reward = 100 } location[2] = { x = 2157.4, y = -1792, z = 13.3, blipicon = 32, reward = 250 } No blips are showing up, i also tried this client sided. So close yet far away heh. Not quite sure what to do Link to comment
SDK Posted January 6, 2011 Share Posted January 6, 2011 Yeah cause my table name was wrong, "locations" and "location", they should be the same And about the blips, this code is meant as an example, you'll have to rewrite it into a server and client file, using events to trigger stuff Link to comment
vanishSHC Posted January 7, 2011 Author Share Posted January 7, 2011 Ah i see that now, makes perfect sense. I did some moving around/added some things and it works like a charm! thanks alot for your help 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