Jump to content

[HELP] problem


K4stic

Recommended Posts

addEventHandler("onMarkerHit", finish, 
function (thePlayer) 
    if ( getElementType ( thePlayer)) == "player" then 
        local fishes = getElementData( thePlayer, "fishes") 
        outputChatBox ( "You have sold "..fishes.." fishes and earned #00FF00$"..fishes * 3,thePlayer) 
        givePlayerMoney ( thePlayer,fishes* 3 ) 
        setElementData ( thePlayer, "fishes", 0, false) 
    end 
end 
) 

it's output me error => server.lua:5: attempt to concatenate local 'fishes' (a boolean value)

Link to comment

Maybe the player haven't fishes.

addEventHandler("onMarkerHit", finish, 
function (thePlayer) 
    if ( getElementType ( thePlayer)) == "player" then 
        local fishes = getElementData( thePlayer, "fishes") or 0 
        outputChatBox ( "You have sold "..fishes.." fishes and earned #00FF00$"..fishes * 3,thePlayer) 
        givePlayerMoney ( thePlayer,fishes* 3 ) 
        setElementData ( thePlayer, "fishes", 0, false) 
    end 
end 
) 

Link to comment

thx Alexs_Steel that part work

Now new problem :/

--client side

function getheVehicleSpeed() 
    return (x^2 + y^2 + z^2) ^ 0.5 
end 
  
addEvent ("enableFishermanMission",true) 
addEventHandler ("enableFishermanMission",getRootElement(), 
function() 
    if (source == getLocalPlayer()) then 
        addEventHandler ("onClientRender",getRootElement(),FishermanGUIText) 
    end 
    checkfishesbleh = setTimer( 
    function() 
        kmh = math.floor( getheVehicleSpeed( getPedOccupiedVehicle(getLocalPlayer()), getElementVelocity (getPedOccupiedVehicle(getLocalPlayer())) ) * 100 * 1.61 ) 
        curfish = getElementData(getPedOccupiedVehicle(getLocalPlayer()),"fishes") 
        if curfish > 499 then 
            setElementData(getPedOccupiedVehicle(getLocalPlayer()),"fishes",500) 
        else 
            if kmh >= 20 then 
                setElementData(getPedOccupiedVehicle(getLocalPlayer()),"fishes",curfish + math.random(1,4)) 
            end 
        end 
    end 
    ,5000,0) 
end 
) 

No error's just it not give fishes

Edited by Guest
Link to comment
thx Alexs_Steel that part work

Now new problem :/

--client side

function getheVehicleSpeed() 
    return (x^2 + y^2 + z^2) ^ 0.5 
end 
  
addEvent ("enableFishermanMission",true) 
addEventHandler ("enableFishermanMission",getRootElement(), 
function() 
    if (source == getLocalPlayer()) then 
        addEventHandler ("onClientRender",getRootElement(),FishermanGUIText) 
    end 
    checkfishesbleh = setTimer( 
    function() 
        kmh = math.floor( getheVehicleSpeed( getPedOccupiedVehicle(getLocalPlayer()), getElementVelocity (getPedOccupiedVehicle(getLocalPlayer())) ) * 100 * 1.61 ) 
        curfish = getElementData(getPedOccupiedVehicle(getLocalPlayer()),"fishes") 
        if curfish > 499 then 
            setElementData(getPedOccupiedVehicle(getLocalPlayer()),"fishes",500) 
        else 
            if kmh >= 20 then 
                setElementData(getPedOccupiedVehicle(getLocalPlayer()),"fishes",curfish + math.random(1,4)) 
            end 
        end 
    end 
    ,5000,0) 
end 
) 
) 

No error's just it not give fishes

You have a '(' extra, and 'getheVehicleSpeed' There are no argument.

Edited by Guest
Link to comment
function getElementSpeed(element,unit) 
    if (unit == nil) then unit = 0 end 
    if (isElement(element)) then 
        local x,y,z = getElementVelocity(element) 
        if (unit=="mph" or unit==1 or unit =='1') then 
            return (x^2 + y^2 + z^2) ^ 0.5 * 100 
        else 
            return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 
        end 
    else 
        outputDebugString("Not an element. Can't get speed") 
        return false 
    end 
end 
  
addEvent( 'enableFishermanMission', true ) 
addEventHandler( 'enableFishermanMission', getRootElement( ), 
    function( ) 
        if ( source == localPlayer ) then 
            addEventHandler( 'onClientRender', getRootElement( ), FishermanGUIText ) 
            Timer = setTimer( checkfishesbleh, 5000, 0 ) 
        end 
    end 
) 
  
