Jump to content

Vert very annoying problem.


WolfPire

Recommended Posts

So... I'm working in a job's script which consist in the delivery of many things to different places.

The problem is that whenever i start the delivery, i get 2 Faggios and i just want to spawn one. I don't see where's the problem on this.

Can you guys please help me once again? =) Thanks

Server

function fire() 
    outputChatBox("Congratulations, you've earned a free...", playa, 0, 255, 0) 
    setTimer( outputChatBox, 1000, 1, "GTFO.", playa, 255, 0, 0 ) 
end 
  
addEvent("win",true) 
addEventHandler("win",root, 
    function( localPlayer ) 
        outputChatBox("Thanks, your reward is 5000$", localPlayer, 0, 255, 0) 
        triggerClientEvent("markersOn",root) 
        givePlayerMoney( localPlayer, 5000) 
    end 
) 
  
addEvent("start",true) 
addEventHandler("start",root, 
    function( source ) 
        if source then 
            outputChatBox("Deliver these parts to Pay N' Spray. Do no step out of the vehicle or YOU'RE FIRED.", source, 0, 255, 0) 
            mVehicle = createVehicle( 462, -2755, 203, 7 ) 
            warpPedIntoVehicle(source, mVehicle) 
    end 
end 
) 
  
function Fail() 
    if (mVehicle) then 
        triggerClientEvent("destroyFail",root) 
        triggerClientEvent("markersOn",root) 
        destroyElement(mVehicle) 
    end 
end 
  
addEventHandler("onPlayerVehicleExit",root,Fail) 
  
  

Client

DeliveryLocations = { "-2572, 1150, 56, 0", "-2398, 1130, 56, 0", "-2462, 792, 35, 0" } 
----------------------------------------------------------- 
  
    local loca = {} 
    local DeliveryLocationTableSize = table.maxn ( DeliveryLocations ) 
    local randomLocationIdx = math.random ( 1, DeliveryLocationTableSize ) 
    local locString = tostring( DeliveryLocations[randomLocationIdx] ) 
    loca.Location = split ( locString, string.byte( "," ) ) 
    local DelX = loca.Location[1] 
    local DelY = loca.Location[2] 
    local DelZ = loca.Location[3] 
  
JobStart = createColSphere( -2749, 204, 8, 1 ) 
JobStartM = createMarker( -2749, 204, 6.5, "cylinder", 1, 0, 200, 0 ) 
JobStartB = createBlipAttachedTo( JobStart, 58 ) 
  
  
function giveVehicle( source ) 
    if source then 
        destroyElement(JobStart) 
        destroyElement(JobStartM) 
        destroyElement(JobStartB) 
        triggerServerEvent("start",root, source) 
        Destiny = createColSphere( DelX, DelY, DelZ, 3 ) 
        DestinyM = createMarker( DelX, DelY, DelZ, "cylinder", 3, 0, 200, 0 ) 
        DestinyB = createBlipAttachedTo( Destiny, 52 ) 
        addEventHandler("onClientColShapeHit",Destiny,Reward) 
    end 
end 
addEventHandler("onClientColShapeHit",JobStart,giveVehicle) 
  
addEvent("markersOn",true) 
addEventHandler("markersOn",root, 
    function() 
        JobStart = createColSphere( -2749, 204, 8, 1 ) 
        JobStartM = createMarker( -2749, 204, 6.5, "cylinder", 1, 0, 200, 0 ) 
        JobStartB = createBlipAttachedTo( JobStart, 58 ) 
end 
) 
  
function Reward() 
    triggerServerEvent("win",root, localPlayer) 
end 

Honto ni, arigato =)

Link to comment

hmm at a glance it looks ok (a few random variable names for players tho - playa, player, source, localPlayer),

the only thing i can see is... if ur in a vehicle when u hit the marker, that too will be detected as hitting it.

the parameters for are: giveVehicle(hitElement,matchingDimension),

so in yours, the element hitting the marker is 'source' which could be a vehicle if ur in one.

so in: function giveVehicle( source ), below this u should add: if getElementType(source) == "player" then

give that a try.

i dont think u need the colsphere either.. u can do this with just the 1 marker and 1 blip, i dont see why u need a colsphere too. just create ur marker and use "onClientMarkerHit".

anyway... ive rambled on enough i think lol.

check out what ive said and post back if ur still having problems.

Link to comment
hmm at a glance it looks ok (a few random variable names for players tho - playa, player, source, localPlayer),

the only thing i can see is... if ur in a vehicle when u hit the marker, that too will be detected as hitting it.

the parameters for are: giveVehicle(hitElement,matchingDimension),

so in yours, the element hitting the marker is 'source' which could be a vehicle if ur in one.

so in: function giveVehicle( source ), below this u should add: if getElementType(source) == "player" then

give that a try.

i dont think u need the colsphere either.. u can do this with just the 1 marker and 1 blip, i dont see why u need a colsphere too. just create ur marker and use "onClientMarkerHit".

anyway... ive rambled on enough i think lol.

check out what ive said and post back if ur still having problems.

Well... Used colshapes. Markers are problematic as for tiggering, they have a strange bug that also makes them trigger no matter what's your "Z" position.

So it would be a problem when someone is driving a plane. Colshape for function triggering and markers to make em' visible.

Used "theElement" instead of "hitElemt" as i noticed it changed in the wiki :S

I'll try that, ty.

Link to comment
i suppose for the markers, u could just make them work if the player is on foot, since ur spawning them a car anyway.

anyway... good luck, let me know how u get on.

Well tried, it is indeed a nice way to detect more specificly.

but... No, seems like my double vehicle problem is not over x_x

Link to comment

fixed it myself. Thanks for the help tho' =) <3

