Jump to content

Little Help Needed Edited


Lietuvis

Recommended Posts

local gData = getElementData(source, "owner") 
local gPlayerName = getPlayerName(source) 
if (gPlayerName ~= false) and (gPlayerName ~= nil) and (gData ~= false) and (gData ~= nil) then 
    if (gPlayerName == gData) then 
        --Do something 
    else 
        outputChatBox("You are not the owner.", source) 
    end 
else 
    outputChatBox("Error getting data or player name.", source) 
end 

Link to comment

Error getting data or player name. Everytime

sellMarker = createMarker ( -2658.1999511719,-48.599998474121,3.3000001907349, "cylinder", 1.5, 255, 0, 0 ) 
  
function sellVeh(source) 
local gData = getElementData(source, "owner") 
local gPlayerName = getPlayerName(source) 
if (gPlayerName ~= false) and (gPlayerName ~= nil) and (gData ~= false) and (gData ~= nil) then 
    if (gPlayerName == gData) then 
        outputChatBox("You are owner so bla bla", source) 
        -- i will put more things later here  
    else 
        outputChatBox("You are not the owner.", source) 
    end 
else 
    outputChatBox("Error getting data or player name.", source) 
end 
end 
  
addEventHandler( 'onMarkerHit', sellMarker, sellVeh) 

Link to comment
sellMarker = createMarker ( -2658.1999511719,-48.599998474121,3.3000001907349, "cylinder", 1.5, 255, 0, 0 ) 
  
function sellVeh(tElement) 
if (getElementType(tElement) == "player") then 
local gData = getElementData(tElement, "owner") 
local gPlayerName = getPlayerName(tElement) 
if (gPlayerName ~= false) and (gPlayerName ~= nil) and (gData ~= false) and (gData ~= nil) then 
    if (gPlayerName == gData) then 
        outputChatBox("You are owner so bla bla", tElement) 
        -- i will put more things later here 
    else 
        outputChatBox("You are not the owner.", tElement) 
    end 
else 
    outputChatBox("Error getting data or player name.", tElement) 
end 
end 
  
addEventHandler( 'onMarkerHit', sellMarker, sellVeh) 

Link to comment
Still same.. And you forgot end :D

:roll:

sellMarker = createMarker ( -2658.1999511719,-48.599998474121,3.3000001907349, "cylinder", 1.5, 255, 0, 0 ) 
  
function sellVeh(tElement) 
if (getElementType(tElement) == "player") then 
local gData = getElementData(tElement, "owner") 
outputChatBox(tostring(gData)) 
local gPlayerName = getPlayerName(tElement) 
if (gPlayerName ~= false) and (gPlayerName ~= nil) and (gData ~= false) and (gData ~= nil) then 
    if (gPlayerName == gData) then 
        outputChatBox("You are owner so bla bla", tElement) 
        -- i will put more things later here 
    else 
        outputChatBox("You are not the owner.", tElement) 
    end 
else 
    outputChatBox("Error getting data or player name.", tElement) 
end 
end 
end 
  
addEventHandler( 'onMarkerHit', sellMarker, sellVeh) 

What does it output?

Link to comment

Oops, sorry. I checked the data of the player and not of the vehicle. :roll:

sellMarker = createMarker ( -2658.1999511719,-48.599998474121,3.3000001907349, "cylinder", 1.5, 255, 0, 0 ) 
  
function sellVeh(tElement) 
if (getElementType(tElement) == "player") then 
local gVehicle = getPedOccupiedVehicle(tElement) 
if (gVehicle ~= false) and (gVehicle ~= nil) then 
local gData = getElementData(gVehicle , "owner") 
outputChatBox(tostring(gData)) 
local gPlayerName = getPlayerName(tElement) 
if (gPlayerName ~= false) and (gPlayerName ~= nil) and (gData ~= false) and (gData ~= nil) then 
    if (gPlayerName == gData) then 
        outputChatBox("You are owner so bla bla", tElement) 
        -- i will put more things later here 
    else 
        outputChatBox("You are not the owner.", tElement) 
    end 
else 
    outputChatBox("Error getting data or player name.", tElement) 
end 
end 
end 
end 
  
addEventHandler( 'onMarkerHit', sellMarker, sellVeh) 

Link to comment

God the same again.. :D lol

Might this will help:

function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle 
    if ( getElementData(source, "owner")  and getPlayerName(player) ~= getElementData(source, "owner") ) then 
        cancelEvent() 
        outputChatBox ( "You dont have this vehicle keys..", player, 255, 255, 255, true ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle 

This works perfectly

..

I'am trying to make a script to sell owned car i guess you understand that

Link to comment

Sure.

function Buy1 () 
    local money = getPlayerMoney(source) 
    if (money > 5000) then   
    takePlayerMoney(source,5000) 
    local vehicleModel = 602 
    local x,y,z = getElementPosition(source) 
    y = y + 10 
    z = z + 5 
    local veh = createVehicle(tonumber(vehicleModel),x,y,z) 
    setElementData(veh, "owner", getPlayerName(source)) 
    else 
    outputChatBox ( "You need more cash bro..", source, 255, 255, 255, true ) 
end 
end 
addEvent("Car1",true) 
addEventHandler( "Car1", getRootElement(), Buy1 ) 

Link to comment
function Buy1 () 
    local money = getPlayerMoney(source) 
    if (money > 5000) then   
    takePlayerMoney(source,5000) 
    local vehicleModel = 602 
    local x,y,z = getElementPosition(source) 
    y = y + 10 
    z = z + 5 
    local veh = createVehicle(tonumber(vehicleModel),x,y,z) 
    local lol = setElementData(veh, "owner", getPlayerName(source)) 
    outputChatBox(tostring(lol)) 
    else 
    outputChatBox ( "You need more cash bro..", source, 255, 255, 255, true ) 
end 
end 
addEvent("Car1",true) 
addEventHandler( "Car1", getRootElement(), Buy1 ) 

What does it output? If it output's 'true', then I give up. x:

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