function checkfishesbleh( ) 
    local vehicle = getPedOccupiedVehicle( localPlayer ) 
    if ( vehicle ) then 
    local aSpeed = getElementSpeed( vehicle, 'kph' ) 
    local curfish = getElementData( vehicle, 'fishes' ) or 0 
        if ( curfish > 499 ) then 
            setElementData( vehicle, 'fishes', 500 ) 
        else 
            if ( aSpeed >= 20 ) then 
                setElementData( vehicle, 'fishes', ( curfish + math.random( 4 ) ) ) 
            end 
        end 
    end 
end 

Try This, not tested.

Link to comment

--Server side

local index,theBoat; 
  
for index,theBoat in ipairs ( getElementsByType ( "vehicle" ) ) do 
if ( model == 453 ) then 
    setElementData(theBoat, "fishboat", true) 
    setElementData(theBoat, "fishes", 0) 
 end 
end 
  
finish = createMarker( 971.8, -2103.6, 2.2,"cylinder", 2, 0, 0, 255, 155) 
FishingMinigameBlip = createBlipAttachedTo ( finish, 9, 2, 0, 0, 255, 255, 0, 250, getRootElement() ) 
  
addEventHandler("onMarkerHit", finish, 
function (thePlayer) 
    if ( getElementType ( thePlayer)) == "player" then 
        local fishes = getElementData( thePlayer, "fishes") or 0 
        outputChatBox ( "You have sold "..fishes.." fishes and earned $"..fishes * 3,thePlayer) 
        givePlayerMoney ( thePlayer,fishes* 3 ) 
        setElementData ( thePlayer, "fishes", 0, false) 
    end 
end 
) 
  
addEventHandler ( "onVehicleEnter", getRootElement(), 
function(thePlayer) 
    if getElementData(getPedOccupiedVehicle(thePlayer),"fishboat") then 
        triggerClientEvent(thePlayer, "enableFishermanMission",thePlayer) 
    end 
end 
) 
  
  
addEventHandler ( "onVehicleExit", getRootElement(), 
function(thePlayer) 
    if getElementData(source,"fishboat") then 
        triggerClientEvent(thePlayer, "disableFishermanMission",thePlayer) 
    end 
end 
) 
  

--Client side

LINE NUMBER ON/OFF | EXPAND/CONTRACT | SELECT ALL 
function getElementSpeed(element,unit) 
    if (unit == nil) then unit = 0 end 
    if (isElement(element)) then 
        local x,y,z = getElementVelocity(element) 
        if (unit=="mph" or unit==1 or unit =='1') then 
            return (x^2 + y^2 + z^2) ^ 0.5 * 100 
        else 
            return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 
        end 
    else 
        outputDebugString("Not an element. Can't get speed") 
        return false 
    end 
end 
  
addEvent( 'enableFishermanMission', true ) 
addEventHandler( 'enableFishermanMission', getRootElement( ), 
    function( ) 
        if ( source == localPlayer ) then 
            addEventHandler( 'onClientRender', getRootElement( ), FishermanGUIText ) 
            Timer = setTimer( checkfishesbleh, 5000, 0 ) 
        end 
    end 
) 
  
function checkfishesbleh( ) 
    local vehicle = getPedOccupiedVehicle( localPlayer ) 
    if ( vehicle ) then 
    local aSpeed = getElementSpeed( vehicle, 'kph' ) 
    local curfish = getElementData( vehicle, 'fishes' ) or 0 
        if ( curfish > 499 ) then 
            setElementData( vehicle, 'fishes', 500 ) 
        else 
            if ( aSpeed >= 20 ) then 
                setElementData( vehicle, 'fishes', ( curfish + math.random( 4 ) ) ) 
            end 
        end 
    end 
end 
  
addEvent ("disableFishermanMission",true) 
addEventHandler ("disableFishermanMission",getRootElement(), 
function() 
    if (source == getLocalPlayer()) then 
        removeEventHandler ("onClientRender",getRootElement(),FishermanGUIText) 
        killTimer(checkfishesbleh) 
    end 
end 
) 

Link to comment

Client Side

Timer = {} 
  
function getElementSpeed(element,unit) 
    if (unit == nil) then unit = 0 end 
    if (isElement(element)) then 
        local x,y,z = getElementVelocity(element) 
        if (unit=="mph" or unit==1 or unit =='1') then 
            return (x^2 + y^2 + z^2) ^ 0.5 * 100 
        else 
            return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 
        end 
    else 
        outputDebugString("Not an element. Can't get speed") 
        return false 
    end 
end 
  
