Jump to content

Need some help


sckatchof

Recommended Posts

hello , why this script does not work i try many times and i need help this car show just for team and when he arrived to the marker get the money and Destroy marker and blip and car .

This is my scirpt.

function create () 
    hijackerv = createVehicle ( 500, 2071, -1332, 25, 0, 0, 0 ) 
    blip = createBlipAttachedTo ( hijackerv, 53, 1 ) 
     outputChatBox( 'hijacker has appeared, enter it and distribute it!', 0, 255, 125 ) 
end 
create () 
  
function getdriver ( driver ) 
if ( driver ) then 
    outputChatBox( 'Those inside the car, hurry up!', driver ) 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), getdriver ) 
  
function car( thePlayer ) 
if (source == marker) then 
    marker = createMarker ( 2015, -2410, 12.5, "cylinder", 6, 255, 0, 0, 90 ) 
    blip = createBlipAttachedTo ( marker, 51, 1  
local money = math.random(15000,25000) 
    givePlayerMoney ( source, math.random(15000,25000) 
    outputChatBox ( "Well done, you get the money  "..money.."$ !Good Work", source, 0,255,0 ) 
    destroyElement ( marker ) 
    destroyElement ( blip ) 
    destroyElement ( hijackerv ) 
   end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), car ) 

Link to comment

You can't set a vehicle visible to just some players, you should check if the player who tries to enter is a Car Jacker.

function create () 
    hijackerv = createVehicle ( 500, 2071, -1332, 25, 0, 0, 0 ) 
    carBlip = createBlipAttachedTo ( hijackerv, 53, 1 ) 
    outputChatBox( 'hijacker has appeared, enter it and distribute it!', 0, 255, 125 ) 
    addEventHandler ( "onVehicleEnter", hijackerv, getdriver ) 
end 
  
function getdriver ( driver ) 
if ( driver ) then 
    outputChatBox( 'Those inside the car, hurry up!', driver ) 
    marker = createMarker ( 2015, -2410, 12.5, "cylinder", 6, 255, 0, 0, 90 ) 
    blip = createBlipAttachedTo ( marker, 51, 1 )    
    addEventHandler("onMarkerHit",marker,onMarkerHit) 
    end 
end 
  
function onMarkerHit( thePlayer ) 
    local money = math.random(15000, 25000) 
    givePlayerMoney ( thePlayer, money) 
    outputChatBox ( "Well done, you get the money  ".. tostring(money) .."$ !Good Work", thePlayer, 0,255,0 ) 
    if isElement(marker) then destroyElement ( marker ) end 
    if isElement(carBlip) then destroyElement ( carBlip ) end 
    if isElement(blip) then destroyElement ( blip ) end 
    if isElement(hijackerv) then destroyElement ( hijackerv ) end 
end 
  
create() 

Edited by Guest
Link to comment

Damn. He was faster than me ^

You are going to have to explain yourself a little better. My plan was that I would talk you through this script so you also could learn something, but I really have no idea what you are trying to do here. Please give a more detailed description of your problem. The script is a complete mess. I wrote a few lines below. Try reading that and see if it makes sense.

First of all, in your script you have two functions that are connected to the same event. ("onVehicleEnter")

What I mean by this is that ' function car( thePlayer ) ' and ' function getdriver ( driver ) ' could/should be the same function.

Next problem I see is that you check if the source(in this case the vehicle is the source) is == a marker.

A vehicle and a marker would never be equal.. NEVER! :P

Another problem is that you are trying to check the marker before it has even been created.

if (source == marker) then 
    marker = createMarker ( 2015, -2410, 12.5, "cylinder", 6, 255, 0, 0, 90 ) 

After that you destroy them again right away in the same function?

    destroyElement ( marker ) 
    destroyElement ( blip ) 

When you do this they wont exist for more than a few milliseconds, not long enough for you to notice it.

Link to comment
You can't set a vehicle visible to just some players, you should check if the player who tries to enter is a Car Jacker.
function create () 
    hijackerv = createVehicle ( 500, 2071, -1332, 25, 0, 0, 0 ) 
    carBlip = createBlipAttachedTo ( hijackerv, 53, 1 ) 
    outputChatBox( 'hijacker has appeared, enter it and distribute it!', 0, 255, 125 ) 
    addEventHandler ( "onVehicleEnter", hijackerv, getdriver ) 