function fire() 
    outputChatBox("Congratulations, you've earned a free...", playa, 0, 255, 0) 
    setTimer( outputChatBox, 1000, 1, "GTFO.", playa, 255, 0, 0 ) 
end 
  
addEvent("win",true) 
addEventHandler("win",root, 
    function( localPlayer ) 
        outputChatBox("Thanks, your reward is 5000$", localPlayer, 0, 255, 0) 
        triggerClientEvent("markersOn",root) 
        givePlayerMoney( localPlayer, 5000) 
    end 
) 
  
addEvent("start",true) 
addEventHandler("start",root, 
    function( theElement ) 
        if theElement then 
            outputChatBox("Deliver these parts to Pay N' Spray. Do no step out of the vehicle or YOU'RE FIRED.", theElement, 0, 255, 0) 
            mVehicle = createVehicle( 462, -2755, 203, 7 ) 
            warpPedIntoVehicle(theElement, mVehicle) 
    end 
end 
) 
  
function Fail() 
    if (mVehicle) then 
        triggerClientEvent("markersOn",root) 
        destroyElement(mVehicle) 
    end 
end 
  
addEventHandler("onPlayerVehicleExit",root,Fail) 

^ Server.

DeliveryLocations = { "-2572, 1150, 56, 0", "-2398, 1130, 56, 0", "-2462, 792, 35, 0" } 
----------------------------------------------------------- 
  
    local loca = {} 
    local DeliveryLocationTableSize = table.maxn ( DeliveryLocations ) 
    local randomLocationIdx = math.random ( 1, DeliveryLocationTableSize ) 
    local locString = tostring( DeliveryLocations[randomLocationIdx] ) 
    loca.Location = split ( locString, string.byte( "," ) ) 
    local DelX = loca.Location[1] 
    local DelY = loca.Location[2] 
    local DelZ = loca.Location[3] 
  
JobStart = createColSphere( -2749, 204, 8, 1 ) 
JobStartM = createMarker( -2749, 204, 6.5, "cylinder", 1, 0, 200, 0 ) 
JobStartB = createBlipAttachedTo( JobStart, 58 ) 
  
  
function giveVehicle( theElement ) 
    if ( theElement == getLocalPlayer() ) then 
        destroyElement(JobStart) 
        destroyElement(JobStartM) 
        destroyElement(JobStartB) 
        triggerServerEvent("start",root, theElement) 
        Destiny = createColSphere( DelX, DelY, DelZ, 3 ) 
        DestinyM = createMarker( DelX, DelY, DelZ, "cylinder", 3, 0, 200, 0 ) 
        DestinyB = createBlipAttachedTo( Destiny, 52 ) 
        addEventHandler("onClientColShapeHit",Destiny,Reward) 
    end 
end 
addEventHandler("onClientColShapeHit",JobStart,giveVehicle) 
  
addEvent("markersOn",true) 
addEventHandler("markersOn",root, 
    function() 
        JobStart = createColSphere( -2749, 204, 8, 1 ) 
        JobStartM = createMarker( -2749, 204, 6.5, "cylinder", 1, 0, 200, 0 ) 
        JobStartB = createBlipAttachedTo( JobStart, 58 ) 
end 
) 
  
function Reward() 
    triggerServerEvent("win",root, localPlayer) 
end 

^ Client.

used "if ( theElement == getLocalPlayer() ) then".

EDIT:

New issue.

Client

DeliveryLocations = { "-2572, 1150, 56, 0", "-2398, 1130, 56, 0", "-2462, 792, 35, 0" } 
----------------------------------------------------------- 
  
    local loca = {} 
    local DeliveryLocationTableSize = table.maxn ( DeliveryLocations ) 
    local randomLocationIdx = math.random ( 1, DeliveryLocationTableSize ) 
    local locString = tostring( DeliveryLocations[randomLocationIdx] ) 
    loca.Location = split ( locString, string.byte( "," ) ) 
    local DelX = loca.Location[1] 
    local DelY = loca.Location[2] 
    local DelZ = loca.Location[3] 
  
JobStart = createColSphere( -2749, 204, 8, 1 ) 
JobStartM = createMarker( -2749, 204, 6.5, "cylinder", 1, 0, 200, 0 ) 
JobStartB = createBlipAttachedTo( JobStart, 58 ) 
  
  
function giveVehicle( theElement ) 
    if ( theElement == getLocalPlayer() ) then 
        removeEventHandler("onClientColShapeHit",JobStart,giveVehicle) 
        destroyElement(JobStart) 
        destroyElement(JobStartM) 
        destroyElement(JobStartB) 
        triggerServerEvent("start",root, theElement) 
        Destiny = createColSphere( DelX, DelY, DelZ, 3 ) 
        DestinyM = createMarker( DelX, DelY, DelZ, "cylinder", 3, 0, 200, 0 ) 
        DestinyB = createBlipAttachedTo( Destiny, 52 ) 
        addEventHandler("onClientColShapeHit",Destiny,Reward) 
    end 
end 
addEventHandler("onClientColShapeHit",JobStart,giveVehicle) 
  
addEvent("markersOn",true) 
addEventHandler("markersOn",root, 
    function() 
        JobStart = createColSphere( -2749, 204, 8, 1 ) 
        JobStartM = createMarker( -2749, 204, 6.5, "cylinder", 1, 0, 200, 0 ) 
        JobStartB = createBlipAttachedTo( JobStart, 58 ) 
        addEventHandler("onClientColShapeHit",JobStart,giveVehicle) 
end 
) 
  
function Reward() 
    triggerServerEvent("win",root, localPlayer) 
end 

When exiting the vehicle, the markers will retun to normal state, but when triggered again, they will triggerd the "Reward function as well" and double the money (major bug)

Edit: Solved.

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