addEvent( 'enableFishermanMission', true ) 
addEventHandler( 'enableFishermanMission', getRootElement( ), 
    function( ) 
        if ( source == localPlayer ) then 
            addEventHandler( 'onClientRender', getRootElement( ), FishermanGUIText ) 
            Timer[localPlayer] = setTimer( checkfishesbleh, 5000, 0 ) 
        end 
    end 
) 
  
function checkfishesbleh( ) 
    local vehicle = getPedOccupiedVehicle( localPlayer ) 
    if ( vehicle ) then 
    local aSpeed = getElementSpeed( vehicle, 'kph' ) 
    local curfish = getElementData( vehicle, 'fishes' ) or 0 
        if ( curfish > 499 ) then 
            setElementData( vehicle, 'fishes', 500 ) 
        else 
            if ( aSpeed >= 20 ) then 
                setElementData( vehicle, 'fishes', ( curfish + math.random( 4 ) ) ) 
            end 
        end 
    end 
end 
  
addEvent( 'disableFishermanMission', true ) 
addEventHandler( 'disableFishermanMission', getRootElement( ), 
    function() 
        if ( source == localPlayer ) then 
            removeEventHandler( 'onClientRender', getRootElement( ),FishermanGUIText ) 
            killTimer( Timer[localPlayer] ) 
        end 
    end 
) 

Server Side

local index, theBoat; 
  
for index,theBoat in ipairs ( getElementsByType ( "vehicle" ) ) do 
    if ( getElementModel( theBoat )  == 453 ) then 
        setElementData( theBoat, 'fishboat', true ) 
        setElementData( theBoat, 'fishes', 0 ) 
    end 
end 
  
finish = createMarker( 971.8, -2103.6, 2.2,"cylinder", 2, 0, 0, 255, 155) 
FishingMinigameBlip = createBlipAttachedTo ( finish, 9, 2, 0, 0, 255, 255, 0, 250, getRootElement() ) 
  
addEventHandler( 'onMarkerHit', finish, 
    function (thePlayer) 
        if ( getElementType( thePlayer) == 'player' ) then 
            local fishes = getElementData( getPedOccupiedVehicle( thePlayer ), 'fishes' ) or 0 
            outputChatBox( 'You have sold '..fishes..' fishes and earned $'..fishes * 3,thePlayer) 
            givePlayerMoney( thePlayer,fishes* 3 ) 
            setElementData( thePlayer, 'fishes', 0, false ) 
        end 
    end 
) 
  
addEventHandler( 'onVehicleEnter', getRootElement( ), 
    function( thePlayer ) 
        if getElementData( source,'fishboat' ) then 
            triggerClientEvent( thePlayer, 'enableFishermanMission', thePlayer ) 
        end 
    end 
) 
  
addEventHandler ( "onVehicleExit", getRootElement(), 
    function( thePlayer ) 
        if getElementData( source, 'fishboat' ) then 
            triggerClientEvent( thePlayer, 'disableFishermanMission',thePlayer ) 
        end 
    end 
) 

Link to comment
local index, theBoat; 
  
for index, theBoat in ipairs ( getElementsByType 'vehicle' ) do 
    if ( getElementModel( theBoat )  == 453 ) then 
        setElementData( theBoat, 'fishboat', true ) 
        setElementData( theBoat, 'fishes', 0 ) 
    end 
end 
  
finish = createMarker( 971.8, -2103.6, 2.2,"cylinder", 2, 0, 0, 255, 155) 
FishingMinigameBlip = createBlipAttachedTo ( finish, 9, 2, 0, 0, 255, 255, 0, 250, getRootElement() ) 
  
addEventHandler( 'onMarkerHit', finish, 
    function( hit ) 
        if ( getElementType( hit ) == 'player' ) then 
            local fishes = getElementData( hit , 'FishPlayer' ) or 0 
            outputChatBox( 'You have sold '..fishes..' fishes and earned $'.. fishes * 3, thePlayer ) 
            givePlayerMoney( hit, fishes * 3 ) 
            setElementData( hit, 'FishPlayer', 0 ) 
        end 
    end 
) 
  
addEventHandler( 'onVehicleEnter', getRootElement( ), 
    function( thePlayer ) 
        if getElementData( source, 'fishboat' ) then 
            triggerClientEvent( thePlayer, 'enableFishermanMission', thePlayer ) 
        end 
    end 
) 
  
addEventHandler ( 'onVehicleExit', getRootElement( ), 
    function( thePlayer ) 
        if getElementData( source, 'fishboat' ) then 
            triggerClientEvent( thePlayer, 'disableFishermanMission', thePlayer ) 
            setElementData( thePlayer, 'FishPlayer', getElementData( source , 'fishes' ) or 0 ) 
            setElementData( source, 'fishes', 0 ) 
        end 
    end 
) 

Edited by Guest
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...