Jump to content

Need Help with Markers


Recommended Posts

Well I am the Co-Scripter for TRSA and we are having trouble with our automated Job, Pizza Delivery.

Well. When you get on the Bike you get a message saying press F2 to begin delivering Pizza. You press that you get another message saying go collect the pizza from the shop. The Blip and Marker are displayed but when you arrive at the Marker nothing happens. it is meant to be deleted another bit of text saying go to the customer and a new marker. But it doesn't.

Me and the other Scripter have been Fiddling and Testing for the past 2 hours to no success. Please Could someone help.

Here is the Code:

function sendMessageOnPizzaStart ( player, seat, jacked) 
    if ( getVehicleID ( source ) == 448 ) then  
            outputChatBox ( "Press F2 to Begin Pizza Delivery" , player) 
            bindKey ( player, "F2", "down", pizzaDeliveryHandler) 
    end 
end 
  
function pizzaDeliveryHandler ( source, key, keystate ) 
    pbplace = createBlip (1807.4569,944.3589,24.8906, 29,2,255,0,0,255,0, source ) 
    pplace = createMarker ( 1807.4569,944.3589,24.8906, "cylinder", 3,240,0,0,200, source ) 
    outputChatBox ( "Pickup the Pizza from the Pizza Blip on the Radar" , source ) 
end 
  
function onMarkerHitHandler ( player, matchingDimension ) 
    if source == pplace then 
        destroyElement ( pbplace ) 
        destroyElement ( pplace ) 
        pbcustomer = createBlip ( -2710.8235,969.6843,54.4609, 29,2,255,0,0,255,0,player ) 
        local pcustomer = createMarker ( -2710.8235,969.6843,54.4609, "cylinder", 3,240,0,0,200,player ) 
        outputChatBox ( "You have the Pizza, Now proceed to the customer", player ) -- send it to player only 
    else 
    if source == pcustomer then 
    outputChatBox("you hit a marker3",player) 
        destroyElement ( pbcustomer ) 
        destroyElement ( pcustomer ) 
        outputChatBox ( "You have successfully delivered the Pizza, Here is your Money", player ) -- send it to that player only 
        givePlayerMoney ( player, 25 ) 
    end 
end 
  
-- Event Handlers 
addEventHandler ( "onVehicleEnter", getRootElement(), sendMessageOnPizzaStart ) 
addEventHandler ( "onMarkerHit", getRootElement (), onMarkerHitHandler ) 

Link to post

It doesn't seem to be problem with pplace because marker get created and the marker gets assigned to pplace variable (which is global since it was prefixed with local).

Try to output some text in onMarkerHitHandler function, not in if statements but before them and see if that function was called at all.

Also, do you get any warnings/errors? (/debugscript 3)

Link to post

Useing the debugger, No Errors are picked up upon entering the 2nd Marker. Nothing happense. Not a single thing.

Another thing is that it's posting the blips for all players.

Here is the New code:

function sendMessageOnPizzaStart ( player, seat, jacked) 
    if ( getVehicleID ( source ) == 448 ) then  
            outputChatBox ( "Press F2 to Begin Pizza Delivery" , player) 
            bindKey ( player, "F2", "down", pizzaDeliveryHandler) 
    end 
end 
  
function pizzaDeliveryHandler ( source, key, keystate ) 
    pbplace = createBlip (-1807.4569,944.3589,24.8906, 29,2,255,0,0,255,0, source ) 
    pplace = createMarker ( -1807.4569,944.3589,24.8906, "cylinder", 3,240,0,0,200, source ) 
    outputChatBox ( "Pickup the Pizza from the Pizza Blip on the Radar" , source ) 
end 
  
