Jump to content

One problem with script.


Bilal135

Recommended Posts

Hello, I was trying to make a pay and spray script, but I'm getting one error.

function consoleCreateMarker(thePlayer) 
    local theMarker = createMarker(1911.2722167969,-1776.7221679688, 13.3828125,"cylinder",2,0,255,255) 
    if isElementWithinMarker(theMarker) then 
    local playerVehicle = getPedOccupiedVehicle(thePlayer) 
    if (playerVehicle) then 
    fixVehicle(playerVehicle) 
else 
    return false 
end 
end 
end 
setTimer(consoleCreateMarker, 1000, 1) 

Error: payandspray\paynspray.lua:3: Bad argument @ 'isElementWithinMarker' [Expected marker at argument 2 got none]

Thanks in advance.

Link to comment
  
  local theMarker = createMarker(1911.2722167969,-1776.7221679688, 13.3828125,"cylinder",2,0,255,255)  
addEventHandler( "onMarkerHit",theMarker, 
function (hitElement,mD) 
    if getElementType ( hitElement ) == "player" and mD then  
if not isPedInVehicle (hitElement ) then return end 
    local playerVehicle = getPedOccupiedVehicle(hitElement) 
    fixVehicle(playerVehicle) 
  
      end 
end) 
  

You're creating a new marker every 1 sec.

Link to comment

Okay, so I got one more problem.

local theMarker = createMarker(1911.2722167969,-1776.7221679688, 13.382,"cylinder",2,255,0,0) 
addEventHandler( "onMarkerHit",theMarker, 
function (hitElement,mD) 
    if getElementType ( hitElement ) == "player" and mD then 
if not isPedInVehicle (hitElement ) then 
return outputChatBox("Please sit in a vehicle!", hitElement, 255, 0, 0) 
end 
    local playerVehicle = getPedOccupiedVehicle(hitElement) 
    takePlayerMoney(hitElement, 1000) 
    fixVehicle(playerVehicle) 
    outputChatBox("Vehicle Fixed!", hitElement, 0, 255, 0) 
else 
    outputChatBox("You are too poor!", hitElement, 255, 0, 0) 
end 
          if getElementHealth(hitElement) == 100 then 
          return outputChatBox("Vehicle's health is already 100", hitElement, 0, 255, 0)           
end 
end) 

When ever i went into the marker, and my vehicle health was 100, it still takes 1000$ money and the money of the player goes to "-1000$". How can I fix this? So if player will have 1000$ or more than 1000$, he will be able to fix his vehicle, if not, he wont be able. Please, tell me whats the problem?

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