end 
create () 
  
function getdriver ( driver ) 
if ( driver ) then 
    outputChatBox( 'Those inside the car, hurry up!', driver ) 
    marker = createMarker ( 2015, -2410, 12.5, "cylinder", 6, 255, 0, 0, 90 ) 
    blip = createBlipAttachedTo ( marker, 51, 1 )    
    addEventHandler("onMarkerHit",marker,onMarkerHit) 
    end 
end 
  
function onMarkerHit( thePlayer ) 
    local money = math.random(15000, 25000) 
    givePlayerMoney ( thePlayer, money) 
    outputChatBox ( "Well done, you get the money  ".. tostring(money) .."$ !Good Work", thePlayer, 0,255,0 ) 
    if isElement(marker) then destroyElement ( marker ) end 
    if isElement(carBlip) then destroyElement ( carBlip ) end 
    if isElement(blip) then destroyElement ( blip ) end 
    if isElement(hijackerv) then destroyElement ( hijackerv ) end 
end 

when i get in the car blip does not show and marker and i want the blip show just for team.

thnx for help snake

Link to comment
Damn. He was faster than me ^

You are going to have to explain yourself a little better. My plan was that I would talk you through this script so you also could learn something, but I really have no idea what you are trying to do here. Please give a more detailed description of your problem. The script is a complete mess. I wrote a few lines below. Try reading that and see if it makes sense.

First of all, in your script you have two functions that are connected to the same event. ("onVehicleEnter")

What I mean by this is that ' function car( thePlayer ) ' and ' function getdriver ( driver ) ' could/should be the same function.

Next problem I see is that you check if the source(in this case the vehicle is the source) is == a marker.

A vehicle and a marker would never be equal.. NEVER! :P

Another problem is that you are trying to check the marker before it has even been created.

if (source == marker) then 
    marker = createMarker ( 2015, -2410, 12.5, "cylinder", 6, 255, 0, 0, 90 ) 

After that you destroy them again right away in the same function?

    destroyElement ( marker ) 
    destroyElement ( blip ) 

When you do this they wont exist for more than a few milliseconds, not long enough for you to notice it.

sorry because i'm new in scripting that's why .

i mean when I enter the car I recive blip and marker where I can delivery it.

and when I get into the marker, the marker and the blip and the car removed

Link to comment
local hijackerTeam = "Criminal" 
local currentDriver = nil 
  
function create () 
    hijackerv = createVehicle ( 500, 2071, -1332, 25, 0, 0, 0 ) 
    carBlip = createBlipAttachedTo ( hijackerv, 53, 1 ) 
    setElementVisibleTo(carBlip, getRootElement(), false) 
    for index, player in ipairs(getPlayersInTeam(getTeamFromName(hijackerTeam))) do 
        outputChatBox( 'hijacker has appeared, enter it and distribute it!', player, 0, 255, 125 ) 
        setElementVisibleTo(carBlip, player, true) 
    end 
    addEventHandler ( "onVehicleEnter", hijackerv, getdriver ) 
    addEventHandler ( "onVehicleExit", hijackerv, onExit ) 
    addEventHandler ( "onVehicleStartEnter", hijackerv, onTryToEnter ) 
end 
  
function onTryToEnter ( thePlayer ) 
    if (getPlayerTeam(thePlayer) and getTeamName(getPlayerTeam(thePlayer)) ~= hijackerTeam and source == hijackerv) then 
        outputChatBox("You cannot enter this vehicle", thePlayer, 255, 0, 0) 
        cancelEvent() 
    end 
end 
  
function getdriver ( driver ) 
if ( driver ) then 
    outputChatBox( 'Those inside the car, hurry up!', driver ) 
    marker = createMarker ( 2015, -2410, 12.5, "cylinder", 6, 255, 0, 0, 90 ) 
    blip = createBlipAttachedTo ( marker, 51, 1 ) 
    setElementVisibleTo(marker, getRootElement(), false) 
    setElementVisibleTo(blip, getRootElement(), false) 
    setElementVisibleTo(marker, driver, true) 
    setElementVisibleTo(blip, driver, true) 
    addEventHandler("onMarkerHit",marker,onMarkerHit) 
    currentDriver = driver 
    end 
end 
  
