Jump to content

Help-me resolving 2 bugs.


neves768

Recommended Posts

Posted

BUG 1:

I Have this code(checkpoint system):

-- Viação 1001 [RJ] 
rj1001 = createMarker(2939.0646972656,-588.25177001953,11.604391098022, 'cylinder', 2.0, 255, 0, 0, 150) 
  
function rj(hitPlayer, matchingDimension) 
    if getElementData(hitPlayer,"empresa") == 1 then 
        local playerelem = getPlayerName(hitPlayer) 
        local veih = getPedOccupiedVehicle(hitPlayer) 
        local pass = getElementData(hitPlayer,"passageiros") 
        if pass > 10 and pass < 20 then 
            setPlayerMoney(hitPlayer,500) 
        elseif pass > 20 and pass < 35 then 
            setPlayerMoney(hitPlayer,649) 
        elseif pass > 35 and pass < 49 then 
            setPlayerMoney(hitPlayer,809) 
        end 
        outputChatBox(playerelem..", Aguarde, passageiros subindo/descendo.", 255, 255, 0,true) 
        setElementFrozen(veih, true) 
        setTimer(function() 
            destroyElement(rj1001) 
            flo1001 = createMarker(2930.7834472656,-589.88006591797,11.629212379456, 'cylinder', 2.0, 255, 0, 0, 150) 
            outputChatBox("CHEFE: Você tem que ir para Florianopolis", 255, 255, 0,true) 
            setElementData(hitPlayer,"passageiros",math.random(5,48)) 
            setElementFrozen(veih, false) 
        end, 60000, 1) 
    else 
    outputChatBox("CHEFE: Estou zangado com você! Está tentando pegar a rota da outra empresa? Porque não se demite?", 255, 255, 0,true) 
    end 
end 
addEventHandler("onClientMarkerHit", rj1001, rj) 
flo1001 = createMarker(2930.7834472656,-589.88006591797,11.629212379456, 'cylinder', 2.0, 255, 0, 0, 150) 
  
function flo(hitPlayer, matchingDimension) 
    if getElementData(hitPlayer,"empresa") == 1 then 
        local playerelem = getPlayerName(hitPlayer) 
        local veih = getPedOccupiedVehicle(hitPlayer) 
        local pass = getElementData(hitPlayer,"passageiros") 
        if pass > 10 and pass < 20 then 
            setPlayerMoney(hitPlayer,500) 
        elseif pass > 20 and pass < 35 then 
            setPlayerMoney(hitPlayer,649) 
        elseif pass > 35 and pass < 49 then 
            setPlayerMoney(hitPlayer,809) 
        end 
        outputChatBox(playerelem..", Aguarde, passageiros subindo/descendo.", 255, 255, 0,true) 
        setElementFrozen(veih, true) 
        setTimer(function() 
            destroyElement(flo1001) 
            outputChatBox("CHEFE: Você tem que ir para Florianopolis", 255, 255, 0,true) 
            setElementData(hitPlayer,"passageiros",math.random(5,48)) 
            setElementFrozen(veih, false) 
        end, 60000, 1) 
    else 
    outputChatBox("CHEFE: Estou zangado com você! Está tentando pegar a rota da outra empresa? Porque não se demite?", 255, 255, 0,true) 
    end 
end 
addEventHandler("onClientMarkerHit", flo1001, flo) 
setTimer(destroyElement,1000,1,flo1001) 

After player hit marker 1, marker 2 show, but if player hit marker 2 result: no actions

Don't have console erros. This script create marker 1 and 2, delete marker 2 and if player hit marker 1 shows marker 2 again(If have "markerVisible" or somenthing please send.

Another Bug:

