OFF_Gunner Posted July 14, 2020 Share Posted July 14, 2020 Bom dia, boa tarde, boa noite. Estou fazendo um painel de alugar carros. Porém quando adicionei as funções de verificar se o player tem dinheiro suficiente , apenas o primeiro carro funciona. O que eu fiz de errado? Codigo: Server Side function spawn(player) if player then local carselected = getElementData(player, "CARSelect") if vehSpawn[player] then destroyElement(vehSpawn[player]) end if carselected then if carselected == 1 then local Money = getPlayerMoney(player) local Valor = 5000 if Money >= Valor then exports.Gunner_MensagensDX:outputDx ( player, "Carro alugado com sucesso!", "success" ) vehSpawn[player] = createVehicle(car1, 262.19952, -3096.83765, 6.45605) takePlayerMoney(player, 5000) else exports.Gunner_MensagensDX:outputDx ( player, "Dinheiro insuficinete!", "error" ) end elseif carselected == 2 then if Money >= Valor then exports.Gunner_MensagensDX:outputDx ( player, "Carro alugado com sucesso!", "success" ) vehSpawn[player] = createVehicle(car2, 262.19952, -3096.83765, 6.45605) takePlayerMoney(player, 5000) else exports.Gunner_MensagensDX:outputDx ( player, "Dinheiro insuficinete!", "error" ) end elseif carselected == 3 then if Money >= Valor then exports.Gunner_MensagensDX:outputDx ( player, "Carro alugado com sucesso!", "success" ) vehSpawn[player] = createVehicle(car3, 262.19952, -3096.83765, 6.45605) takePlayerMoney(player, 5000) else exports.Gunner_MensagensDX:outputDx ( player, "Dinheiro insuficinete!", "error" ) end end end end end addEvent("GiveCAR", true) addEventHandler("GiveCAR", getRootElement(), spawn) Link to comment
Blaack Posted July 15, 2020 Share Posted July 15, 2020 Tente: function spawn(player) if player then local carselected = getElementData(player, "CARSelect") if vehSpawn[player] then destroyElement(vehSpawn[player]) end local Money = getPlayerMoney(player) local Valor = 5000 if Money >= Valor then if not carselected then return end -- SE NÃO EXISTIR carselected A FUNÇÃO RETORNARÁ AO FIM! if carselected == 1 then exports.Gunner_MensagensDX:outputDx ( player, "Carro alugado com sucesso!", "success" ) vehSpawn[player] = createVehicle(car1, 262.19952, -3096.83765, 6.45605) takePlayerMoney(player, 5000) elseif carselected == 2 then exports.Gunner_MensagensDX:outputDx ( player, "Carro alugado com sucesso!", "success" ) vehSpawn[player] = createVehicle(car2, 262.19952, -3096.83765, 6.45605) takePlayerMoney(player, 5000) elseif carselected == 3 then exports.Gunner_MensagensDX:outputDx ( player, "Carro alugado com sucesso!", "success" ) vehSpawn[player] = createVehicle(car3, 262.19952, -3096.83765, 6.45605) takePlayerMoney(player, 5000) end else exports.Gunner_MensagensDX:outputDx ( player, "Dinheiro insuficiente!", "error" ) end end end addEvent("GiveCAR", true) addEventHandler("GiveCAR", getRootElement(), spawn) 1 Link to comment
OFF_Gunner Posted July 15, 2020 Author Share Posted July 15, 2020 Funcionou perfeitamente. E vendo seu codigo vi o meu erro, muito obrigado 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