function onMarkerHitHandler ( player, matchingDimension ) 
    outputChatBox( "onMarkerHitHandler", player ) 
    if source == pplace then 
        outputChatBox( "onMarkerHitHandler - pplace", player ) 
        destroyElement ( pbplace ) 
        destroyElement ( pplace ) 
        pbcustomer = createBlip ( -2710.8235,969.6843,54.4609, 29,2,255,0,0,255,0,player ) 
        pcustomer = createMarker ( -2710.8235,969.6843,54.4609, "cylinder", 3,240,0,0,200,player ) 
        outputChatBox ( "You have the Pizza, Now proceed to the customer", player ) -- send it to player only 
    elseif source == pcustomer then 
        outputChatBox( "onMarkerHitHandler - pcustomer", player ) 
        destroyElement ( pbcustomer ) 
        destroyElement ( pcustomer ) 
        outputChatBox ( "You have successfully delivered the Pizza, Here is your Money", player ) -- send it to that player only 
        givePlayerMoney ( player, 25 ) 
    end 
end 
  
-- Event Handlers 
addEventHandler ( "onVehicleEnter", getRootElement(), sendMessageOnPizzaStart ) 
addEventHandler ( "onMarkerHit", getRootElement (), onMarkerHitHandler ) 
  

Link to post

This confuses even me. When you create the customer marker in let's say onPlayerJoin call back everything goes fine. Even if you define the customer marker globally it doesn't work even though the marker is created successfully. Maybe this is a bug because I've tried all possibilities that should have worked but didn't.

Also when you want to make a blip explicitly visible to one or a group of players you must hide it for the entire root first. This is DP2 related as well.

Edited by Guest
Link to post

New Error Time :D

Me and the other Scripter decided to revert to using Client Side. Now it's just completely messed up.

function sendMessageOnPizzaStart ( theVehicle, seat) 
    if source == getLocalPlayer() then 
    --if ( getVehicleID ( theVehicle ) == 448 ) then 
        outputChatBox ( "Press F2 to Begin Pizza Delivery") 
        bindKey ("F2", "down", pizzaDeliveryHandler) 
    --end 
    else  
        outputChatBox ( "TISNT WORKINGGGG" ) 
    end 
end 
  
function pizzaDeliveryHandler ( source, key, keystate ) 
    pbplace = createBlip (-1807.4569,944.3589,24.8906, 29) 
    pplace = createColSphere ( -1807.4569,944.3589,24.8906, 5.0 )               
    outputChatBox ( "Pickup the Pizza from the Pizza Blip on the Radar")                            
    bindKey ("F3", "down", pizzaPickupHandler)                                       
end 
  
function pizzaPickupHandler ( source, key, keystate ) 
    if isElementWithinColShape ( getLocalPlayer(), pplace ) then  
        destroyElement ( pplace ) 
        pcustomercreateColSphere ( -2710.8235,969.6843,54.4609, 5.0 ) 
        setElementPosition ( pbplace, -2710.8235,969.6843,54.4609 )    
        outputChatBox ( "You have the Pizza, Now proceed to the customer") 
    else  
        outputChatBox ( "You are not at the Pizza Blip") 
    end 
end 
  
function onMarkerHitHandler ( player, matchingDimension ) 
    if source == pcustomer then 
        destroyElement ( pbplace )          
        destroyElement ( pcustomer )             
        outputChatBox ( "You have successfully delivered the Pizza, Here is your Money") 
        triggerServerEvent ( "givemoney", getRootElement(), player, 25 ) 
    end 
end 
  
function onClientColShapeHitHandler( theElement, matchingDimension ) 
    if ( theElement == getLocalPlayer() ) then 
        if source == pplace then 
            outputChatBox( "Press F3 to pickup the pizza") 
        elseif source == pcustomer then 
            destroyElement ( pbplace )          
            destroyElement ( pcustomer )             
            outputChatBox ( "You have successfully delivered the Pizza, Here is your Money") 
            triggerServerEvent ( "givemoney", getRootElement(), player, 25 ) 
        end 
    end 
end 
  
-- Event Handlers 
addEventHandler ( "onClientVehicleEnter", getRootElement(), sendMessageOnPizzaStart ) 
addEventHandler ( "onClientColShapeHit", getRootElement (), onClientColShapeHitHandler ) 

Any Help is Appreciated.

Link to post

source of onClientVehicleEnter is the vehicle player entered, 1st param is the player that entered the vehicle.

You also missed '=' sign between pcustomer and createColShape.

Link to post

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