Jump to content

[HELP] Pizza job


Emile

Recommended Posts

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

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
  
  
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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...