ZaaKScripter Posted October 15, 2020 Share Posted October 15, 2020 Galera, sou bem leigo ainda na criação de scripts para o MTA, estou tentando aprender aos poucos, então decidi tentar criar um script basico de aluguel de bike, porem ele não funciona nada ainda, sei que deve ser algo bem besta porem ainda não tenho tanto conhecimento para identificar o problema. Desde ja agradeço a atenção. Código abaixo: local mrk = createMarker(-2405.083, -598.298, 131.648, "cylinder", 3.0, 255, 0, 0, 50) -- local do marker function msg (thePlayer) outputChatBox ("#0000FF|ALUGUEL DE BIKES CLASSE ALTA RP|", thePlayer, 255,255,255, true) outputChatBox ("----------------------------------------", thePlayer, 255,255,255, true) outputChatBox ("#0000FF 1 -|BMX| - #008000R$ 150", thePlayer, 255,255,255, true) outputChatBox ("#0000FF 2 -|MOUNTAIN| - #008000R$ 150", thePlayer, 255,255,255, true) outputChatBox ("#0000FF 3 -|CLASSIC| - #008000R$ 150", thePlayer, 255,255,255, true) outputChatBox ("----------------------------------------", thePlayer, 255,255,255, true) outputChatBox ("#0000FF3Digite '/alugar' e o numero da Bike que deseja.", thePlayer, 255,255,255, true) end addEventHandler ("onMarkerHit", mrk, msg) function comprarbmx (thePlayer) -- alugar bmx local dinheiro = getPlayerMoney (thePlayer) if isElementWithinMarker (thePlayer, mrk) then if (dinheiro > 149) then takePlayerMoney (thePlayer, 150) local bike1 = createVehicle(481, -2422.081, -609.549, 132.563) else outputChatBox ("#FF0000Você não tem dinheiro suficiente para alugar uma bicicleta.") end end end addCommandHandler ("alugar 1" comprarbmx) function comprarmountain (thePlayer) -- alugar mountain local dinheiro = getPlayerMoney (thePlayer) if isElementWithinMarker (thePlayer, mrk) then if (dinheiro > 149) then takePlayerMoney (thePlayer, 150) local bike2 = createVehicle(510, -2422.081, -609.549, 132.563) else outputChatBox ("#FF0000Você não tem dinheiro suficiente para alugar uma bicicleta.") end end end addCommandHandler ("alugar 2" comprarmountain) function comprarclassic (thePlayer) -- alugar a classic local dinheiro = getPlayerMoney (thePlayer) if isElementWithinMarker (thePlayer, mrkl) then if (dinheiro > 149) then takePlayerMoney (thePlayer, 150) local bike3 = createVehicle(509, -2422.081, -609.549, 132.563) else outputChatBox ("#FF0000Você não tem dinheiro suficiente para alugar uma bicicleta.") end end end addCommandHandler ("alugar 3" comprarclassic) Link to comment
Angelo Pereira Posted October 15, 2020 Share Posted October 15, 2020 (edited) Bom, refiz algumas coisas, onde você poder tiras suas dúvidas baseadas no que eu refiz. local mrk = createMarker(-2405.083, -598.298, 131.648, "cylinder", 3.0, 255, 0, 0, 50) -- local do marker local bikes = { } --/> ADD. function msg ( thePlayer, dimension ) if isElement(thePlayer) and getElementType( thePlayer ) == "player" and dimension then --/> ADD. outputChatBox ("#0000FF|ALUGUEL DE BIKES CLASSE ALTA RP|", thePlayer, 255,255,255, true) outputChatBox ("----------------------------------------", thePlayer, 255,255,255, true) outputChatBox ("#0000FF 1 -|BMX| - #008000R$ 150", thePlayer, 255,255,255, true) outputChatBox ("#0000FF 2 -|MOUNTAIN| - #008000R$ 150", thePlayer, 255,255,255, true) outputChatBox ("#0000FF 3 -|CLASSIC| - #008000R$ 150", thePlayer, 255,255,255, true) outputChatBox ("----------------------------------------", thePlayer, 255,255,255, true) outputChatBox ("#0000FF3Digite '/alugar' e o numero da Bike que deseja.", thePlayer, 255,255,255, true) end end addEventHandler ("onMarkerHit", mrk, msg) function alugar_bike ( thePlayer, cmd, id) if not isElementWithinMarker (thePlayer, mrk) then return outputChatBox ("Comando Apenas Funciona no Marker de Aluguel de Bikes.", thePlayer, 255, 255, 255, true) elseif not id then return outputChatBox ("Utilize o Comando : </alugar id>,", thePlayer, 255, 255, 255, true) elseif not tonumber(id) or ( tonumber(id) <= 0 ) or ( tonumber(id) >= 4 ) then return outputChatBox ("Apenas Permitido Numeros de 1 a 3.", thePlayer, 255, 255, 255, true) elseif getPlayerMoney (thePlayer) < 150 then return outputChatBox ("#FF0000Você não tem dinheiro suficiente para alugar uma bicicleta.", thePlayer, 255, 255, 255, true) end if isElement(bikes[thePlayer]) then destroyElement ( bikes[thePlayer] ) bikes[thePlayer] = nil end if tonumber(id) == 1 then outputChatBox ("#FF0000Você Alugou uma BMX.", thePlayer, 255, 255, 255, true) takePlayerMoney ( thePlayer, 150 ) bikes[thePlayer] = createVehicle(481, -2422.081, -609.549, 132.563) elseif tonumber(id) == 2 then outputChatBox ("#FF0000Você Alugou uma MOUNTAIN.", thePlayer, 255, 255, 255, true) takePlayerMoney ( thePlayer, 150 ) bikes[thePlayer] = createVehicle(510, -2422.081, -609.549, 132.563) elseif tonumber(id) == 3 then outputChatBox ("#FF0000Você Alugou uma CLASSIC.", thePlayer, 255, 255, 255, true) takePlayerMoney ( thePlayer, 150 ) bikes[thePlayer] = createVehicle(509, -2422.081, -609.549, 132.563) end end addCommandHandler ("alugar", alugar_bike ) Edited October 15, 2020 by Angelo Pereira 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now