Emile Posted September 17, 2014 Share Posted September 17, 2014 Hello, I'm having trouble scripting a pizza job. I want to make it so that you deliver 8 pizzas then you need to get new pizzas. When I deliver a pizza, it doesn't go down. This is a part of my script: local pizzas = 0 local pcount = "0" pizzasLeft = guiCreateLabel (0.82, 0.5, 5, 3.5, "Pizzas: "..pcount.."/8", true) function pay() if ( source == marker ) then givePlayerMoney(5000) local pizzas = pizzas - 1 local pcount = tostring(pizzas) guiSetText(pizzasLeft, "Pizzas: " ..pcount.."/8") destroyElement(marker) destroyElement(blip) destroyElement(pizzabox) outputChatBox("Get in a Pizza Boy to get a new mission", 255, 204, 0) end end addEventHandler ( "onClientMarkerHit", getRootElement(), pay ) function refillmarker() if pizzas < 1 then refmarker = createMarker ( -1805, 944, 23.9, "cylinder", 1.5, 255, 25, 0, 170 ) refblip = createBlipAttachedTo(refmarker, 29) outputChatBox("Go to the pizza store to get new pizzas") function refill() if ( source == refmarker ) then pizzas = 8 local pcount = tostring(pizzas) guiSetText(pizzasLeft, "Pizzas: " ..pcount.."/8") destroyElement(refmarker) destroyElement(refblip) end end addEventHandler ( "onClientMarkerHit", getRootElement(), refill ) Thanks for your help Link to comment
justn Posted September 17, 2014 Share Posted September 17, 2014 I'm guessing this is what you want.. and 1 more thing, variables shouldn't be defined locally unless it is out of the function.. ( or if you're creating the thing / element for that function only ) pizzas = 8 refmarker = createMarker ( -1805, 944, 23.9, "cylinder", 1.5, 255, 25, 0, 170 ) refblip = createBlipAttachedTo(refmarker, 29) pizzasLeft = guiCreateLabel (0.82, 0.5, 5, 3.5, "Pizzas: "..pcount.."/8", true) function pay() if ( source == marker ) then pizzas = pizzas - 1 givePlayerMoney(5000) guiSetText(pizzasLeft, "Pizzas: " ..pizzas.."/8") destroyElement(marker) destroyElement(blip) destroyElement(pizzabox) outputChatBox("Get in a Pizza Boy to get a new mission", 255, 204, 0) end end addEventHandler ( "onClientMarkerHit", getRootElement(), pay ) function refill() if ( source == refmarker ) then if ( not pizzas == 8 ) then pizzas = 8 local pcount = tostring(pizzas) guiSetText(pizzasLeft, "Pizzas: " ..pcount.."/8") destroyElement(refmarker) destroyElement(refblip) end end end addEventHandler ( "onClientMarkerHit", getRootElement(), refill ) Link to comment
Emile Posted September 17, 2014 Author Share Posted September 17, 2014 It doesnt work... Attempt to get length of upvalue `pizzas` (a number value) Link to comment
Anubhav Posted September 17, 2014 Share Posted September 17, 2014 pizzas = 8 refmarker = createMarker ( -1805, 944, 23.9, "cylinder", 1.5, 255, 25, 0, 170 ) refblip = createBlipAttachedTo(refmarker, 29) pizzasLeft = guiCreateLabel (0.82, 0.5, 5, 3.5, "Pizzas: "..pcount.."/8", true) function pay() if ( source == marker ) then pizzas = pizzas - 1 givePlayerMoney(5000) guiSetText(pizzasLeft, "Pizzas: " ..tostring(pizzas).."/8") destroyElement(marker) destroyElement(blip) destroyElement(pizzabox) outputChatBox("Get in a Pizza Boy to get a new mission", 255, 204, 0) end end addEventHandler ( "onClientMarkerHit", getRootElement(), pay ) function refill() if ( source == refmarker ) then if ( not pizzas == 8 ) then pizzas = 8 local pcount = tostring(pizzas) guiSetText(pizzasLeft, "Pizzas: " ..pcount.."/8") destroyElement(refmarker) destroyElement(refblip) end end end addEventHandler ( "onClientMarkerHit", getRootElement(), refill ) Link to comment
Emile Posted September 19, 2014 Author Share Posted September 19, 2014 Thanks guys, it's working! I got another problem, I want to make the ped holds the pizza box. I used setPedAnimation(localPlayer, "CARRY", "crry_prtial", -1, true, true, false, false) but how can I make the ped movable? I heard that I must use setControlState but how do I use it? Thanks Link to comment
Anubhav Posted September 20, 2014 Share Posted September 20, 2014 No problem. toggleAllControls(true, true, true) Link to comment
Emile Posted September 20, 2014 Author Share Posted September 20, 2014 Not working... I cannot move Link to comment
Emile Posted September 20, 2014 Author Share Posted September 20, 2014 I found it. It's setTimer(setPedAnimation,500,1,localPlayer, "CARRY", "crry_prtial", 50, false, true, false, false) setTimer(setPedAnimation,500,1,localPlayer, "CARRY", "crry_prtial", 50, false, true, false, true) 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