function onExit ( thePlayer ) 
    if (getPlayerTeam(thePlayer) and getTeamName(getPlayerTeam(thePlayer)) == hijackerTeam and currentDriver == thePlayer) then 
        if isElement(blip) then destroyElement ( blip ) end 
        if isElement(marker) then destroyElement ( marker ) end 
        currentDriver = nil 
    end 
end 
  
function onMarkerHit( thePlayer ) 
    if (getPlayerTeam(thePlayer) and getTeamName(getPlayerTeam(thePlayer)) == hijackerTeam and isPedInVehicle(thePlayer) and getPedOccupiedVehicle(thePlayer) == hijackerv) then 
        local money = math.random(15000, 25000) 
        givePlayerMoney ( thePlayer, money) 
        outputChatBox ( "Well done, you get the money  ".. tostring(money) .."$ !Good Work", thePlayer, 0,255,0 ) 
        if isElement(marker) then destroyElement ( marker ) end 
        if isElement(carBlip) then destroyElement ( carBlip ) end 
        if isElement(blip) then destroyElement ( blip ) end 
        if isElement(hijackerv) then destroyElement ( hijackerv ) end 
        currentDriver = nil 
    end 
end 
create() 

Link to comment
local hijackerTeam = "Criminal" 
local currentDriver = nil 
  
function create () 
    hijackerv = createVehicle ( 500, 2071, -1332, 25, 0, 0, 0 ) 
    carBlip = createBlipAttachedTo ( hijackerv, 53, 1 ) 
    setElementVisibleTo(carBlip, getRootElement(), false) 
    for index, player in ipairs(getPlayersInTeam(getTeamFromName(hijackerTeam))) do 
        outputChatBox( 'hijacker has appeared, enter it and distribute it!', player, 0, 255, 125 ) 
        setElementVisibleTo(carBlip, player, true) 
    end 
    addEventHandler ( "onVehicleEnter", hijackerv, getdriver ) 
    addEventHandler ( "onVehicleExit", hijackerv, onExit ) 
    addEventHandler ( "onVehicleStartEnter", hijackerv, onTryToEnter ) 
end 
  
function onTryToEnter ( thePlayer ) 
    if (getPlayerTeam(thePlayer) and getTeamName(getPlayerTeam(thePlayer)) ~= hijackerTeam and source == hijackerv) then 
        outputChatBox("You cannot enter this vehicle", thePlayer, 255, 0, 0) 
        cancelEvent() 
    end 
end 
  
function getdriver ( driver ) 
if ( driver ) then 
    outputChatBox( 'Those inside the car, hurry up!', driver ) 
    marker = createMarker ( 2015, -2410, 12.5, "cylinder", 6, 255, 0, 0, 90 ) 
    blip = createBlipAttachedTo ( marker, 51, 1 ) 
    setElementVisibleTo(marker, getRootElement(), false) 
    setElementVisibleTo(blip, getRootElement(), false) 
    setElementVisibleTo(marker, driver, true) 
    setElementVisibleTo(blip, driver, true) 
    addEventHandler("onMarkerHit",marker,onMarkerHit) 
    currentDriver = driver 
    end 
end 
  
function onExit ( thePlayer ) 
    if (getPlayerTeam(thePlayer) and getTeamName(getPlayerTeam(thePlayer)) == hijackerTeam and currentDriver == thePlayer) then 
        if isElement(blip) then destroyElement ( blip ) end 
        if isElement(marker) then destroyElement ( marker ) end 
        currentDriver = nil 
    end 
end 
  
function onMarkerHit( thePlayer ) 
    if (getPlayerTeam(thePlayer) and getTeamName(getPlayerTeam(thePlayer)) == hijackerTeam and isPedInVehicle(thePlayer) and getPedOccupiedVehicle(thePlayer) == hijackerv) then 
        local money = math.random(15000, 25000) 
        givePlayerMoney ( thePlayer, money) 
        outputChatBox ( "Well done, you get the money  ".. tostring(money) .."$ !Good Work", thePlayer, 0,255,0 ) 
        if isElement(marker) then destroyElement ( marker ) end 
        if isElement(carBlip) then destroyElement ( carBlip ) end 
        if isElement(blip) then destroyElement ( blip ) end 
        if isElement(hijackerv) then destroyElement ( hijackerv ) end 
        currentDriver = nil 
    end 
end 
create() 

script.lua:8: Bad argument @' get playersIn team'

script.lua:8: Bad argument #1 to 'pairs"

and blips does not show and marker!!

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