I Have this code(Client-side) and if player choose button, calls another function saving "setElementData(getLocalPlayer(),"empresas",1)" (1 = number of business, don't have bug)

If player reconnect, don't save "empresas" Element.

function empresas() 
local empresas = getElementData(player,"empresa") 
    if not empresas then 
        GUIEditor.window[1] = guiCreateWindow(0.27, 0.36, 0.48, 0.20, "Escolha a Empresa", true) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.button[1] = guiCreateButton(11, 35, 148, 46, "Viação 1001\n3 Ônibus", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFFFFFF") 
        GUIEditor.button[2] = guiCreateButton(169, 91, 148, 46, "Guanabara\n3 Ônibus", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFE3CB00") 
        GUIEditor.button[3] = guiCreateButton(11, 91, 148, 46, "Viação Catarinense\n3 Ônibus", false, GUIEditor.window[1]) 
        GUIEditor.button[4] = guiCreateButton(327, 35, 148, 46, "Expresso Brasileiro\n3 Ônibus", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FF1FC100") 
        GUIEditor.button[5] = guiCreateButton(169, 35, 148, 46, "Viação Cometa\n3 Ônibus", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[5], "NormalTextColour", "FF0024C1") 
        GUIEditor.button[6] = guiCreateButton(327, 91, 148, 46, "VIP\nÔnibus 8x2", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[6], "NormalTextColour", "FF00F5FF")     
  
        addEventHandler("onClientGUIClick", GUIEditor.button[1], empresa1, false) 
        addEventHandler("onClientGUIClick", GUIEditor.button[2], empresa2, false) 
        addEventHandler("onClientGUIClick", GUIEditor.button[3], empresa3, false) 
        addEventHandler("onClientGUIClick", GUIEditor.button[4], empresa4, false) 
        addEventHandler("onClientGUIClick", GUIEditor.button[5], empresa5, false) 
        addEventHandler("onClientGUIClick", GUIEditor.button[6], empresavip, false) 
        showCursor(true) 
    else 
    spawn() 
    showCursor(false) 
    end 
end 
addEvent("onPlayerSpawn_",true) 
addEventHandler("onPlayerSpawn_", getRootElement(), empresas)    

Posted

it's 2 bug, Please don't see client if you want to resolve markers... It's different systems... The GUI Window need only save system(Markers are Client-side[see "OnClientMarkerHit"])

Posted

Of course element data is lost if the player leaves the server. If you want it to be permanent, you'll have to use account data.

setAccoundData 
getAccountData 

Posted

Like this?

  
function aosair(thePlayer, thePreviousAccount, theCurrentAccount, autoLogin) 
    if not (isGuestAccount (getPlayerAccount (source))) then 
    account = getPlayerAccount (source) 
        if (account) then 
        local empp = getElementData(thePlayer,"empresa") 
            setAccountData(theCurrentAccount,empp) 
        end 
    end 
end 
addEventHandler ("onPlayerQuit", getRootElement(), aosair) 
  
function aoentrar(thePlayer, thePreviousAccount, theCurrentAccount, autoLogin) 
    if not (isGuestAccount (getPlayerAccount (source))) then 
        if getAccountData (theCurrentAccount, "empresa") then 
        local emp = getAccountData (theCurrentAccount, "empresa") 
            setElementData(thePlayer,emp) 
            setElementData(source,"nasceu",1) 
        end 
    end 
end 
addEventHandler ("onPlayerLogin", getRootElement(), aoentrar) 
  

Errors:

[2013-12-19 16:47:25] WARNING: bussimu\server.lua:97: Bad argument @ 'getElementData' [Expected element at argument 1, got string 'Quit']

[2013-12-19 16:47:25] WARNING: bussimu\server.lua:98: Bad argument @ 'setAccountData' [Expected account at argument 1, got boolean]

Posted
function aosair ( ) 
    local account = getPlayerAccount ( source ) 
    if ( not isGuestAccount ( account ) ) then 
        local empp = getElementData ( source, "empresa" ) 
        setAccountData ( account, "empresa", empp ) 
    end 
end 
addEventHandler ( "onPlayerQuit", getRootElement(), aosair ) 
  
function aoentrar ( thePreviousAccount, theCurrentAccount, autoLogin ) 
    if getAccountData (theCurrentAccount, "empresa" ) then 
        local emp = getAccountData ( theCurrentAccount, "empresa" ) 
        setElementData ( source, "emrpesa", emp ) 
        setElementData ( source,"nasceu",1 ) 
    end 
end 
addEventHandler ( "onPlayerLogin", getRootElement(), aoentrar ) 

Posted
-- Viação 1001 [RJ] 
rj1001 = createMarker(2939.0646972656,-588.25177001953,11.604391098022, 'cylinder', 2.0, 255, 0, 0, 150) 
  
function rj(hitPlayer, matchingDimension) 
    if getElementData(hitPlayer,"empresa") == 1 then 
        local playerelem = getPlayerName(hitPlayer) 
        local veih = getPedOccupiedVehicle(hitPlayer) 
        local pass = getElementData(hitPlayer,"passageiros") 
        if pass > 10 and pass < 20 then 
            setPlayerMoney(hitPlayer,500) 
        elseif pass > 20 and pass < 35 then 
            setPlayerMoney(hitPlayer,649) 
        elseif pass > 35 and pass < 49 then 
            setPlayerMoney(hitPlayer,809) 
        end 
        outputChatBox(playerelem..", Aguarde, passageiros subindo/descendo.", 255, 255, 0,true) 
        setElementFrozen(veih, true) 
        setTimer(function() 
            destroyElement(rj1001) 
            flo1001 = createMarker(2930.7834472656,-589.88006591797,11.629212379456, 'cylinder', 2.0, 255, 0, 0, 150) 
            outputChatBox("CHEFE: Você tem que ir para Florianopolis", 255, 255, 0,true) 
            setElementData(hitPlayer,"passageiros",math.random(5,48)) 
            setElementFrozen(veih, false) 
            addEventHandler("onClientMarkerHit", flo1001, flo) 
        end, 60000, 1) 
    else 
    outputChatBox("CHEFE: Estou zangado com você! Está tentando pegar a rota da outra empresa? Porque não se demite?", 255, 255, 0,true) 
    end 
end 
addEventHandler("onClientMarkerHit", rj1001, rj) 
flo1001 = createMarker(2930.7834472656,-589.88006591797,11.629212379456, 'cylinder', 2.0, 255, 0, 0, 150) 
  
function flo(hitPlayer, matchingDimension) 
    if getElementData(hitPlayer,"empresa") == 1 then 
        local playerelem = getPlayerName(hitPlayer) 
        local veih = getPedOccupiedVehicle(hitPlayer) 
        local pass = getElementData(hitPlayer,"passageiros") 
        if pass > 10 and pass < 20 then 
            setPlayerMoney(hitPlayer,500) 
        elseif pass > 20 and pass < 35 then 
            setPlayerMoney(hitPlayer,649) 
        elseif pass > 35 and pass < 49 then 
            setPlayerMoney(hitPlayer,809) 
        end 
        outputChatBox(playerelem..", Aguarde, passageiros subindo/descendo.", 255, 255, 0,true) 
        setElementFrozen(veih, true) 
        setTimer(function() 
            destroyElement(flo1001) 
            outputChatBox("CHEFE: Você tem que ir para Florianopolis", 255, 255, 0,true) 
            setElementData(hitPlayer,"passageiros",math.random(5,48)) 
            setElementFrozen(veih, false) 
        end, 60000, 1) 
    else 
    outputChatBox("CHEFE: Estou zangado com você! Está tentando pegar a rota da outra empresa? Porque não se demite?", 255, 255, 0,true) 
    end 
end 
addEventHandler("onClientMarkerHit", flo1001, flo) 
setTimer(destroyElement,1000,1,flo1001) 

Posted

My friend tested and... Hitting marker 1(okay now and okay before) it's okay(hide and save Elements), but after hitting other marker don't have actions.

Posted

Marker 1 get passengers( to bus ) and Marker 2 too. Marker 1 = Stop 1, Marker 2 = Stop 2. Marker 2 only show after Marker 1 as hit. Passengers = setElementData(source,"passageiros",math.random(0,48)).

PS: Markers are in Client-side

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