g_cola=0 g_cash=0 pressed = 0 function cola_machine_init(e) end function cola_machine_main(e) PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); if PlayerDist < 80 then Text(27,65,1,"Welcome to the cola Vending machine Press E to buy a can of cola.",3000) if g_KeyPressE == 1 and pressed == 0 then if g_cash >= 50 then g_cola = g_cola + 1 g_cash = g_cash - 50 pressed = 1 end end if g_KeyPressE == 0 then pressed = 0 end end end